TABM4Dialog.cs 172 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687
  1. using Metis.ParameterSet;
  2. using OpenCvSharp;
  3. using PaintDotNet.Base.CommTool;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Data;
  7. using System.Drawing;
  8. using System.Linq;
  9. using System.Windows.Forms;
  10. namespace PaintDotNet.DedicatedAnalysis.NonferrousMetals.YYT098814_2016
  11. {
  12. internal class TABM4Dialog : NonFMetalsStandardDialog
  13. {
  14. #region 属性
  15. /// <summary>
  16. /// 是否调用了灰度化的算法
  17. /// </summary>
  18. private bool grayBitmap = false;
  19. int leftX11 = 0, topX11 = 0;
  20. Bitmap tempHole1Bitmap;
  21. ////OpenCvSharp.Point[][] contours11;
  22. int leftX22 = 0, topX22 = 0;
  23. Bitmap tempHole2Bitmap;
  24. //OpenCvSharp.Point[][] contours22;
  25. int leftX33 = 0, topX33 = 0;
  26. Bitmap tempHole3Bitmap;
  27. //OpenCvSharp.Point[][] contours33;
  28. /// <summary>
  29. /// 平均孔隙截距 用到的参数
  30. /// </summary>
  31. Color panel3__BackColor = System.Drawing.Color.Yellow;
  32. int trackBar4__Value = 3;
  33. string textBox4__Text = "10";//"100";
  34. string textBox6__Text = "25";//"10";
  35. /// <summary>
  36. /// 记录鼠标最后所在的点的y坐标
  37. /// </summary>
  38. int lineNum = 0;
  39. /// <summary>
  40. /// 竖直的辅助线
  41. /// </summary>
  42. List<Line> vlines = new List<Line>();
  43. /// <summary>
  44. /// 组织界面像素y坐标
  45. /// </summary>
  46. int planesnumcal = int.MaxValue;
  47. /// <summary>
  48. /// 基体平行线
  49. /// </summary>
  50. Line line;
  51. /// <summary>
  52. /// 是否显示辅助线
  53. /// </summary>
  54. bool button2_Clicked = false;
  55. /// <summary>
  56. /// 1显示辅助线 0隐藏辅助线
  57. /// </summary>
  58. int btnflag = 0;
  59. ///// <summary>
  60. ///// 1显示基体界面 2移动基体界面 0隐藏基体界面
  61. ///// </summary>
  62. //int btnflag = 0;
  63. /// <summary>
  64. /// 基体辅助线和组织界面辅助线
  65. /// </summary>
  66. Line top, bottom;
  67. ///// <summary>
  68. ///// 横向辅助线
  69. ///// </summary>
  70. //List<Line> hlines = new List<Line>();
  71. /// <summary>
  72. /// 横向辅助线
  73. /// </summary>
  74. List<Line> lines = new List<Line>();
  75. List<Line> lineDraws = new List<Line>();
  76. List<Line> line1s = new List<Line>();
  77. List<Line> line2s = new List<Line>();
  78. List<Line> line3s = new List<Line>();
  79. int rect_n = 0;
  80. //循环计算有效的网格线平均孔隙密度
  81. float totallength = 0;
  82. //float perlength = 0;
  83. int pointsum = 0;
  84. /// <summary>
  85. /// 每条平行辅助线和轮廓的交点的集合
  86. /// </summary>
  87. List<List<OpenCvSharp.Point>> linePoints = new List<List<OpenCvSharp.Point>>();
  88. /// <summary>
  89. /// 点击计算按钮的标识
  90. /// </summary>
  91. bool calculation = false;
  92. float totallength1 = 0;
  93. float perlength1 = 0;
  94. int pointsum1 = 0;
  95. float totallength2 = 0;
  96. float perlength2 = 0;
  97. int pointsum2 = 0;
  98. float totallength3 = 0;
  99. float perlength3 = 0;
  100. int pointsum3 = 0;
  101. //简单计算孔隙面积和总面积等
  102. double area1 = 0;
  103. double allarea1 = 0;
  104. double area2 = 0;
  105. double allarea2 = 0;
  106. double area3 = 0;
  107. double allarea3 = 0;
  108. //轮廓线颜色、基线颜色
  109. public Color rectLineColor = Color.IndianRed, baseLineColor = Color.Yellow, scopeLineColor = Color.Red, orgLineColor = Color.LightCoral, rect1LineColor = Color.MediumSpringGreen, rect2LineColor = Color.YellowGreen
  110. , rect3LineColor = Color.DarkSeaGreen, assistLineColor = Color.ForestGreen;
  111. //轮廓线线宽、基线线宽、范围线线宽、组织线线宽、区域1线宽、区域2线宽、区域3线宽、辅助线线宽
  112. public int rectLineWidth = 3, baseLineWidth = 3, scopeLineWidth = 3, orgLineWidth = 3, rect1LineWidth = 3, rect2LineWidth = 3, rect3LineWidth = 3, assistLineWidth = 3;
  113. //范围线距边界距离
  114. public int scopeMarginLeft = 25;
  115. /// <summary>
  116. /// 轮廓的线
  117. /// </summary>
  118. System.Drawing.Point[][] tempLine;
  119. ///// <summary>
  120. ///// 孔隙的mat
  121. ///// </summary>
  122. //Mat tempHoleMat;
  123. //Bitmap tempHoleBitmap;
  124. /// <summary>
  125. /// 定义变量存储鼠标操作状态 1拖动上辅助线 2拖动下辅助线 /* 3拖动平行辅助线*/
  126. /// </summary>
  127. int mouseFlag = 0;
  128. ///// <summary>
  129. ///// 1显示辅助线 2移动辅助线 0隐藏辅助线
  130. ///// </summary>
  131. //int btnflag = 0;
  132. int contoursTop = 0;
  133. ///// <summary>
  134. ///// 辅助线
  135. ///// </summary>
  136. //Line top, bottom;
  137. /// <summary>
  138. /// 下面定义三个变量存储鼠标按下的坐标
  139. /// </summary>
  140. int xPos;
  141. int yPos;
  142. ///// <summary>
  143. ///// 定义变量存储鼠标操作状态 1拖动左辅助线 2拖动右辅助线 3拖动平行辅助线
  144. ///// </summary>
  145. //int mouseFlag = 0;
  146. ///// <summary>
  147. ///// 1显示辅助线 2移动辅助线 0隐藏辅助线
  148. ///// </summary>
  149. //int btnflag = 0;
  150. /// <summary>
  151. /// 左侧辅助线
  152. /// </summary>
  153. Line lineleft;
  154. /// <summary>
  155. /// 右侧辅助线
  156. /// </summary>
  157. Line lineright;
  158. /// <summary>
  159. /// 底部辅助线
  160. /// </summary>
  161. Line linebottom;
  162. ///// <summary>
  163. ///// 横向辅助线上孔隙的线段集合
  164. ///// </summary>
  165. //List<Line> honlines = new List<Line>();
  166. ///// <summary>
  167. ///// 横向辅助线
  168. ///// </summary>
  169. //List<Line> hlines = new List<Line>();
  170. /// <summary>
  171. /// 总长度
  172. /// </summary>
  173. double res_totalL;
  174. /// <summary>
  175. /// 平均孔隙截距
  176. /// </summary>
  177. double res_perL;
  178. /// <summary>
  179. /// 截点数量
  180. /// </summary>
  181. double res_count;
  182. /// <summary>
  183. /// 选择标尺的物理长度(微米/像素)
  184. /// </summary>
  185. double physical_length = 1;
  186. /// <summary>
  187. /// 调色板
  188. /// </summary>
  189. private ColorsForm colorsFormGrid;
  190. private Panel panelC;
  191. // <summary>
  192. /// 保存窗口参数 range
  193. /// </summary>
  194. private GrainSizeAnalysisModel analysisModel;
  195. private const string ParamKey_Report = "report";//报告设置
  196. private const string ParamKey_SetGuideNumber = "setGuideNumber";//设置辅助线条数
  197. private const string ParamKey_SetShow = "setShow";//设置显示
  198. private const string ParamKey_PoreRatioColour1 = "poreRatioColour1";//孔隙1体积百分比颜色
  199. private const string ParamKey_PoreRatioColour2 = "poreRatioColour2";//孔隙2体积百分比颜色
  200. private const string ParamKey_PoreRatioColour3 = "poreRatioColour3";//孔隙3体积百分比颜色
  201. private const string ParamKey_PoreRatioShow = "poreRatioShow";//孔隙体积百分比显示
  202. private const string ParamKey_AvgRangeColour = "avgRangeColour";//平均截距颜色
  203. private const string ParamKey_AvgRangeWidth = "avgRangeWidth";//平均截距线宽
  204. private const string ParamKey_AvgRangeSpacing = "avgRangeSpacing";//平均截距间距
  205. private const string ParamKey_AvgRangeShow = "avgRangeShow";//平均截距显示
  206. private const string ParamKey_DecimalPlace = "decimalPlace";//保留小数位数
  207. //更多
  208. private const string ParamKey_RectLineColor = "rectLineColor";
  209. private const string ParamKey_BaseLineColor = "baseLineColor";
  210. private const string ParamKey_ScopeLineColor = "scopeLineColor";
  211. private const string ParamKey_OrgLineColor = "orgLineColor";
  212. private const string ParamKey_Rect1LineColor = "rect1LineColor";
  213. private const string ParamKey_Rect2LineColor = "rect2LineColor";
  214. private const string ParamKey_Rect3LineColor = "rect3LineColor";
  215. private const string ParamKey_AssistLineColor = "assistLineColor";
  216. private const string ParamKey_RectLineWidth = "rectLineWidth";//轮廓线线宽
  217. private const string ParamKey_BaseLineWidth = "baseLineWidth";//基线线宽
  218. private const string ParamKey_ScopeLineWidth = "scopeLineWidth";//范围线线宽
  219. private const string ParamKey_OrgLineWidth = "orgLineWidth";//组织线线宽
  220. private const string ParamKey_Rect1LineWidth = "rect1LineWidth";//区域1线宽
  221. private const string ParamKey_Rect2LineWidth = "rect2LineWidth";//区域2线宽
  222. private const string ParamKey_Rect3LineWidth = "rect3LineWidth";//区域3线宽
  223. private const string ParamKey_AssistLineWidth = "assistLineWidth";//辅助线线宽
  224. private const string ParamKey_ScopeMarginLeft = "scopeMarginLeft";//范围线距边界距离
  225. #endregion 属性
  226. #region 组件
  227. private Button button2;
  228. private GroupBox groupBox5;
  229. private Button button14;
  230. private Button button17;
  231. private Button button3;
  232. private Button button15;
  233. private Button button13;
  234. private Button button10;
  235. private Button button4;
  236. private Button button5;
  237. private GroupBox groupBox7;
  238. private Button button6;
  239. private TextBox textBox6;
  240. private GroupBox groupBox8;
  241. private DataGridView dataGridView1;
  242. private GroupBox groupBox11;
  243. private Panel panel4;
  244. private Panel panel5;
  245. private Panel panel2_0;
  246. private Label label1;
  247. private Label label2;
  248. private Label label7;
  249. private GroupBox groupBox6;
  250. private Panel panel3;
  251. private TrackBar trackBar4;
  252. private TextBox textBox10;
  253. private Label label4;
  254. private Label label6;
  255. private CheckBox checkBox2;
  256. private CheckBox checkBox1;
  257. private CheckBox checkBox3;
  258. private TextBox textBox4;
  259. private Label label15;
  260. private Label label17;
  261. #endregion 组件
  262. #region 构造函数
  263. public TABM4Dialog(AppWorkspace appWorkspace, int menuId) : base(appWorkspace, menuId)
  264. {
  265. Dictionary<MeasurementUnit, double> measurementUnitDictionary = Startup.instance.rules;
  266. this.physical_length = measurementUnitDictionary[MeasurementUnit.Micron];
  267. string filePath = Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\GrainSizeAnalyze\\GrainSizeAnalysisModel.xml";
  268. GrainSizeAnalysisModel analysisModelXml = XmlSerializeHelper.DESerializer<GrainSizeAnalysisModel>(FileOperationHelper.ReadStringFromFile(filePath, System.IO.FileMode.Open));
  269. this.analysisModel = analysisModelXml.cloneListParamModel(this.menuId);
  270. foreach (var item in this.analysisModel.ListParam)
  271. item.setValue();
  272. //
  273. //初始化色板
  274. //
  275. this.colorsFormGrid = new ColorsForm();
  276. this.colorsFormGrid.StartPosition = FormStartPosition.CenterScreen;
  277. this.colorsFormGrid.setSaveBtn_Click(new System.EventHandler(this.gridColorChanged));
  278. GetListParamModel();
  279. InitGridHeader();
  280. }
  281. /// <summary>
  282. /// 初始化表头
  283. /// </summary>
  284. private void InitGridHeader()
  285. {
  286. //
  287. //数据展示表
  288. //
  289. this.dataGridView1.ColumnHeadersHeight = 23;// 30;//0914###18533
  290. DataGridViewTextBoxColumn h1 = new DataGridViewTextBoxColumn();
  291. h1.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
  292. h1.Width = 144;
  293. DataGridViewTextBoxColumn h2 = new DataGridViewTextBoxColumn();
  294. h2.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
  295. h2.Width = 144;
  296. DataGridViewTextBoxColumn h3 = new DataGridViewTextBoxColumn();
  297. h3.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
  298. h3.Width = 144;
  299. DataGridViewTextBoxColumn h4 = new DataGridViewTextBoxColumn();
  300. h4.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
  301. h4.Width = 160;
  302. DataGridViewTextBoxColumn h5 = new DataGridViewTextBoxColumn();
  303. h5.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
  304. h5.Width = 144;
  305. DataGridViewTextBoxColumn h611 = new DataGridViewTextBoxColumn();
  306. h611.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
  307. h611.Width = 156;
  308. DataGridViewTextBoxColumn h711 = new DataGridViewTextBoxColumn();
  309. h711.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
  310. h711.Width = 144;
  311. this.dataGridView1.Columns.Add(h1);
  312. this.dataGridView1.Columns.Add(h2);
  313. this.dataGridView1.Columns.Add(h3);
  314. this.dataGridView1.Columns.Add(h4);
  315. this.dataGridView1.Columns.Add(h5);
  316. this.dataGridView1.Columns.Add(h611);
  317. this.dataGridView1.Columns.Add(h711);
  318. CustomControl.DataGridViewHelper helper = new CustomControl.DataGridViewHelper(this.dataGridView1);
  319. helper.Headers.Add(new CustomControl.DataGridViewHelper.TopHeader(0, 1, PdnResources.GetString("Menu.rea.Text")));
  320. helper.Headers.Add(new CustomControl.DataGridViewHelper.TopHeader(1, 1, PdnResources.GetString("Menu.area.text")));
  321. helper.Headers.Add(new CustomControl.DataGridViewHelper.TopHeader(2, 1, PdnResources.GetString("Menu.Thetotalarea.text")));
  322. helper.Headers.Add(new CustomControl.DataGridViewHelper.TopHeader(3, 1, PdnResources.GetString("Menu.Percentageofholevolume.text")));
  323. helper.Headers.Add(new CustomControl.DataGridViewHelper.TopHeader(4, 1, PdnResources.GetString("Menu.Totallengthofintercept.text")));
  324. helper.Headers.Add(new CustomControl.DataGridViewHelper.TopHeader(5, 1, PdnResources.GetString("Menu.Meanporeintercept.text")));
  325. helper.Headers.Add(new CustomControl.DataGridViewHelper.TopHeader(6, 1, PdnResources.GetString("Menu.Numberofintercept.text")));
  326. this.dataGridView1.Columns[0].SortMode = DataGridViewColumnSortMode.NotSortable;
  327. this.dataGridView1.Columns[0].ReadOnly = true;
  328. this.dataGridView1.Columns[0].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;//文字居中
  329. this.dataGridView1.Columns[1].SortMode = DataGridViewColumnSortMode.NotSortable;
  330. this.dataGridView1.Columns[1].ReadOnly = true;
  331. this.dataGridView1.Columns[1].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
  332. this.dataGridView1.Columns[2].SortMode = DataGridViewColumnSortMode.NotSortable;
  333. this.dataGridView1.Columns[2].ReadOnly = true;
  334. this.dataGridView1.Columns[2].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
  335. this.dataGridView1.Columns[3].SortMode = DataGridViewColumnSortMode.NotSortable;
  336. this.dataGridView1.Columns[3].ReadOnly = true;
  337. this.dataGridView1.Columns[3].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
  338. this.dataGridView1.Columns[4].SortMode = DataGridViewColumnSortMode.NotSortable;
  339. this.dataGridView1.Columns[4].ReadOnly = true;
  340. this.dataGridView1.Columns[4].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
  341. this.dataGridView1.Columns[5].SortMode = DataGridViewColumnSortMode.NotSortable;
  342. this.dataGridView1.Columns[5].ReadOnly = true;
  343. this.dataGridView1.Columns[5].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
  344. this.dataGridView1.Columns[6].SortMode = DataGridViewColumnSortMode.NotSortable;
  345. this.dataGridView1.Columns[6].ReadOnly = true;
  346. this.dataGridView1.Columns[6].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
  347. //this.dataGridView1.Columns[4].SortMode = DataGridViewColumnSortMode.NotSortable;
  348. //this.dataGridView1.Columns[4].ReadOnly = true;
  349. //this.dataGridView1.Columns[4].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
  350. this.dataGridView1.AllowUserToResizeRows = false;
  351. this.dataGridView1.AllowUserToResizeColumns = false;
  352. //分析结果表
  353. //this.dataGridView2.ColumnHeadersHeight = 30;
  354. //DataGridViewTextBoxColumn h6 = new DataGridViewTextBoxColumn();
  355. //h6.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
  356. //h6.Width = 185;
  357. //DataGridViewTextBoxColumn h7 = new DataGridViewTextBoxColumn();
  358. //h7.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
  359. //h7.Width = 185;
  360. //DataGridViewTextBoxColumn h8 = new DataGridViewTextBoxColumn();
  361. //h8.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
  362. //h8.Width = 185;
  363. //DataGridViewTextBoxColumn h9 = new DataGridViewTextBoxColumn();
  364. //h9.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
  365. //h9.Width = 185;
  366. //DataGridViewTextBoxColumn h10 = new DataGridViewTextBoxColumn();
  367. //h10.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
  368. //h10.Width = 185;
  369. //DataGridViewTextBoxColumn h11 = new DataGridViewTextBoxColumn();
  370. //h11.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
  371. //h11.Width = 185;
  372. //DataGridViewTextBoxColumn h12 = new DataGridViewTextBoxColumn();
  373. //h12.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
  374. //h12.Width = 190;
  375. //DataGridViewTextBoxColumn h13 = new DataGridViewTextBoxColumn();
  376. //h13.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
  377. //h13.Width = 190;
  378. //this.dataGridView2.Columns.Add(h6);
  379. //this.dataGridView2.Columns.Add(h7);
  380. //this.dataGridView2.Columns.Add(h8);
  381. //this.dataGridView2.Columns.Add(h9);
  382. //this.dataGridView2.Columns.Add(h10);
  383. //this.dataGridView2.Columns.Add(h11);
  384. //this.dataGridView2.Columns.Add(h12);
  385. //this.dataGridView2.Columns.Add(h13);
  386. //DataGridViewHelper helper2 = new DataGridViewHelper(this.dataGridView2);
  387. //helper2.Headers.Add(new DataGridViewHelper.TopHeader(0, 1, PdnResources.GetString("Menu.picture.Text")));
  388. //helper2.Headers.Add(new DataGridViewHelper.TopHeader(1, 1, PdnResources.GetString("Menu.rea.Text")));
  389. //helper2.Headers.Add(new DataGridViewHelper.TopHeader(2, 1, PdnResources.GetString("Menu.area.text")));
  390. //helper2.Headers.Add(new DataGridViewHelper.TopHeader(3, 1, PdnResources.GetString("Menu.Thetotalarea.text")));
  391. //helper2.Headers.Add(new DataGridViewHelper.TopHeader(4, 1, PdnResources.GetString("Menu.Percentageofholevolume.text")));
  392. //helper2.Headers.Add(new DataGridViewHelper.TopHeader(5, 1, PdnResources.GetString("Menu.Totallengthofporeintercepts.text")));
  393. //helper2.Headers.Add(new DataGridViewHelper.TopHeader(6, 1, PdnResources.GetString("Menu.Meanporeintercept.text")));
  394. //helper2.Headers.Add(new DataGridViewHelper.TopHeader(7, 1, PdnResources.GetString("Menu.Numberofintercept.text")));
  395. //this.dataGridView2.Columns[0].SortMode = DataGridViewColumnSortMode.NotSortable;
  396. //this.dataGridView2.Columns[0].ReadOnly = true;
  397. //this.dataGridView2.Columns[1].SortMode = DataGridViewColumnSortMode.NotSortable;
  398. //this.dataGridView2.Columns[1].ReadOnly = true;
  399. //this.dataGridView2.Columns[2].SortMode = DataGridViewColumnSortMode.NotSortable;
  400. //this.dataGridView2.Columns[2].ReadOnly = true;
  401. //this.dataGridView2.Columns[3].SortMode = DataGridViewColumnSortMode.NotSortable;
  402. //this.dataGridView2.Columns[3].ReadOnly = true;
  403. //this.dataGridView2.Columns[4].SortMode = DataGridViewColumnSortMode.NotSortable;
  404. //this.dataGridView2.Columns[4].ReadOnly = true;
  405. //this.dataGridView2.Columns[5].SortMode = DataGridViewColumnSortMode.NotSortable;
  406. //this.dataGridView2.Columns[5].ReadOnly = true;
  407. //this.dataGridView2.Columns[6].SortMode = DataGridViewColumnSortMode.NotSortable;
  408. //this.dataGridView2.Columns[6].ReadOnly = true;
  409. //this.dataGridView2.Columns[7].SortMode = DataGridViewColumnSortMode.NotSortable;
  410. //this.dataGridView2.Columns[7].ReadOnly = true;
  411. //this.dataGridView2.AllowUserToResizeRows = false;
  412. //this.dataGridView2.AllowUserToResizeColumns = false;
  413. //DataGridViewTextBoxColumn Column2_total = new System.Windows.Forms.DataGridViewTextBoxColumn();
  414. DataGridViewTextBoxColumn Column3_total = new System.Windows.Forms.DataGridViewTextBoxColumn();
  415. DataGridViewTextBoxColumn Column4_total = new System.Windows.Forms.DataGridViewTextBoxColumn();
  416. DataGridViewTextBoxColumn Column5_total = new System.Windows.Forms.DataGridViewTextBoxColumn();
  417. DataGridViewTextBoxColumn Column6_total = new System.Windows.Forms.DataGridViewTextBoxColumn();
  418. DataGridViewTextBoxColumn Column7_total = new System.Windows.Forms.DataGridViewTextBoxColumn();
  419. DataGridViewTextBoxColumn Column8_total = new System.Windows.Forms.DataGridViewTextBoxColumn();
  420. //Column2_total.Name = "Column2_total";
  421. //Column2_total.ReadOnly = true;
  422. Column3_total.Name = "Column3_total";
  423. Column3_total.ReadOnly = true;
  424. Column4_total.Name = "Column4_total";
  425. Column4_total.ReadOnly = true;
  426. Column5_total.Name = "Column5_total";
  427. Column5_total.ReadOnly = true;
  428. Column6_total.Name = "Column6_total";
  429. Column6_total.ReadOnly = true;
  430. Column7_total.Name = "Column7_total";
  431. Column7_total.ReadOnly = true;
  432. Column8_total.Name = "Column8_total";
  433. Column8_total.ReadOnly = true;
  434. //Column2_total.HeaderText = PdnResources.GetString("Menu.rea.Text");
  435. Column3_total.HeaderText = PdnResources.GetString("Menu.area.text");
  436. Column4_total.HeaderText = PdnResources.GetString("Menu.Thetotalarea.text");
  437. Column5_total.HeaderText = PdnResources.GetString("Menu.Percentageofholevolume.text");
  438. Column6_total.HeaderText = PdnResources.GetString("Menu.Totallengthofporeintercepts.text");
  439. Column7_total.HeaderText = PdnResources.GetString("Menu.Meanporeintercept.text");
  440. Column8_total.HeaderText = PdnResources.GetString("Menu.Numberofintercept.text");
  441. this.dataGridView_Total.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
  442. //Column2_total,
  443. Column3_total,
  444. Column4_total,
  445. Column5_total,
  446. Column6_total,
  447. Column7_total,
  448. Column8_total});
  449. this.dataGridView_Total.Columns[0].SortMode = DataGridViewColumnSortMode.NotSortable;
  450. this.dataGridView_Total.Columns[0].ReadOnly = true;
  451. this.dataGridView_Total.Columns[1].SortMode = DataGridViewColumnSortMode.NotSortable;
  452. this.dataGridView_Total.Columns[1].ReadOnly = true;
  453. this.dataGridView_Total.Columns[2].SortMode = DataGridViewColumnSortMode.NotSortable;
  454. this.dataGridView_Total.Columns[2].ReadOnly = true;
  455. this.dataGridView_Total.Columns[3].SortMode = DataGridViewColumnSortMode.NotSortable;
  456. this.dataGridView_Total.Columns[3].ReadOnly = true;
  457. this.dataGridView_Total.Columns[4].SortMode = DataGridViewColumnSortMode.NotSortable;
  458. this.dataGridView_Total.Columns[4].ReadOnly = true;
  459. this.dataGridView_Total.Columns[5].SortMode = DataGridViewColumnSortMode.NotSortable;
  460. this.dataGridView_Total.Columns[5].ReadOnly = true;
  461. //this.dataGridView_Total.Columns[6].SortMode = DataGridViewColumnSortMode.NotSortable;
  462. //this.dataGridView_Total.Columns[6].ReadOnly = true;
  463. DataGridViewTextBoxColumn Column1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
  464. DataGridViewTextBoxColumn Column2 = new System.Windows.Forms.DataGridViewTextBoxColumn();
  465. DataGridViewTextBoxColumn Column3 = new System.Windows.Forms.DataGridViewTextBoxColumn();
  466. DataGridViewTextBoxColumn Column4 = new System.Windows.Forms.DataGridViewTextBoxColumn();
  467. DataGridViewTextBoxColumn Column5 = new System.Windows.Forms.DataGridViewTextBoxColumn();
  468. DataGridViewTextBoxColumn Column6 = new System.Windows.Forms.DataGridViewTextBoxColumn();
  469. DataGridViewTextBoxColumn Column7 = new System.Windows.Forms.DataGridViewTextBoxColumn();
  470. DataGridViewTextBoxColumn Column8 = new System.Windows.Forms.DataGridViewTextBoxColumn();
  471. Column1.Name = "Column1";
  472. Column1.ReadOnly = true;
  473. Column2.Name = "Column2";
  474. Column2.ReadOnly = true;
  475. Column3.Name = "Column3";
  476. Column3.ReadOnly = true;
  477. Column4.Name = "Column4";
  478. Column4.ReadOnly = true;
  479. Column5.Name = "Column5";
  480. Column5.ReadOnly = true;
  481. Column6.Name = "Column6";
  482. Column6.ReadOnly = true;
  483. Column7.Name = "Column7";
  484. Column7.ReadOnly = true;
  485. Column8.Name = "Column8";
  486. Column8.ReadOnly = true;
  487. Column1.HeaderText = PdnResources.GetString("Menu.picture.Text");
  488. Column2.HeaderText = PdnResources.GetString("Menu.rea.Text");
  489. Column3.HeaderText = PdnResources.GetString("Menu.area.text");
  490. Column4.HeaderText = PdnResources.GetString("Menu.Thetotalarea.text");
  491. Column5.HeaderText = PdnResources.GetString("Menu.Percentageofholevolume.text");
  492. Column6.HeaderText = PdnResources.GetString("Menu.Totallengthofporeintercepts.text");
  493. Column7.HeaderText = PdnResources.GetString("Menu.Meanporeintercept.text");
  494. Column8.HeaderText = PdnResources.GetString("Menu.Numberofintercept.text");
  495. this.dataGridView2.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
  496. Column1,
  497. Column2,
  498. Column3,
  499. Column4,
  500. Column5,
  501. Column6,
  502. Column7,
  503. Column8});
  504. //Column1.Width = 195;
  505. //Column2.Width = 165;
  506. //Column3.Width = 165;
  507. //Column4.Width = 165;
  508. this.dataGridView2.Columns[0].SortMode = DataGridViewColumnSortMode.NotSortable;
  509. this.dataGridView2.Columns[0].ReadOnly = true;
  510. this.dataGridView2.Columns[1].SortMode = DataGridViewColumnSortMode.NotSortable;
  511. this.dataGridView2.Columns[1].ReadOnly = true;
  512. this.dataGridView2.Columns[2].SortMode = DataGridViewColumnSortMode.NotSortable;
  513. this.dataGridView2.Columns[2].ReadOnly = true;
  514. this.dataGridView2.Columns[3].SortMode = DataGridViewColumnSortMode.NotSortable;
  515. this.dataGridView2.Columns[3].ReadOnly = true;
  516. this.dataGridView2.Columns[4].SortMode = DataGridViewColumnSortMode.NotSortable;
  517. this.dataGridView2.Columns[4].ReadOnly = true;
  518. this.dataGridView2.Columns[5].SortMode = DataGridViewColumnSortMode.NotSortable;
  519. this.dataGridView2.Columns[5].ReadOnly = true;
  520. this.dataGridView2.Columns[6].SortMode = DataGridViewColumnSortMode.NotSortable;
  521. this.dataGridView2.Columns[6].ReadOnly = true;
  522. this.dataGridView2.Columns[7].SortMode = DataGridViewColumnSortMode.NotSortable;
  523. this.dataGridView2.Columns[7].ReadOnly = true;
  524. }
  525. #endregion 构造函数
  526. #region 初始化组件和实现组件事件
  527. private void InitializeLanguageText()
  528. {
  529. this.button6.Text = PdnResources.GetString("Menu.More.text");
  530. this.groupBox7.Text = PdnResources.GetString("Menu.Organizationinterfacesettings.text");
  531. //this.label6.Text = PdnResources.GetString("Menu.color.text") + ":";
  532. //this.label4.Text = PdnResources.GetString("Menu.Linewidth.text") + ":";
  533. //this.groupBox6.Text = PdnResources.GetString("Menu.holesetting.text");
  534. //this.label5.Text = PdnResources.GetString("Menu.color.text") + ":";
  535. //this.groupBox10.Text = "孔隙";// PdnResources.GetString("Menu.contour.text");
  536. this.button2.Text = PdnResources.GetString("Menu.reinformation.text");
  537. this.button5.Text = PdnResources.GetString("Menu.Image.Grayscale.Text");
  538. this.button4/*button3*/.Text = PdnResources.GetString("Menu.BinaryAction.ErosionExtraction.Text");
  539. this.button10.Text = PdnResources.GetString("Menu.BinaryAction.DilationExtraction.Text");
  540. this.button13.Text = PdnResources.GetString("Menu.Definetheorganizationinterface.text");
  541. this.button3.Text = PdnResources.GetString("Menu.reinformation.text");
  542. this.button15.Text = PdnResources.GetString("Menu.searchcontour.text");
  543. this.button17.Text = PdnResources.GetString("Menu.auto-adjust.text");
  544. this.button14.Text = PdnResources.GetString("Menu.easemodifytheoutline.Text");
  545. this.groupBox5.Text = PdnResources.GetString("Menu.Basicoperation.text");
  546. this.Text = "YYT 0988.14-2016(" + PdnResources.GetString("Menu.Organizationinterfacegradientmethod.text") + ")";
  547. //this.label11.Text = PdnResources.GetString("Menu.Totallengthofporeintercepts.text") + ":";
  548. //this.label12.Text = PdnResources.GetString("Menu.Meanporeintercept.text") + ":";
  549. //this.label13.Text = PdnResources.GetString("Menu.Numberofintercept.text") + ":";
  550. this.groupBox8.Text = PdnResources.GetString("Menu.reckoning.text");
  551. //this.groupBox8.Text = PdnResources.GetString("Menu.result.text");
  552. //this.label18.Text = PdnResources.GetString("Menu.color.text") + ":";
  553. this.label17.Text = PdnResources.GetString("Menu.Numberofauxiliarylines.text") + ":";
  554. //this.label16.Text = PdnResources.GetString("Menu.Linewidth.text") + ":";
  555. //this.label15.Text = PdnResources.GetString("Menu.spacing.text") + ":";
  556. this.label7.Text = PdnResources.GetString("Menu.hole1.text") + ":";
  557. this.label2.Text = PdnResources.GetString("Menu.hole2.text") + ":";
  558. this.label1.Text = PdnResources.GetString("Menu.hole3.text") + ":";
  559. this.groupBox11.Text = PdnResources.GetString("Menu.Percentageofholevolume.text");
  560. this.label6.Text = PdnResources.GetString("Menu.color.text") + ":";
  561. this.label4.Text = PdnResources.GetString("Menu.Linewidth.text") + ":";
  562. this.groupBox6.Text = PdnResources.GetString("Menu.Meanporeintercept.text");
  563. this.checkBox1.Text = "显示";
  564. this.checkBox2.Text = "显示";
  565. this.checkBox3.Text = "显示";
  566. this.label15.Text = "间距";
  567. }
  568. private void InitializeComponent()
  569. {
  570. this.button2 = new System.Windows.Forms.Button();
  571. this.groupBox5 = new System.Windows.Forms.GroupBox();
  572. this.button14 = new System.Windows.Forms.Button();
  573. this.button17 = new System.Windows.Forms.Button();
  574. this.button3 = new System.Windows.Forms.Button();
  575. this.button15 = new System.Windows.Forms.Button();
  576. this.button13 = new System.Windows.Forms.Button();
  577. this.button10 = new System.Windows.Forms.Button();
  578. this.button4 = new System.Windows.Forms.Button();
  579. this.button5 = new System.Windows.Forms.Button();
  580. this.groupBox7 = new System.Windows.Forms.GroupBox();
  581. this.checkBox3 = new System.Windows.Forms.CheckBox();
  582. this.button6 = new System.Windows.Forms.Button();
  583. this.textBox6 = new System.Windows.Forms.TextBox();
  584. this.label17 = new System.Windows.Forms.Label();
  585. this.groupBox8 = new System.Windows.Forms.GroupBox();
  586. this.dataGridView1 = new System.Windows.Forms.DataGridView();
  587. this.groupBox11 = new System.Windows.Forms.GroupBox();
  588. this.checkBox2 = new System.Windows.Forms.CheckBox();
  589. this.panel4 = new System.Windows.Forms.Panel();
  590. this.panel5 = new System.Windows.Forms.Panel();
  591. this.panel2_0 = new System.Windows.Forms.Panel();
  592. this.label1 = new System.Windows.Forms.Label();
  593. this.label2 = new System.Windows.Forms.Label();
  594. this.label7 = new System.Windows.Forms.Label();
  595. this.groupBox6 = new System.Windows.Forms.GroupBox();
  596. this.textBox4 = new System.Windows.Forms.TextBox();
  597. this.label15 = new System.Windows.Forms.Label();
  598. this.checkBox1 = new System.Windows.Forms.CheckBox();
  599. this.panel3 = new System.Windows.Forms.Panel();
  600. this.trackBar4 = new System.Windows.Forms.TrackBar();
  601. this.textBox10 = new System.Windows.Forms.TextBox();
  602. this.label4 = new System.Windows.Forms.Label();
  603. this.label6 = new System.Windows.Forms.Label();
  604. this.groupBox_img.SuspendLayout();
  605. this.groupBox_report.SuspendLayout();
  606. this.groupBox_analysisResult1.SuspendLayout();
  607. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1_0)).BeginInit();
  608. this.groupBox5.SuspendLayout();
  609. this.groupBox7.SuspendLayout();
  610. this.groupBox8.SuspendLayout();
  611. ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit();
  612. this.groupBox11.SuspendLayout();
  613. this.groupBox6.SuspendLayout();
  614. ((System.ComponentModel.ISupportInitialize)(this.trackBar4)).BeginInit();
  615. this.SuspendLayout();
  616. //
  617. // button2
  618. //
  619. this.button2.Location = new System.Drawing.Point(96, 39);
  620. this.button2.Name = "button2";
  621. this.button2.Size = new System.Drawing.Size(75, 23);
  622. this.button2.TabIndex = 6;
  623. this.button2.UseVisualStyleBackColor = true;
  624. //
  625. // groupBox5
  626. //
  627. this.groupBox5.Controls.Add(this.button14);
  628. this.groupBox5.Controls.Add(this.button17);
  629. this.groupBox5.Controls.Add(this.button3);
  630. this.groupBox5.Controls.Add(this.button15);
  631. this.groupBox5.Controls.Add(this.button13);
  632. this.groupBox5.Controls.Add(this.button10);
  633. this.groupBox5.Controls.Add(this.button4);
  634. this.groupBox5.Controls.Add(this.button5);
  635. this.groupBox5.Location = new System.Drawing.Point(180, 317);
  636. this.groupBox5.Name = "groupBox5";
  637. this.groupBox5.Size = new System.Drawing.Size(353, 66);
  638. this.groupBox5.TabIndex = 44;
  639. this.groupBox5.TabStop = false;
  640. //
  641. // button14
  642. //
  643. this.button14.Location = new System.Drawing.Point(267, 40);
  644. this.button14.Name = "button14";
  645. this.button14.Size = new System.Drawing.Size(75, 23);
  646. this.button14.TabIndex = 8;
  647. this.button14.UseVisualStyleBackColor = true;
  648. this.button14.Click += new System.EventHandler(this.button14_Click);
  649. //
  650. // button17
  651. //
  652. this.button17.Location = new System.Drawing.Point(180, 40);
  653. this.button17.Name = "button17";
  654. this.button17.Size = new System.Drawing.Size(75, 23);
  655. this.button17.TabIndex = 7;
  656. this.button17.UseVisualStyleBackColor = true;
  657. this.button17.Click += new System.EventHandler(this.button17_Click);
  658. //
  659. // button3
  660. //
  661. this.button3.Location = new System.Drawing.Point(103, 40);
  662. this.button3.Name = "button3";
  663. this.button3.Size = new System.Drawing.Size(65, 23);
  664. this.button3.TabIndex = 6;
  665. this.button3.UseVisualStyleBackColor = true;
  666. this.button3.Click += new System.EventHandler(this.button3_Click);
  667. //
  668. // button15
  669. //
  670. this.button15.Location = new System.Drawing.Point(267, 15);
  671. this.button15.Name = "button15";
  672. this.button15.Size = new System.Drawing.Size(75, 23);
  673. this.button15.TabIndex = 5;
  674. this.button15.UseVisualStyleBackColor = true;
  675. this.button15.Click += new System.EventHandler(this.button15_Click);
  676. //
  677. // button13
  678. //
  679. this.button13.Location = new System.Drawing.Point(9, 40);
  680. this.button13.Name = "button13";
  681. this.button13.Size = new System.Drawing.Size(85, 23);
  682. this.button13.TabIndex = 3;
  683. this.button13.UseVisualStyleBackColor = true;
  684. this.button13.Click += new System.EventHandler(this.button13_Click);
  685. //
  686. // button10
  687. //
  688. this.button10.Location = new System.Drawing.Point(180, 15);
  689. this.button10.Name = "button10";
  690. this.button10.Size = new System.Drawing.Size(75, 23);
  691. this.button10.TabIndex = 2;
  692. this.button10.UseVisualStyleBackColor = true;
  693. this.button10.Click += new System.EventHandler(this.button10_Click);
  694. //
  695. // button4
  696. //
  697. this.button4.Location = new System.Drawing.Point(103, 15);
  698. this.button4.Name = "button4";
  699. this.button4.Size = new System.Drawing.Size(65, 23);
  700. this.button4.TabIndex = 1;
  701. this.button4.UseVisualStyleBackColor = true;
  702. this.button4.Click += new System.EventHandler(this.button4_Click);
  703. //
  704. // button5
  705. //
  706. this.button5.Location = new System.Drawing.Point(9, 15);
  707. this.button5.Name = "button5";
  708. this.button5.Size = new System.Drawing.Size(85, 23);
  709. this.button5.TabIndex = 0;
  710. this.button5.UseVisualStyleBackColor = true;
  711. this.button5.Click += new System.EventHandler(this.button5_Click);
  712. //
  713. // groupBox7
  714. //
  715. this.groupBox7.Controls.Add(this.checkBox3);
  716. this.groupBox7.Controls.Add(this.button6);
  717. this.groupBox7.Controls.Add(this.textBox6);
  718. this.groupBox7.Controls.Add(this.label17);
  719. this.groupBox7.Location = new System.Drawing.Point(180, 389);
  720. this.groupBox7.Name = "groupBox7";
  721. this.groupBox7.Size = new System.Drawing.Size(355, 35);
  722. this.groupBox7.TabIndex = 45;
  723. this.groupBox7.TabStop = false;
  724. //
  725. // checkBox3
  726. //
  727. this.checkBox3.AutoSize = true;
  728. this.checkBox3.Location = new System.Drawing.Point(160, 16);
  729. this.checkBox3.Name = "checkBox3";
  730. this.checkBox3.Size = new System.Drawing.Size(15, 14);
  731. this.checkBox3.TabIndex = 26;
  732. this.checkBox3.UseVisualStyleBackColor = true;
  733. this.checkBox3.CheckedChanged += new System.EventHandler(this.checkBox3_CheckedChanged);
  734. //
  735. // button6
  736. //
  737. this.button6.Location = new System.Drawing.Point(284, 10);
  738. this.button6.Name = "button6";
  739. this.button6.Size = new System.Drawing.Size(58, 23);
  740. this.button6.TabIndex = 8;
  741. this.button6.UseVisualStyleBackColor = true;
  742. this.button6.Click += new System.EventHandler(this.button6_Click);
  743. //
  744. // textBox6
  745. //
  746. this.textBox6.Location = new System.Drawing.Point(88, 12);
  747. this.textBox6.Name = "textBox6";
  748. this.textBox6.Size = new System.Drawing.Size(55, 21);
  749. this.textBox6.TabIndex = 10;
  750. this.textBox6.Text = "25";
  751. this.textBox6.TextChanged += new System.EventHandler(this.textBox6_TextChanged);
  752. //
  753. // label17
  754. //
  755. this.label17.AutoSize = true;
  756. this.label17.Location = new System.Drawing.Point(15, 17);
  757. this.label17.Name = "label17";
  758. this.label17.Size = new System.Drawing.Size(0, 12);
  759. this.label17.TabIndex = 1;
  760. //
  761. // groupBox8
  762. //
  763. this.groupBox8.Controls.Add(this.dataGridView1);
  764. this.groupBox8.Location = new System.Drawing.Point(178, 522);
  765. this.groupBox8.Name = "groupBox8";
  766. this.groupBox8.Size = new System.Drawing.Size(357, 134);
  767. this.groupBox8.TabIndex = 46;
  768. this.groupBox8.TabStop = false;
  769. //
  770. // dataGridView1
  771. //
  772. this.dataGridView1.AllowUserToAddRows = false;
  773. this.dataGridView1.AllowUserToDeleteRows = false;
  774. this.dataGridView1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  775. | System.Windows.Forms.AnchorStyles.Left)
  776. | System.Windows.Forms.AnchorStyles.Right)));
  777. this.dataGridView1.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill;
  778. this.dataGridView1.BackgroundColor = System.Drawing.Color.White;
  779. this.dataGridView1.ColumnHeadersBorderStyle = System.Windows.Forms.DataGridViewHeaderBorderStyle.None;
  780. this.dataGridView1.Location = new System.Drawing.Point(7, 21);
  781. this.dataGridView1.MultiSelect = false;
  782. this.dataGridView1.Name = "dataGridView1";
  783. this.dataGridView1.RowHeadersVisible = false;
  784. this.dataGridView1.RowTemplate.Height = 23;
  785. this.dataGridView1.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
  786. this.dataGridView1.Size = new System.Drawing.Size(344, 107);
  787. this.dataGridView1.TabIndex = 0;
  788. //
  789. // groupBox11
  790. //
  791. this.groupBox11.Controls.Add(this.checkBox2);
  792. this.groupBox11.Controls.Add(this.panel4);
  793. this.groupBox11.Controls.Add(this.panel5);
  794. this.groupBox11.Controls.Add(this.panel2_0);
  795. this.groupBox11.Controls.Add(this.label1);
  796. this.groupBox11.Controls.Add(this.label2);
  797. this.groupBox11.Controls.Add(this.label7);
  798. this.groupBox11.Location = new System.Drawing.Point(180, 428);
  799. this.groupBox11.Name = "groupBox11";
  800. this.groupBox11.Size = new System.Drawing.Size(355, 41);
  801. this.groupBox11.TabIndex = 47;
  802. this.groupBox11.TabStop = false;
  803. //
  804. // checkBox2
  805. //
  806. this.checkBox2.AutoSize = true;
  807. this.checkBox2.Location = new System.Drawing.Point(294, 21);
  808. this.checkBox2.Name = "checkBox2";
  809. this.checkBox2.Size = new System.Drawing.Size(15, 14);
  810. this.checkBox2.TabIndex = 23;
  811. this.checkBox2.UseVisualStyleBackColor = true;
  812. this.checkBox2.CheckedChanged += new System.EventHandler(this.checkBox2_CheckedChanged);
  813. //
  814. // panel4
  815. //
  816. this.panel4.BackColor = System.Drawing.Color.LightCoral;
  817. this.panel4.Location = new System.Drawing.Point(248, 18);
  818. this.panel4.Name = "panel4";
  819. this.panel4.Size = new System.Drawing.Size(34, 21);
  820. this.panel4.TabIndex = 25;
  821. this.panel4.Click += new System.EventHandler(this.panel2_Click);
  822. //
  823. // panel5
  824. //
  825. this.panel5.BackColor = System.Drawing.Color.Orange;
  826. this.panel5.Location = new System.Drawing.Point(151, 18);
  827. this.panel5.Name = "panel5";
  828. this.panel5.Size = new System.Drawing.Size(36, 21);
  829. this.panel5.TabIndex = 24;
  830. this.panel5.Click += new System.EventHandler(this.panel2_Click);
  831. //
  832. // panel2_0
  833. //
  834. this.panel2_0.BackColor = System.Drawing.Color.Yellow;
  835. this.panel2_0.Location = new System.Drawing.Point(58, 18);
  836. this.panel2_0.Name = "panel2_0";
  837. this.panel2_0.Size = new System.Drawing.Size(36, 21);
  838. this.panel2_0.TabIndex = 22;
  839. this.panel2_0.Click += new System.EventHandler(this.panel2_Click);
  840. //
  841. // label1
  842. //
  843. this.label1.AutoSize = true;
  844. this.label1.Location = new System.Drawing.Point(199, 24);
  845. this.label1.Name = "label1";
  846. this.label1.Size = new System.Drawing.Size(0, 12);
  847. this.label1.TabIndex = 3;
  848. //
  849. // label2
  850. //
  851. this.label2.AutoSize = true;
  852. this.label2.Location = new System.Drawing.Point(104, 24);
  853. this.label2.Name = "label2";
  854. this.label2.Size = new System.Drawing.Size(0, 12);
  855. this.label2.TabIndex = 2;
  856. //
  857. // label7
  858. //
  859. this.label7.AutoSize = true;
  860. this.label7.Location = new System.Drawing.Point(15, 24);
  861. this.label7.Name = "label7";
  862. this.label7.Size = new System.Drawing.Size(0, 12);
  863. this.label7.TabIndex = 0;
  864. //
  865. // groupBox6
  866. //
  867. this.groupBox6.Controls.Add(this.textBox4);
  868. this.groupBox6.Controls.Add(this.label15);
  869. this.groupBox6.Controls.Add(this.checkBox1);
  870. this.groupBox6.Controls.Add(this.panel3);
  871. this.groupBox6.Controls.Add(this.trackBar4);
  872. this.groupBox6.Controls.Add(this.textBox10);
  873. this.groupBox6.Controls.Add(this.label4);
  874. this.groupBox6.Controls.Add(this.label6);
  875. this.groupBox6.Location = new System.Drawing.Point(180, 475);
  876. this.groupBox6.Name = "groupBox6";
  877. this.groupBox6.Size = new System.Drawing.Size(355, 45);
  878. this.groupBox6.TabIndex = 48;
  879. this.groupBox6.TabStop = false;
  880. //
  881. // textBox4
  882. //
  883. this.textBox4.Location = new System.Drawing.Point(239, 19);
  884. this.textBox4.Name = "textBox4";
  885. this.textBox4.Size = new System.Drawing.Size(41, 21);
  886. this.textBox4.TabIndex = 24;
  887. this.textBox4.Text = "25";
  888. //
  889. // label15
  890. //
  891. this.label15.AutoSize = true;
  892. this.label15.Location = new System.Drawing.Point(209, 24);
  893. this.label15.Name = "label15";
  894. this.label15.Size = new System.Drawing.Size(0, 12);
  895. this.label15.TabIndex = 23;
  896. //
  897. // checkBox1
  898. //
  899. this.checkBox1.AutoSize = true;
  900. this.checkBox1.Location = new System.Drawing.Point(294, 21);
  901. this.checkBox1.Name = "checkBox1";
  902. this.checkBox1.Size = new System.Drawing.Size(15, 14);
  903. this.checkBox1.TabIndex = 0;
  904. this.checkBox1.UseVisualStyleBackColor = true;
  905. this.checkBox1.CheckedChanged += new System.EventHandler(this.checkBox1_CheckedChanged);
  906. //
  907. // panel3
  908. //
  909. this.panel3.BackColor = System.Drawing.Color.YellowGreen;
  910. this.panel3.Location = new System.Drawing.Point(54, 18);
  911. this.panel3.Name = "panel3";
  912. this.panel3.Size = new System.Drawing.Size(36, 21);
  913. this.panel3.TabIndex = 22;
  914. this.panel3.Click += new System.EventHandler(this.panel2_Click);
  915. //
  916. // trackBar4
  917. //
  918. this.trackBar4.AutoSize = false;
  919. this.trackBar4.Cursor = System.Windows.Forms.Cursors.Hand;
  920. this.trackBar4.Location = new System.Drawing.Point(122, 20);
  921. this.trackBar4.Maximum = 50;
  922. this.trackBar4.Minimum = 1;
  923. this.trackBar4.Name = "trackBar4";
  924. this.trackBar4.Size = new System.Drawing.Size(49, 21);
  925. this.trackBar4.TabIndex = 7;
  926. this.trackBar4.TickStyle = System.Windows.Forms.TickStyle.None;
  927. this.trackBar4.Value = 3;
  928. this.trackBar4.Scroll += new System.EventHandler(this.trackBar4_Scroll);
  929. this.trackBar4.ValueChanged += new System.EventHandler(this.trackBar4_ValueChanged);
  930. //
  931. // textBox10
  932. //
  933. this.textBox10.Location = new System.Drawing.Point(172, 19);
  934. this.textBox10.Name = "textBox10";
  935. this.textBox10.Size = new System.Drawing.Size(30, 21);
  936. this.textBox10.TabIndex = 6;
  937. this.textBox10.Text = "3";
  938. this.textBox10.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.textBoxWidth_KeyPress);
  939. this.textBox10.KeyUp += new System.Windows.Forms.KeyEventHandler(this.textBox10_KeyUp);
  940. //
  941. // label4
  942. //
  943. this.label4.AutoSize = true;
  944. this.label4.Location = new System.Drawing.Point(96, 24);
  945. this.label4.Name = "label4";
  946. this.label4.Size = new System.Drawing.Size(0, 12);
  947. this.label4.TabIndex = 2;
  948. //
  949. // label6
  950. //
  951. this.label6.AutoSize = true;
  952. this.label6.Location = new System.Drawing.Point(15, 24);
  953. this.label6.Name = "label6";
  954. this.label6.Size = new System.Drawing.Size(0, 12);
  955. this.label6.TabIndex = 0;
  956. //
  957. // TABM4Dialog
  958. //
  959. this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
  960. this.ClientSize = new System.Drawing.Size(1127, 822);
  961. this.Controls.Add(this.groupBox6);
  962. this.Controls.Add(this.groupBox11);
  963. this.Controls.Add(this.groupBox8);
  964. this.Controls.Add(this.groupBox7);
  965. this.Controls.Add(this.groupBox5);
  966. this.Name = "TABM4Dialog";
  967. this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.TABM4Dialog_FormClosing);
  968. this.Controls.SetChildIndex(this.groupBox5, 0);
  969. this.Controls.SetChildIndex(this.groupBox_img, 0);
  970. this.Controls.SetChildIndex(this.groupBox_review, 0);
  971. this.Controls.SetChildIndex(this.groupBox_analysisResult1, 0);
  972. this.Controls.SetChildIndex(this.groupBox6groupBox_analysisResult2, 0);
  973. this.Controls.SetChildIndex(this.groupBox_report, 0);
  974. this.Controls.SetChildIndex(this.groupBox7, 0);
  975. this.Controls.SetChildIndex(this.groupBox8, 0);
  976. this.Controls.SetChildIndex(this.groupBox11, 0);
  977. this.Controls.SetChildIndex(this.groupBox6, 0);
  978. this.groupBox_img.ResumeLayout(false);
  979. this.groupBox_report.ResumeLayout(false);
  980. this.groupBox_report.PerformLayout();
  981. this.groupBox_analysisResult1.ResumeLayout(false);
  982. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1_0)).EndInit();
  983. this.groupBox5.ResumeLayout(false);
  984. this.groupBox7.ResumeLayout(false);
  985. this.groupBox7.PerformLayout();
  986. this.groupBox8.ResumeLayout(false);
  987. ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit();
  988. this.groupBox11.ResumeLayout(false);
  989. this.groupBox11.PerformLayout();
  990. this.groupBox6.ResumeLayout(false);
  991. this.groupBox6.PerformLayout();
  992. ((System.ComponentModel.ISupportInitialize)(this.trackBar4)).EndInit();
  993. this.ResumeLayout(false);
  994. }
  995. /// <summary>
  996. /// 线宽输入框 对输入值做限制
  997. /// </summary>
  998. /// <param name="sender"></param>
  999. private void varifyTextBoxValue(object sender)
  1000. {
  1001. if (string.IsNullOrEmpty(((TextBox)sender)/*this.textBox2*/.Text))
  1002. ((TextBox)sender)/*this.textBox2*/.Text = "1";
  1003. if (Convert.ToInt32(((TextBox)sender)/*this.textBox2*/.Text) > 50)
  1004. ((TextBox)sender)/*this.textBox2*/.Text = "50";
  1005. }
  1006. /// <summary>
  1007. /// 限制只可以输入0-9数字以及退格键
  1008. /// </summary>
  1009. /// <param name="sender"></param>
  1010. /// <param name="e"></param>
  1011. private void textBoxWidth_KeyPress(object sender, KeyPressEventArgs e)
  1012. {
  1013. if (e.KeyChar != '\b')//这是允许输入退格键 
  1014.             {
  1015. int len = ((TextBox)sender)/*this.textBox1*/.Text.Length;
  1016. if (len < 1 && e.KeyChar == '0')
  1017. {
  1018. e.Handled = true;
  1019. }
  1020. else if ((e.KeyChar < '0') || (e.KeyChar > '9'))//这是允许输入0-9数字 
  1021.                 {
  1022. e.Handled = true;
  1023. }
  1024. }
  1025. }
  1026. private void textBox10_KeyUp(object sender, KeyEventArgs e)
  1027. {
  1028. this.varifyTextBoxValue(sender);
  1029. this.trackBar4.Value = Convert.ToInt32(this.textBox10.Text);
  1030. }
  1031. #endregion 初始化组件和实现组件事件
  1032. #region 需继承的一部分方法
  1033. protected override void drawSubclass(Graphics graphics)
  1034. {
  1035. //绘制孔隙体积百分比 (循环绘制轮廓)
  1036. if (checkBox2.Checked && tempHole1Bitmap != null)
  1037. graphics.DrawImage(tempHole1Bitmap, new PointF(leftX11, topX11));
  1038. if (checkBox2.Checked && tempHole2Bitmap != null)
  1039. graphics.DrawImage(tempHole2Bitmap, new PointF(leftX22, topX22));
  1040. if (checkBox2.Checked && tempHole3Bitmap != null)
  1041. graphics.DrawImage(tempHole3Bitmap, new PointF(leftX33, topX33));
  1042. if (checkBox1.Checked && lines != null && lines.Count() > 0)
  1043. {
  1044. Pen bluePen = new Pen(this.assistLineColor, this.assistLineWidth);
  1045. foreach (Line l in lines)
  1046. graphics.DrawLine(bluePen, l.startPoint, l.endPoint);
  1047. //画笔
  1048. Pen yellowPen11 = new Pen(this.panel3.BackColor/*Color.Yellow*/, this.trackBar4.Value/*5*/);
  1049. if (lineDraws != null && lineDraws.Count() > 0)
  1050. foreach (Line l in lineDraws)
  1051. graphics.DrawLine(yellowPen11, l.startPoint, l.endPoint);
  1052. }
  1053. if (tempLine != null && tempLine.Length > 0/* && !bcOriginChecked()*/)//#19575
  1054. {
  1055. Pen lineColor = new Pen(this.rectLineColor, this.rectLineWidth);
  1056. for (int index = 0; index < tempLine.Length; index++)
  1057. {
  1058. System.Drawing.Point[] tempLine1 = tempLine[index];
  1059. graphics.DrawLines(lineColor, tempLine1);
  1060. }
  1061. }
  1062. //if (tempHoleMat != null && tempHoleBitmap != null)
  1063. //{
  1064. // graphics.DrawImage(tempHoleBitmap, new PointF(0, 0));
  1065. //}
  1066. //Pen bluePen = new Pen(this.panel4__BackColor/*Color.FromArgb(255, 0, 208, 202)*/, this.trackBar3__Value);
  1067. ////画左右下辅助线
  1068. //if (lineleft != null)
  1069. // graphics.DrawLine(bluePen, lineleft.startPoint, lineleft.endPoint);
  1070. //if (lineright != null)
  1071. // graphics.DrawLine(bluePen, lineright.startPoint, lineright.endPoint);
  1072. ////if (linebottom != null)
  1073. //// graphics.DrawLine(bluePen, linebottom.startPoint, linebottom.endPoint);
  1074. if (lineleft != null)//line
  1075. {
  1076. graphics.DrawLine(new Pen(this.scopeLineColor, this.scopeLineWidth), lineleft.startPoint, lineleft.endPoint);
  1077. }
  1078. if (lineright != null)//line
  1079. {
  1080. graphics.DrawLine(new Pen(this.scopeLineColor, this.scopeLineWidth), lineright.startPoint, lineright.endPoint);
  1081. }
  1082. if (top != null && bottom != null)
  1083. {
  1084. int planesnum = top.startPoint.Y;// int.Parse(Intent.dict["planesnum"].ToString());
  1085. int planesbottom1 = planesnum + +(int)(200 / physical_length);
  1086. int planesbottom2 = planesnum + +(int)(400 / physical_length);
  1087. int planesbottom3 = bottom.startPoint.Y;// int.Parse(Intent.dict["planesbottom"].ToString());
  1088. if (((bottom.startPoint.Y - planesnum) * physical_length) > 600)
  1089. {
  1090. planesbottom3 = planesnum + +(int)(600 / physical_length);
  1091. }
  1092. graphics.DrawLine(new Pen(rect1LineColor, rect1LineWidth), new System.Drawing.Point(0, planesbottom1), new System.Drawing.Point(this.bitmap.Width, planesbottom1));
  1093. graphics.DrawLine(new Pen(rect2LineColor, rect2LineWidth), new System.Drawing.Point(0, planesbottom2), new System.Drawing.Point(this.bitmap.Width, planesbottom2));
  1094. if (((bottom.startPoint.Y - planesnum) * physical_length) > 600)
  1095. {
  1096. graphics.DrawLine(new Pen(rect3LineColor, rect3LineWidth), new System.Drawing.Point(0, planesbottom3), new System.Drawing.Point(this.bitmap.Width, planesbottom3));
  1097. }
  1098. graphics.DrawLine(new Pen(orgLineColor, orgLineWidth), top.startPoint, top.endPoint);
  1099. graphics.DrawLine(new Pen(baseLineColor, baseLineWidth), bottom.startPoint, bottom.endPoint);
  1100. }
  1101. else if (bottom != null)
  1102. {
  1103. graphics.DrawLine(new Pen(baseLineColor, baseLineWidth), bottom.startPoint, bottom.endPoint);
  1104. }
  1105. //if (hlines != null && hlines.Count() > 0)
  1106. //{
  1107. // foreach (Line l in hlines)
  1108. // {
  1109. // graphics.DrawLine(bluePen, l.startPoint, l.endPoint);
  1110. // }
  1111. //}
  1112. //画笔
  1113. Pen yellowPen = new Pen(this.panel3__BackColor, this.trackBar4__Value);
  1114. //if (honlines != null && honlines.Count() > 0)
  1115. //{
  1116. // foreach (Line l in honlines)
  1117. // {
  1118. // graphics.DrawLine(yellowPen, l.startPoint, l.endPoint);
  1119. // }
  1120. //}
  1121. ////画笔
  1122. //Pen yellowPen = new Pen(this.panel3.BackColor, this.trackBar4.Value);
  1123. if (line == null)
  1124. {
  1125. btnflag = 0;
  1126. //System.Drawing.Point point1 = new System.Drawing.Point(0, lab1Img.Height - 130);
  1127. //System.Drawing.Point point2 = new System.Drawing.Point(lab1Img.Width, lab1Img.Height - 130);
  1128. //line = new Line(point1, point2);
  1129. //graphics.DrawLine(yellowPen, line.startPoint, line.endPoint);
  1130. }
  1131. else
  1132. {
  1133. if (btnflag == 0)
  1134. btnflag = 1;
  1135. graphics.DrawLine(yellowPen, line.startPoint, line.endPoint);
  1136. }
  1137. if (checkBox3.Checked && vlines.Count() > 0)
  1138. {
  1139. Pen bluePen = new Pen(this.assistLineColor, this.assistLineWidth);
  1140. foreach (Line temp in vlines)
  1141. graphics.DrawLine(bluePen, temp.startPoint, temp.endPoint);
  1142. }
  1143. }
  1144. //数据库的name(报告模板)
  1145. protected override string getTemplateName()
  1146. {
  1147. return "Template.Manager.item3.TitaniumAlloyBio4Method";
  1148. }
  1149. //语言包的name(项目工程)
  1150. protected override string getProjectEngineeringName()
  1151. {
  1152. return "Menu.DedicatedAnalysis.NonferrousMetal.TitaniumAlloyBiomaterial.Text";
  1153. }
  1154. protected override void SubclassInitialize()
  1155. {
  1156. InitializeComponent();
  1157. InitializeLanguageText();
  1158. //this.panel1.Click += new System.EventHandler(this.panel1_Click);
  1159. ////this.panel3.Click += new System.EventHandler(this.panel1_Click);
  1160. //this.panel4.Click += new System.EventHandler(this.panel1_Click);
  1161. ////this.groupBox_img.Size = new System.Drawing.Size(158, 544/*514*/);
  1162. ////this.groupBox_review.Size = new System.Drawing.Size(575, 544/*514*/);
  1163. ////this.groupBox_analysisResult1.Location = new System.Drawing.Point(12, 622/*592*/);
  1164. ////this.groupBox6groupBox_analysisResult2.Location = new System.Drawing.Point(242, 622/*592*/);
  1165. ////this.groupBox_report.Location = new System.Drawing.Point(974, 622/*592*/);
  1166. this.ClientSize = new System.Drawing.Size(1127, 892);///*822*/
  1167. IndexChangedFromIndex.Add(2);
  1168. IndexChangedFromIndex.Add(3);
  1169. IndexChangedFromIndex.Add(4);
  1170. IndexChangedFromIndex.Add(5);
  1171. IndexChangedFromIndex.Add(6);
  1172. IndexChangedFromIndex.Add(7);
  1173. IndexChangedToIndex.Add(0, new int[] { 2, 0 });//平均
  1174. IndexChangedToIndex.Add(1, new int[] { 2, 1 });//平均
  1175. IndexChangedToIndex.Add(2, new int[] { 2, 2 });//平均
  1176. IndexChangedToIndex.Add(3, new int[] { 2, 3 });//平均
  1177. IndexChangedToIndex.Add(4, new int[] { 2, 4 });//平均
  1178. IndexChangedToIndex.Add(5, new int[] { 2, 5 });//平均
  1179. //IndexChangedToIndex.Add(1, new int[] { 2/*1*/, 1 });//平均<-求和
  1180. }
  1181. //切换图片时控制前一张图的信息不遗留显示
  1182. protected override void refreshWhileImgChanged()
  1183. {
  1184. this.physical_length = getCurrentWorkspace().GetRuler(MeasurementUnit.Micron);
  1185. calculate1d = false;
  1186. //this.label2.Text = "";
  1187. //this.label7.Text = "";
  1188. //this.label14.Text = "";
  1189. if (top != null)
  1190. top = null;
  1191. if (bottom != null)
  1192. bottom = null;
  1193. if (tempHole1Bitmap != null)
  1194. {
  1195. tempHole1Bitmap.Dispose();
  1196. tempHole1Bitmap = null;
  1197. }
  1198. if (tempHole2Bitmap != null)
  1199. {
  1200. tempHole2Bitmap.Dispose();
  1201. tempHole2Bitmap = null;
  1202. }
  1203. if (tempHole3Bitmap != null)
  1204. {
  1205. tempHole3Bitmap.Dispose();
  1206. tempHole3Bitmap = null;
  1207. }
  1208. vlines.Clear();
  1209. if (line != null)
  1210. {
  1211. btnflag = 0;
  1212. line = null;
  1213. }
  1214. tempLine = new System.Drawing.Point[][] { };
  1215. //hlines.Clear();
  1216. //honlines.Clear();
  1217. if (lineleft != null || linebottom != null || lineright != null)
  1218. {
  1219. btnflag = 0;
  1220. lineleft = null;
  1221. linebottom = null;
  1222. lineright = null;
  1223. }
  1224. //bool BinaryChecked = false;
  1225. //if (getCurrentWorkTag() != null)
  1226. // BinaryChecked = (binaryClass.getModelBinaryCheckFlag(getCurrentWorkTag()) != false);
  1227. //if (!BinaryChecked && (this.documentWorkspace.PhaseModels.Count() == 0 || this.documentWorkspace.PhaseModels[0].mat == null || !this.documentWorkspace.PhaseModels[0].choise))
  1228. //{//#22416
  1229. // binaryClass.performClickBinaryCheck(false);
  1230. //}
  1231. this.grayBitmap = false;
  1232. }
  1233. #endregion
  1234. #region 基础操作
  1235. /// <summary>
  1236. /// 灰度化
  1237. /// </summary>
  1238. /// <param name="sender"></param>
  1239. /// <param name="e"></param>
  1240. private void button5_Click(object sender, EventArgs e)
  1241. {
  1242. if (this.bitmap == null)
  1243. {
  1244. MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectapicture.text"));
  1245. return;
  1246. }
  1247. if (this.grayBitmap) {
  1248. MessageBox.Show(PdnResources.GetString("Menu.It'salreadygreyscale.text"));
  1249. return;
  1250. }
  1251. this.grayBitmap = true;
  1252. Mat lab1Img = OpenCvSharp.Extensions.BitmapConverter.ToMat(this.bitmap);
  1253. if (lab1Img.Type() != MatType.CV_8UC1)
  1254. {
  1255. lab1Img = lab1Img.CvtColor(ColorConversionCodes.BGR2GRAY);
  1256. Bitmap bitmap2 = OpenCvSharp.Extensions.BitmapConverter.ToBitmap(lab1Img);
  1257. Document document = Document.FromImage(bitmap2);
  1258. this.documentWorkspace.Document = document;
  1259. }
  1260. else
  1261. MessageBox.Show(PdnResources.GetString("Menu.It'salreadygreyscale.text"));
  1262. lab1Img.Dispose();
  1263. lab1Img = null;
  1264. }
  1265. /// <summary>
  1266. /// 腐蚀
  1267. /// </summary>
  1268. /// <param name="sender"></param>
  1269. /// <param name="e"></param>
  1270. private void button4_Click(object sender, EventArgs e)
  1271. {
  1272. if (this.documentWorkspace.PhaseModels.Count < 1 || !this.documentWorkspace.PhaseModels[0].choise
  1273. || this.documentWorkspace.PhaseModels[0].mat == null)
  1274. {
  1275. MessageBox.Show(PdnResources.GetString("Menu.Pleasebinarizefirst.text"));
  1276. return;
  1277. }
  1278. Mat lab1Img = this.documentWorkspace.PhaseModels[0].mat;
  1279. Cv2.Erode(lab1Img, lab1Img, new Mat(), null, 1, BorderTypes.Default);
  1280. this.documentWorkspace.PhaseModels[0].mat = lab1Img;
  1281. this.documentWorkspace.Refresh();
  1282. }
  1283. /// <summary>
  1284. /// 膨胀
  1285. /// </summary>
  1286. /// <param name="sender"></param>
  1287. /// <param name="e"></param>
  1288. private void button10_Click(object sender, EventArgs e)
  1289. {
  1290. if (this.documentWorkspace.PhaseModels.Count < 1 || !this.documentWorkspace.PhaseModels[0].choise
  1291. || this.documentWorkspace.PhaseModels[0].mat == null)
  1292. {
  1293. MessageBox.Show(PdnResources.GetString("Menu.Pleasebinarizefirst.text"));
  1294. return;
  1295. }
  1296. Mat lab1Img = this.documentWorkspace.PhaseModels[0].mat;
  1297. Cv2.Dilate(lab1Img, lab1Img, new Mat(), null, 1, BorderTypes.Default);
  1298. this.documentWorkspace.PhaseModels[0].mat = lab1Img;
  1299. this.documentWorkspace.Refresh();
  1300. }
  1301. /// <summary>
  1302. /// 刷新界面显示的方法
  1303. /// </summary>
  1304. public void refreshWorkSpace()
  1305. {
  1306. //更新左右辅助线位置 (画左右辅助线)
  1307. //if (lineleft == null || lineright == null)
  1308. {
  1309. int margin = Math.Min(this.bitmap.Width / 2 - 5, (int)(this.scopeMarginLeft / this.physical_length));// this.bitmap.Width / 20;
  1310. lineleft = new Line(new System.Drawing.Point(margin, 0), new System.Drawing.Point(margin, this.bitmap.Height));
  1311. lineright = new Line(new System.Drawing.Point(this.bitmap.Width - margin, 0), new System.Drawing.Point(this.bitmap.Width - margin, this.bitmap.Height));
  1312. }
  1313. this.documentWorkspace.Refresh();
  1314. }
  1315. private void checkBox3_CheckedChanged(object sender, EventArgs e)
  1316. {
  1317. this.documentWorkspace.Refresh();
  1318. }
  1319. private void checkBox2_CheckedChanged(object sender, EventArgs e)
  1320. {
  1321. this.documentWorkspace.Refresh();
  1322. }
  1323. private void checkBox1_CheckedChanged(object sender, EventArgs e)
  1324. {
  1325. this.documentWorkspace.Refresh();
  1326. }
  1327. /// <summary>
  1328. /// 寻找轮廓
  1329. /// </summary>
  1330. /// <param name="sender"></param>
  1331. /// <param name="e"></param>
  1332. private void button15_Click(object sender, EventArgs e)
  1333. {
  1334. if (this.documentWorkspace.PhaseModels.Count < 1 || !this.documentWorkspace.PhaseModels[0].choise/* //###21425 */
  1335. || this.documentWorkspace.PhaseModels[0].mat == null)
  1336. {
  1337. MessageBox.Show(PdnResources.GetString("Menu.Pleasebinarizefirst.text"));
  1338. return;
  1339. }
  1340. Mat analyzeMat = this.documentWorkspace.PhaseModels[0].mat;
  1341. bool findTempLineSuccess;
  1342. int Rows = analyzeMat.Rows;
  1343. int Cols = analyzeMat.Cols;
  1344. int[] point = new int[2];
  1345. List<System.Drawing.Point> tempPointList = new List<System.Drawing.Point>();
  1346. //多通道图像的格式化
  1347. for (point[1] = 0; point[1] < Cols; point[1]++)
  1348. {
  1349. findTempLineSuccess = false;
  1350. for (point[0] = 1; point[0] < Rows; point[0]++)
  1351. {
  1352. if (analyzeMat.At<Vec4b>(point[0], point[1]).Item3 > 0)
  1353. {
  1354. tempPointList.Add(new System.Drawing.Point(point[1], point[0]));
  1355. findTempLineSuccess = true;//找到了最上边的交点
  1356. break;
  1357. }
  1358. }
  1359. if (!findTempLineSuccess)//如果没有找到最上边的交点,设置交点为图像的最高点
  1360. {
  1361. point[0] = 0;
  1362. tempPointList.Add(new System.Drawing.Point(point[1], point[0]));
  1363. }
  1364. }
  1365. tempLine = new System.Drawing.Point[][] { tempPointList.ToArray() };
  1366. this.documentWorkspace.Refresh();
  1367. //if (this.documentWorkspace.PhaseModels.Count < 1/* || !this.documentWorkspace.PhaseModels[0].choise*/
  1368. // || this.documentWorkspace.PhaseModels[0].mat == null)
  1369. //{
  1370. // MessageBox.Show(PdnResources.GetString("Menu.Pleasebinarizefirst.text"));
  1371. // return;
  1372. //}
  1373. //Mat analyzeMat = this.documentWorkspace.PhaseModels[0].mat;
  1374. //Color tempHoleColor = this.panel1__BackColor;
  1375. //Vec4b vec4B1 = new Vec4b(tempHoleColor.B, tempHoleColor.G, tempHoleColor.R, 255);
  1376. //Vec4b vec4B2 = new Vec4b(0, 0, 0, 0);
  1377. //if (tempHoleMat != null)
  1378. //{
  1379. // tempHoleMat.Dispose();
  1380. // tempHoleMat = null;
  1381. //}
  1382. //tempHoleMat = new Mat(analyzeMat.Size(), MatType.CV_8UC4);
  1383. //int Rows = analyzeMat.Rows;
  1384. //int Cols = analyzeMat.Cols;
  1385. //int[] point = new int[2];
  1386. ////多通道图像的格式化
  1387. //for (point[1] = 0; point[1] < Cols; point[1]++)
  1388. //{
  1389. // for (point[0] = 0; point[0] < Rows; point[0]++)
  1390. // {
  1391. // if (analyzeMat.At<Vec4b>(point[0], point[1]).Item3 > 0)
  1392. // tempHoleMat.Set(point, vec4B2);
  1393. // else
  1394. // tempHoleMat.Set(point, vec4B1);
  1395. // }
  1396. //}
  1397. //tempHoleBitmap = OpenCvSharp.Extensions.BitmapConverter.ToBitmap(tempHoleMat);
  1398. //this.documentWorkspace.Refresh();
  1399. }
  1400. /// <summary>
  1401. /// 自动调整
  1402. /// </summary>
  1403. /// <param name="sender"></param>
  1404. /// <param name="e"></param>
  1405. private void button17_Click(object sender, EventArgs e)
  1406. {
  1407. if (this.documentWorkspace.PhaseModels.Count < 1/* || !this.documentWorkspace.PhaseModels[0].choise*/
  1408. || this.documentWorkspace.PhaseModels[0].mat == null)
  1409. {
  1410. binaryClass.performClickBinaryCheck(true);
  1411. }
  1412. this.button15.PerformClick();
  1413. }
  1414. /// <summary>
  1415. /// 更多
  1416. /// </summary>
  1417. /// <param name="sender"></param>
  1418. /// <param name="e"></param>
  1419. private void button6_Click(object sender, EventArgs e)
  1420. {
  1421. //if (this.bitmap == null)//0914###18535
  1422. //{
  1423. // //MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectapicturefirst.text"));
  1424. // //return;
  1425. //}
  1426. TABMethod4DialogSetting setting = new TABMethod4DialogSetting(this, this.appWorkspace, this.bitmap == null ? -1 : (this.lstView_img.FocusedItem != null ? this.lstView_img.FocusedItem.Index : this.lstView_img.SelectedItems[0].Index));
  1427. //setting.TopMost = true;
  1428. setting.ShowDialog();
  1429. }
  1430. /// <summary>
  1431. /// 定义组织界面
  1432. /// </summary>
  1433. /// <param name="sender"></param>
  1434. /// <param name="e"></param>
  1435. private void button13_Click(object sender, EventArgs e)
  1436. {
  1437. if (this.bitmap == null)//0914###18535
  1438. {
  1439. MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectapicturefirst.text"));
  1440. return;
  1441. }
  1442. if (lineleft == null || lineright == null)
  1443. {
  1444. this.Button16_Click(sender, e);
  1445. //MessageBox.Show("请先点击选择视场");
  1446. //return;
  1447. }
  1448. if (tempLine == null)
  1449. {
  1450. MessageBox.Show(PdnResources.GetString("Menu.Pleaseclicktodrawtheoutlinefirst.text"));
  1451. return;
  1452. }
  1453. //Form4 form = new Form4(lineright.startPoint.X - lineleft.startPoint.X, physical_length);
  1454. //form.StartPosition = FormStartPosition.CenterParent;
  1455. //if (form.ShowDialog() != DialogResult.OK)
  1456. //{
  1457. // return;
  1458. //}
  1459. //Intent.dict["per_text"] = textBox1.Text;
  1460. //Intent.dict["num_text"] = textBox2.Text;
  1461. if (this.bitmap/*lab1Img*/ != null/* && drawg != null*/)// && line == null
  1462. {
  1463. refreshPerWidth();
  1464. if (string.IsNullOrWhiteSpace(this.textBox4__Text/*Intent.dict["per_text"]*/.ToString()) || /*Intent.dict["per_text"]*/this.textBox4__Text.ToString() == "")
  1465. {
  1466. MessageBox.Show(PdnResources.GetString("Menu.Pleaseentertheauxiliarylinespacingfirst.text"));
  1467. return;
  1468. }
  1469. int per_w;
  1470. try
  1471. {
  1472. per_w = (int)(float.Parse(/*Intent.dict["per_text"]*/this.textBox4__Text.ToString()) / physical_length);
  1473. }
  1474. catch (Exception b)
  1475. {
  1476. MessageBox.Show(b.Message);
  1477. return;
  1478. }
  1479. per_w = Math.Max(1, per_w);//避免报错“尝试除以零”
  1480. if (bottom == null)//line
  1481. {
  1482. System.Drawing.Point point1 = new System.Drawing.Point(0, this.bitmap.Height - 30/*130*/);
  1483. System.Drawing.Point point2 = new System.Drawing.Point(this.bitmap.Width, this.bitmap.Height - 30/*130*/);
  1484. bottom = new Line(point1, point2);
  1485. //drawg.DrawLine(yellowPen, bottom.startPoint, bottom.endPoint);
  1486. }
  1487. else
  1488. {
  1489. //this.documentWorkspace.Refresh();
  1490. ////drawg.Clear(Color.FromArgb(0, 11, 11, 11));
  1491. ////drawg.DrawLine(yellowPen, bottom.startPoint, bottom.endPoint);
  1492. }
  1493. //画均匀垂直于基体平行线的线
  1494. int y = bottom.endPoint.Y;
  1495. lineNum = bottom.endPoint.Y;
  1496. //trackBar1.Value = lineNum;
  1497. int w = ((lineright.startPoint.X - lineleft.startPoint.X)/*lab1Img.Width*/ / per_w) - 1;
  1498. w = Math.Max(1, w);
  1499. vlines.Clear();
  1500. for (int i = 0; i < w; i++)
  1501. {
  1502. int temp_y = -1;
  1503. //找轮廓内所有跟线的x相交的点,取y最大(//###################最小)的值进行计算
  1504. for (int n = 0; n < tempLine.Length; n++)
  1505. {
  1506. System.Drawing.Point[] pointsL = tempLine[n];
  1507. for (int m = 0; m < pointsL.Length; m++)
  1508. {
  1509. if (pointsL[m].X - lineleft.startPoint.X == per_w * (i + 1))
  1510. {
  1511. if (temp_y == -1)
  1512. {
  1513. temp_y = pointsL[m].Y;
  1514. }
  1515. else
  1516. {
  1517. if (pointsL[m].Y < temp_y)
  1518. {
  1519. temp_y = pointsL[m].Y;
  1520. }
  1521. }
  1522. }
  1523. }
  1524. }
  1525. System.Drawing.Point tpoint1 = new System.Drawing.Point(per_w * (i + 1) + lineleft.startPoint.X, temp_y);
  1526. System.Drawing.Point tpoint2 = new System.Drawing.Point(per_w * (i + 1) + lineleft.startPoint.X, y);
  1527. Line temp = new Line(tpoint1, tpoint2);
  1528. vlines.Add(temp);
  1529. }
  1530. int w11 = vlines.Count();
  1531. w11 = Math.Max(1, w11);
  1532. textBox6__Text = w11.ToString();//0916###18556//##################################
  1533. //////calculated = false;
  1534. ////pictureBox1.Image = map;
  1535. //this.documentWorkspace.Refresh();
  1536. }
  1537. else
  1538. {
  1539. MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectapicture.text"));
  1540. return;//
  1541. }
  1542. //获取组织界面
  1543. //-->
  1544. //厚度的数组
  1545. List<int> thickness2 = new List<int>();
  1546. //int[] thickness1 = new int[vlines.Count()];
  1547. //循环每条线,找到和轮廓的交点
  1548. for (int i = 0; i < vlines.Count(); i++)
  1549. {
  1550. ////画点//#############
  1551. //drawg.DrawEllipse(new Pen(Color.Red, 5), vlines[i].startPoint.X - 1, vlines[i].startPoint.Y - 1, 9, 9);
  1552. //drawg.DrawEllipse(new Pen(Color.Red, 5), vlines[i].startPoint.X - 1, lineNum - 1, 9, 9);
  1553. //计算厚度,像素
  1554. thickness2.Add(lineNum - vlines[i].startPoint.Y);
  1555. //thickness1[i] = lineNum - vlines[i].startPoint.Y;
  1556. }
  1557. //计算
  1558. //thickness2.Reverse();//.Sort();//
  1559. thickness2.Sort((x, y) => -x.CompareTo(y));
  1560. //Console.WriteLine(thickness2);
  1561. int lengthForm = Math.Max(1, (int)(thickness2.Count / 20.0));
  1562. int sumForm = 0;
  1563. for (int i = 0; i < lengthForm; i++)
  1564. {
  1565. sumForm += thickness2[i];
  1566. }
  1567. //####################################
  1568. //drawg.DrawLine(new Pen(Color.Yellow, zoom), new System.Drawing.Point(0, lineNum - sumForm / lengthForm), new System.Drawing.Point(lab1Img.Width, lineNum - sumForm / lengthForm));
  1569. planesnumcal = lineNum - sumForm / lengthForm;
  1570. //pictureBox1.Image = map;
  1571. this.Button14_Click(sender, e);
  1572. //////画左右辅助线
  1573. ////if (lineleft == null || lineright == null)
  1574. ////{
  1575. //Pen blueLinePen = new Pen(Color.Blue, zoom);
  1576. //// int margin = lab1Img.Width / 20;
  1577. //// lineleft = new Line(new System.Drawing.Point(margin, 0), new System.Drawing.Point(margin, lab1Img.Height));
  1578. //// lineright = new Line(new System.Drawing.Point(lab1Img.Width - margin, 0), new System.Drawing.Point(lab1Img.Width - margin, lab1Img.Height));
  1579. //// drawg.DrawLine(blueLinePen, lineleft.startPoint, lineleft.endPoint);
  1580. //// drawg.DrawLine(blueLinePen, lineright.startPoint, lineright.endPoint);
  1581. //// pictureBox1.Image = map;
  1582. //// pictureBox1.Refresh();
  1583. ////}
  1584. //drawg.DrawLine(blueLinePen, lineleft.startPoint, lineleft.endPoint);
  1585. //drawg.DrawLine(blueLinePen, lineright.startPoint, lineright.endPoint);
  1586. //pictureBox1.Image = map;
  1587. //pictureBox1.Refresh();
  1588. this.documentWorkspace.Refresh();
  1589. btnflag = 1;
  1590. //if (tempHoleMat == null)
  1591. //{
  1592. // MessageBox.Show("请先进行寻找孔隙操作");
  1593. // return;
  1594. //}
  1595. ////if (contours == null)
  1596. ////{
  1597. //// MessageBox.Show(PdnResources.GetString("Menu.Pleaseclicktodrawtheoutlinefirst.text"));
  1598. //// return;
  1599. ////}
  1600. //////this.showPhaseMat();
  1601. //Mat lab1Img = this.documentWorkspace.PhaseModels[0].mat;
  1602. //if (lab1Img != null/* && drawg != null*/)// && line == null
  1603. //{
  1604. // //if (string.IsNullOrWhiteSpace(this.textBox4.Text) || textBox4.Text == "")
  1605. // //{
  1606. // // MessageBox.Show(PdnResources.GetString("Menu.Pleaseentertheauxiliarylinespacingfirst.text"));
  1607. // // return;
  1608. // //}
  1609. // string width = this.textBox4__Text.Trim();
  1610. // double result;
  1611. // if (!double.TryParse(width, out result))
  1612. // {
  1613. // MessageBox.Show(PdnResources.GetString("Menu.ormatforauxiliarylinespacin.Text"));
  1614. // return;
  1615. // }
  1616. // string width2 = this.textBox6__Text.Trim();
  1617. // int result2;
  1618. // if (!int.TryParse(width2, out result2))
  1619. // {
  1620. // MessageBox.Show(PdnResources.GetString("Menu.Theinputforncorrect.text"));
  1621. // return;
  1622. // }
  1623. // this.drawLines();
  1624. // this.documentWorkspace.Refresh();
  1625. //}
  1626. //else
  1627. //{
  1628. // MessageBox.Show(PdnResources.GetString("Menu.Pleasebinarizefirst.text"));
  1629. //}
  1630. }
  1631. /// <summary>
  1632. /// 选择视场
  1633. /// </summary>
  1634. /// <param name="sender"></param>
  1635. /// <param name="e"></param>
  1636. private void Button16_Click(object sender, EventArgs e)
  1637. {
  1638. this.button2_Clicked = true;
  1639. //画左右辅助线
  1640. if (lineleft == null || lineright == null)
  1641. {
  1642. int margin = Math.Min(this.bitmap.Width / 2 - 5, (int)(this.scopeMarginLeft / this.physical_length));// this.bitmap.Width / 20;
  1643. lineleft = new Line(new System.Drawing.Point(margin, 0), new System.Drawing.Point(margin, this.bitmap.Height));
  1644. lineright = new Line(new System.Drawing.Point(this.bitmap.Width - margin, 0), new System.Drawing.Point(this.bitmap.Width - margin, this.bitmap.Height));
  1645. }
  1646. if (bottom == null)//line
  1647. {
  1648. System.Drawing.Point point1 = new System.Drawing.Point(0, this.bitmap.Height - 30/*130*/);
  1649. System.Drawing.Point point2 = new System.Drawing.Point(this.bitmap.Width, this.bitmap.Height - 30/*130*/);
  1650. bottom = new Line(point1, point2);
  1651. //drawg.DrawLine(new Pen(Color.Yellow, zoom)/*yellowPen*/, bottom.startPoint, bottom.endPoint);
  1652. }
  1653. this.documentWorkspace.Refresh();
  1654. btnflag = 1;
  1655. }
  1656. /// <summary>
  1657. /// 划分分析区域
  1658. /// </summary>
  1659. /// <param name="sender"></param>
  1660. /// <param name="e"></param>
  1661. private void Button14_Click(object sender, EventArgs e)
  1662. {
  1663. if (planesnumcal == int.MaxValue)
  1664. {
  1665. MessageBox.Show(PdnResources.GetString("Menu.Pleasedefinetnterfacefirst.text"));
  1666. //this.drawLines();
  1667. //MessageBox.Show(PdnResources.GetString("Menu.Thedistancebeselectagain.text"));
  1668. return;
  1669. }
  1670. if (planesnumcal < 0)
  1671. {
  1672. MessageBox.Show(PdnResources.GetString("Menu.lineandtr.Text"));
  1673. //this.drawLines();
  1674. //MessageBox.Show(PdnResources.GetString("Menu.Thedistancebeselectagain.text"));
  1675. return;
  1676. }
  1677. try
  1678. {
  1679. int planesnum = planesnumcal;// int.Parse(Intent.dict["planesnum"].ToString());
  1680. int planesbottom = bottom.endPoint.Y;// int.Parse(Intent.dict["planesbottom"].ToString());
  1681. if (((planesbottom - planesnum) * physical_length) < 500)
  1682. {
  1683. this.drawLines();
  1684. MessageBox.Show(PdnResources.GetString("Menu.Thedistancebeselectagain.text"));
  1685. return;
  1686. }
  1687. top = new Line(new System.Drawing.Point(0, planesnum), new System.Drawing.Point(this.bitmap.Width, planesnum));
  1688. bottom = new Line(new System.Drawing.Point(0, planesbottom), new System.Drawing.Point(this.bitmap.Width, planesbottom));
  1689. }
  1690. catch
  1691. {
  1692. MessageBox.Show(PdnResources.GetString("Menu.Failedtodivideanalysisarea.text"));
  1693. return;
  1694. //top = new Line(new System.Drawing.Point(0, lab1Img.Height - (int)(690 / physical_length)), new System.Drawing.Point(lab1Img.Width, lab1Img.Height - (int)(690 / physical_length)));
  1695. }
  1696. //#########
  1697. //Pen blueLinePen = new Pen(Color.Blue, zoom);
  1698. Line bottom1 = new Line(new System.Drawing.Point(0, top.startPoint.Y + (int)(200 / physical_length)), new System.Drawing.Point(this.bitmap.Width, top.startPoint.Y + (int)(200 / physical_length)));
  1699. //drawg.DrawLine(blueLinePen, bottom1.startPoint, bottom1.endPoint);
  1700. Line bottom2 = new Line(new System.Drawing.Point(0, top.startPoint.Y + (int)(400 / physical_length)), new System.Drawing.Point(this.bitmap.Width, top.startPoint.Y + (int)(400 / physical_length)));
  1701. //drawg.DrawLine(blueLinePen, bottom2.startPoint, bottom2.endPoint);
  1702. if (((bottom.startPoint.Y - top.startPoint.Y) * physical_length) > 600)
  1703. {
  1704. Line bottom3 = new Line(new System.Drawing.Point(0, top.startPoint.Y + (int)(600 / physical_length)), new System.Drawing.Point(this.bitmap.Width, top.startPoint.Y + (int)(600 / physical_length)));
  1705. //drawg.DrawLine(blueLinePen, bottom3.startPoint, bottom3.endPoint);
  1706. }
  1707. //drawg.DrawLine(new Pen(Color.Yellow, zoom), bottom.startPoint, bottom.endPoint);
  1708. //pictureBox1.Image = map;
  1709. //pictureBox1.Refresh();
  1710. }
  1711. /// <summary>
  1712. /// 绘制辅助线
  1713. /// </summary>
  1714. private void drawLines()
  1715. {
  1716. string line = this.textBox6__Text.Trim();
  1717. string width = this.textBox4__Text.Trim();
  1718. try
  1719. {
  1720. //画左右下辅助线
  1721. if (lineleft == null || lineright == null)
  1722. {
  1723. int margin = Math.Min(this.bitmap.Width / 2 - 5, (int)(this.scopeMarginLeft / this.physical_length));// this.bitmap/*lab1Img*/.Width / 20;
  1724. lineleft = new Line(new System.Drawing.Point(margin, 0), new System.Drawing.Point(margin, this.bitmap/*lab1Img*/.Height));
  1725. lineright = new Line(new System.Drawing.Point(this.bitmap/*lab1Img*/.Width - margin, 0), new System.Drawing.Point(this.bitmap/*lab1Img*/.Width - margin, this.bitmap/*lab1Img*/.Height));
  1726. }
  1727. if (linebottom == null)
  1728. {
  1729. linebottom = new Line(new System.Drawing.Point(0, this.bitmap/*lab1Img*/.Height - 30/*130*/), new System.Drawing.Point(this.bitmap/*lab1Img*/.Width, this.bitmap/*lab1Img*/.Height - 30/*130*/));
  1730. }
  1731. //画平行的多条辅助线
  1732. int n = int.Parse(line); //线的数量
  1733. int per_w = (int)(double.Parse(width) / this.physical_length); //线的间距(目前当成像素,将来需要从微米转成像素)
  1734. per_w = Math.Max(1, per_w);//避免报错“尝试除以零”
  1735. //hlines.Clear();
  1736. //{
  1737. // for (int i = 0; i < n; i++)
  1738. // {
  1739. // Line l = new Line(new System.Drawing.Point(0, linebottom.startPoint.Y - per_w * i), new System.Drawing.Point(this.bitmap/*lab1Img*/.Width, linebottom.startPoint.Y - per_w * i));
  1740. // //drawg.DrawLine(new Pen(Color.FromArgb(255, 0, 208, 202), zoom), l.startPoint, l.endPoint);
  1741. // hlines.Add(l);
  1742. // }
  1743. //}
  1744. //honlines.Clear();
  1745. btnflag = 1;
  1746. //pictureBox1.Image = map;
  1747. }
  1748. catch (Exception ex)
  1749. {
  1750. MessageBox.Show(ex.Message);
  1751. }
  1752. }
  1753. private void trackBar4_Scroll(object sender, EventArgs e)
  1754. {
  1755. this.textBox10.Text = "" + this.trackBar4.Value;
  1756. }
  1757. private void trackBar4_ValueChanged(object sender, EventArgs e)
  1758. {
  1759. this.documentWorkspace.Refresh();
  1760. }
  1761. /// <summary>
  1762. /// 重置
  1763. /// </summary>
  1764. /// <param name="sender"></param>
  1765. /// <param name="e"></param>
  1766. private void button3_Click(object sender, EventArgs e)
  1767. {
  1768. if (this.bitmap == null)
  1769. {
  1770. MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectapicturefirst.text"));
  1771. return;
  1772. }
  1773. calculate1d = false;
  1774. if (top != null)
  1775. top = null;
  1776. if (bottom != null)
  1777. bottom = null;
  1778. if (tempHole1Bitmap != null)
  1779. {
  1780. tempHole1Bitmap.Dispose();
  1781. tempHole1Bitmap = null;
  1782. }
  1783. if (tempHole2Bitmap != null)
  1784. {
  1785. tempHole2Bitmap.Dispose();
  1786. tempHole2Bitmap = null;
  1787. }
  1788. if (tempHole3Bitmap != null)
  1789. {
  1790. tempHole3Bitmap.Dispose();
  1791. tempHole3Bitmap = null;
  1792. }
  1793. //this.label2.Text = "";
  1794. //this.label7.Text = "";
  1795. //this.label14.Text = "";
  1796. //hlines.Clear();
  1797. //honlines.Clear();
  1798. if (lineleft == null && linebottom == null && lineright == null)
  1799. { }
  1800. else
  1801. {
  1802. btnflag = 0;
  1803. lineleft = null;
  1804. linebottom = null;
  1805. lineright = null;
  1806. }
  1807. //contours = null;
  1808. //vlines.Clear();
  1809. //if (line == null)
  1810. //{
  1811. //}
  1812. //else
  1813. //{
  1814. // btnflag = 0;
  1815. // line = null;
  1816. //}
  1817. tempLine = new System.Drawing.Point[][] { };
  1818. //if (tempHoleMat != null)
  1819. //{
  1820. // tempHoleMat.Dispose();
  1821. // tempHoleMat = null;
  1822. //}
  1823. if (this.documentWorkspace.PhaseModels.Count() > 0)
  1824. {
  1825. this.documentWorkspace.PhaseModels[0].mat = null;
  1826. }
  1827. this.documentWorkspace.PhaseModels[0].choise = false;
  1828. binaryClass.performClickBinaryCheck(false);
  1829. //this.checkBox10.Checked = false;//PdnResources.GetString("Menu.Binarization.text");//####################
  1830. this.grayBitmap = false;
  1831. Document document = Document.FromImage(this.bitmap);
  1832. this.documentWorkspace.Document = document;
  1833. }
  1834. /// <summary>
  1835. /// 修改轮廓
  1836. /// </summary>
  1837. /// <param name="sender"></param>
  1838. /// <param name="e"></param>
  1839. private void button14_Click(object sender, EventArgs e)
  1840. {
  1841. if (!(tempLine != null && tempLine.Length > 0))
  1842. {
  1843. MessageBox.Show(PdnResources.GetString("Menu.Pleaseclicktodrawtheoutlinefirst.text"));
  1844. //MessageBox.Show("请先进行寻找轮廓操作"/*PdnResources.GetString("Menu.Pleaseperformuctionfirst.text")*/);
  1845. return;
  1846. }
  1847. IntegrationClass.MetalsBoundaryEditingDialog boundaryEditingDialog = new IntegrationClass.MetalsBoundaryEditingDialog(this.appWorkspace, this.lstView_img.FocusedItem != null ? this.lstView_img.FocusedItem.Index : this.lstView_img.SelectedItems[0].Index, this.rectLineColor
  1848. , tempLine.ToList());//#####################################
  1849. if (boundaryEditingDialog.ShowDialog() == DialogResult.OK)
  1850. {
  1851. tempLine = boundaryEditingDialog.AnalyzePoints.ToArray();
  1852. this.documentWorkspace.Refresh();
  1853. }
  1854. //if (this.bitmap == null)
  1855. //{
  1856. // MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectapicture.text"));
  1857. // return;
  1858. //}
  1859. //if (tempHoleMat == null)
  1860. //{
  1861. // MessageBox.Show("请先进行寻找孔隙操作");
  1862. // return;
  1863. //}
  1864. //IntegrationClass.MetalsHoleAreaEditingDialog boundaryEditingDialog = new IntegrationClass.MetalsHoleAreaEditingDialog(this.appWorkspace, this.lstView_img.FocusedItem.Index, this.panel1__BackColor
  1865. // , tempHoleMat);
  1866. //if (boundaryEditingDialog.ShowDialog() == DialogResult.OK)
  1867. //{
  1868. // tempHoleMat = boundaryEditingDialog.PhaseMat.Clone();
  1869. // tempHoleBitmap = OpenCvSharp.Extensions.BitmapConverter.ToBitmap(tempHoleMat);
  1870. // this.documentWorkspace.Refresh();
  1871. //}
  1872. }
  1873. #endregion 基础操作
  1874. #region 矩形拖动
  1875. /// <summary>
  1876. /// 鼠标按下
  1877. /// </summary>
  1878. /// <param name="drawArea"></param>
  1879. /// <param name="e"></param>
  1880. protected override void OnMouseDown(object sender, MouseEventArgs e)
  1881. {
  1882. if (!CanUseMouseFunctions())
  1883. return;
  1884. try
  1885. {
  1886. //判断
  1887. //画左右下辅助线
  1888. if (linebottom == null || lineleft == null || lineright == null)
  1889. {
  1890. this.documentWorkspace.Cursor = Cursors.Default;
  1891. //在MouseDown处获知鼠标是否按下,并记录下此时的鼠标坐标值;
  1892. if (e.Button == MouseButtons.Left)
  1893. {
  1894. }
  1895. return;
  1896. //int margin = Math.Min(this.bitmap.Width / 2 - 5, (int)(this.scopeMarginLeft / this.physical_length));// lab1Img.Width / 20;
  1897. //lineleft = new Line(new System.Drawing.Point(margin, 0), new System.Drawing.Point(margin, lab1Img.Height));
  1898. //lineright = new Line(new System.Drawing.Point(lab1Img.Width - margin, 0), new System.Drawing.Point(lab1Img.Width - margin, lab1Img.Height));
  1899. }
  1900. System.Drawing.Point point = this.documentWorkspace.GetScalePoint(e.Location);
  1901. float mouse_x = point.X;// ((e.X - panel1.Location.X + 12) * zoom - imgX);
  1902. float mouse_y = point.Y;// ((e.Y - panel1.Location.Y + 12) * zoom - imgY);
  1903. string line = this.textBox6__Text.Trim();
  1904. string width = this.textBox4__Text.Trim();
  1905. //画平行的多条辅助线
  1906. int n = int.Parse(line); //线的数量
  1907. int per_w = (int)(double.Parse(width) / this.physical_length); //线的间距(目前当成像素,将来需要从微米转成像素)
  1908. per_w = Math.Max(1, per_w);//避免报错“尝试除以零”
  1909. int bottomY1 = linebottom.startPoint.Y - per_w * (n - 1);
  1910. if (mouse_x < lineleft.startPoint.X + 10 && mouse_x > lineleft.startPoint.X - 10)
  1911. {
  1912. //拖动左辅助线
  1913. mouseFlag = 1;
  1914. }
  1915. else if (mouse_x < lineright.startPoint.X + 10 && mouse_x > lineright.startPoint.X - 10)
  1916. {
  1917. //拖动右辅助线
  1918. mouseFlag = 2;
  1919. }
  1920. else if (mouse_y < linebottom.startPoint.Y && mouse_y > bottomY1)
  1921. {
  1922. xPos = (int)mouse_x;// e.X;//当前x坐标
  1923. yPos = (int)mouse_y;// e.Y;//当前y坐标
  1924. //拖动平行辅助线
  1925. mouseFlag = 3;
  1926. }
  1927. else
  1928. {
  1929. this.documentWorkspace.Cursor = Cursors.Default;
  1930. }
  1931. }
  1932. catch (Exception ex)
  1933. {
  1934. MessageBox.Show(ex.Message);
  1935. }
  1936. }
  1937. /// <summary>
  1938. /// 移动
  1939. /// </summary>
  1940. /// <param name="sender"></param>
  1941. /// <param name="e"></param>
  1942. protected override void onMouseMove(object sender, MouseEventArgs e)
  1943. {
  1944. if (!CanUseMouseFunctions())
  1945. return;
  1946. //拖动左右辅助线
  1947. if (mouseFlag == 1 || mouseFlag == 2)
  1948. {
  1949. //Mat ImageROI = null;
  1950. try
  1951. {
  1952. System.Drawing.Point point = this.documentWorkspace.GetScalePoint(e.Location);
  1953. float mouse_x = point.X;// ((e.X - panel1.Location.X + 12) * zoom - imgX);
  1954. float mouse_y = point.Y;// ((e.Y - panel1.Location.Y + 12) * zoom - imgY);
  1955. ////移动左辅助线
  1956. //drawg.Clear(Color.FromArgb(0, 11, 11, 11));
  1957. int margin = (int)mouse_x;
  1958. margin = Math.Min(this.bitmap/*lab1Img*/.Width - 10, margin);
  1959. margin = Math.Max(10, margin);
  1960. if (mouseFlag == 1)
  1961. {
  1962. lineleft = new Line(new System.Drawing.Point(margin, 0), new System.Drawing.Point(margin, this.bitmap/*lab1Img*/.Height));
  1963. }
  1964. else if (mouseFlag == 2)
  1965. {
  1966. lineright = new Line(new System.Drawing.Point(margin, 0), new System.Drawing.Point(margin, this.bitmap/*lab1Img*/.Height));
  1967. }
  1968. this.drawLines();
  1969. this.documentWorkspace.Refresh();
  1970. }
  1971. catch
  1972. {
  1973. }
  1974. finally
  1975. {
  1976. //ImageROI.Dispose();
  1977. //GC.Collect();
  1978. }
  1979. return;
  1980. }
  1981. //拖动平行辅助线
  1982. if (mouseFlag == 3)
  1983. {
  1984. System.Drawing.Point point = this.documentWorkspace.GetScalePoint(e.Location);
  1985. float mouse_x = point.X;// ((e.X - panel1.Location.X + 12) * zoom - imgX);
  1986. float mouse_y = point.Y;// ((e.Y - panel1.Location.Y + 12) * zoom - imgY);
  1987. string line = this.textBox6__Text.Trim();
  1988. string width = this.textBox4__Text.Trim();
  1989. try
  1990. {
  1991. //drawg.Clear(Color.FromArgb(0, 11, 11, 11));
  1992. //画左右下辅助线
  1993. if (lineleft == null || lineright == null)
  1994. {
  1995. int margin = Math.Min(this.bitmap.Width / 2 - 5, (int)(this.scopeMarginLeft / this.physical_length));// this.bitmap/*lab1Img*/.Width / 20;
  1996. lineleft = new Line(new System.Drawing.Point(margin, 0), new System.Drawing.Point(margin, this.bitmap/*lab1Img*/.Height));
  1997. lineright = new Line(new System.Drawing.Point(this.bitmap/*lab1Img*/.Width - margin, 0), new System.Drawing.Point(this.bitmap/*lab1Img*/.Width - margin, this.bitmap/*lab1Img*/.Height));
  1998. }
  1999. if (linebottom == null)
  2000. {
  2001. linebottom = new Line(new System.Drawing.Point(0, this.bitmap/*lab1Img*/.Height - 30/*130*/), new System.Drawing.Point(this.bitmap/*lab1Img*/.Width, this.bitmap/*lab1Img*/.Height - 30/*130*/));
  2002. }
  2003. //bluePen = new Pen(Color.Blue, zoom);
  2004. //drawg.DrawLine(bluePen, lineleft.startPoint, lineleft.endPoint);
  2005. //drawg.DrawLine(bluePen, lineright.startPoint, lineright.endPoint);
  2006. //画平行的多条辅助线
  2007. int n = int.Parse(line); //线的数量
  2008. int per_w = (int)(double.Parse(width) / this.physical_length); //线的间距(目前当成像素,将来需要从微米转成像素)
  2009. per_w = Math.Max(1, per_w);//避免报错“尝试除以零”
  2010. //hlines.Clear();
  2011. //for (int i = 0; i < n; i++)
  2012. //{
  2013. // Line l = new Line(new System.Drawing.Point(0, linebottom.startPoint.Y + (int)(mouse_y - yPos) - per_w * i), new System.Drawing.Point(this.bitmap/*lab1Img*/.Width, linebottom.startPoint.Y + (int)(mouse_y - yPos) - per_w * i));
  2014. // //drawg.DrawLine(new Pen(Color.FromArgb(255, 0, 208, 202), zoom), l.startPoint, l.endPoint);
  2015. // hlines.Add(l);
  2016. //}
  2017. //honlines.Clear();
  2018. btnflag = 1;
  2019. //pictureBox1.Image = map;
  2020. this.documentWorkspace.Refresh();
  2021. }
  2022. catch (Exception ex)
  2023. {
  2024. //MessageBox.Show(ex.Message);//解决不断弹出提示语的bug
  2025. }
  2026. return;
  2027. }
  2028. if (btnflag == 2)
  2029. {
  2030. //Mat ImageROI = null;
  2031. try
  2032. {
  2033. System.Drawing.Point point = this.documentWorkspace.GetScalePoint(e.Location);
  2034. float mouse_y = point.Y;// ((e.Y - panel1.Location.Y + 12) * zoom - imgY);
  2035. ////移动辅助线
  2036. //drawg.Clear(Color.FromArgb(0, 11, 11, 11));
  2037. }
  2038. catch (Exception b)
  2039. {
  2040. //MessageBox.Show(b.Message);//解决不断弹出提示语的bug
  2041. }
  2042. finally
  2043. {
  2044. //ImageROI.Dispose();
  2045. //GC.Collect();
  2046. }
  2047. return;
  2048. }
  2049. if (btnflag == 1)
  2050. {
  2051. try
  2052. {
  2053. System.Drawing.Point point = this.documentWorkspace.GetScalePoint(e.Location);
  2054. float mouse_x = point.X;// ((e.X - panel1.Location.X + 12) * zoom - imgX);
  2055. float mouse_y = point.Y;// ((e.Y - panel1.Location.Y + 12) * zoom - imgY);
  2056. string line = this.textBox6__Text.Trim();
  2057. string width = this.textBox4__Text.Trim();
  2058. //画平行的多条辅助线
  2059. int n = int.Parse(line); //线的数量
  2060. int per_w = (int)(double.Parse(width) / this.physical_length); //线的间距(目前当成像素,将来需要从微米转成像素)
  2061. per_w = Math.Max(1, per_w);//避免报错“尝试除以零”
  2062. int bottomY1 = linebottom.startPoint.Y - per_w * (n - 1);
  2063. if ((mouse_x < lineleft.startPoint.X + 10 && mouse_x > lineleft.startPoint.X - 10) || (mouse_x < lineright.startPoint.X + 10 && mouse_x > lineright.startPoint.X - 10))
  2064. {
  2065. //移动辅助线
  2066. this.documentWorkspace.Cursor = Cursors.SizeWE;
  2067. }
  2068. else if (mouse_y < linebottom.startPoint.Y && mouse_y > bottomY1)
  2069. {
  2070. //移动辅助线
  2071. this.documentWorkspace.Cursor = Cursors.SizeAll;
  2072. }
  2073. else
  2074. {
  2075. this.documentWorkspace.Cursor = Cursors.Default;
  2076. }
  2077. }
  2078. catch (Exception ex)
  2079. {
  2080. //MessageBox.Show(ex.Message);//解决不断弹出提示语的bug
  2081. }
  2082. }
  2083. else
  2084. {
  2085. this.documentWorkspace.Cursor = Cursors.Default;
  2086. }
  2087. }
  2088. /// <summary>
  2089. /// 鼠标抬起
  2090. /// </summary>
  2091. /// <param name="sender"></param>
  2092. /// <param name="e"></param>
  2093. protected override void onMouseUp(object sender, MouseEventArgs e)
  2094. {
  2095. if (!CanUseMouseFunctions())
  2096. return;
  2097. //拖动平行辅助线
  2098. if (mouseFlag == 3)
  2099. {
  2100. System.Drawing.Point point = this.documentWorkspace.GetScalePoint(e.Location);
  2101. float mouse_x = point.X;// ((e.X - panel1.Location.X + 12) * zoom - imgX);
  2102. float mouse_y = point.Y;// ((e.Y - panel1.Location.Y + 12) * zoom - imgY);
  2103. string line = this.textBox6__Text.Trim();
  2104. string width = this.textBox4__Text.Trim();
  2105. try
  2106. {
  2107. //drawg.Clear(Color.FromArgb(0, 11, 11, 11));
  2108. //画左右下辅助线
  2109. if (lineleft == null || lineright == null)
  2110. {
  2111. int margin = Math.Min(this.bitmap.Width / 2 - 5, (int)(this.scopeMarginLeft / this.physical_length));// this.bitmap/*lab1Img*/.Width / 20;
  2112. lineleft = new Line(new System.Drawing.Point(margin, 0), new System.Drawing.Point(margin, this.bitmap/*lab1Img*/.Height));
  2113. lineright = new Line(new System.Drawing.Point(this.bitmap/*lab1Img*/.Width - margin, 0), new System.Drawing.Point(this.bitmap/*lab1Img*/.Width - margin, this.bitmap/*lab1Img*/.Height));
  2114. }
  2115. if (linebottom == null)
  2116. {
  2117. linebottom = new Line(new System.Drawing.Point(0, this.bitmap/*lab1Img*/.Height - 30/*130*/), new System.Drawing.Point(this.bitmap/*lab1Img*/.Width, this.bitmap/*lab1Img*/.Height - 30/*130*/));
  2118. }
  2119. //bluePen = new Pen(Color.Blue, zoom);
  2120. //drawg.DrawLine(bluePen, lineleft.startPoint, lineleft.endPoint);
  2121. //drawg.DrawLine(bluePen, lineright.startPoint, lineright.endPoint);
  2122. //画平行的多条辅助线
  2123. int n = int.Parse(line); //线的数量
  2124. int per_w = (int)(double.Parse(width) / this.physical_length); //线的间距(目前当成像素,将来需要从微米转成像素)
  2125. per_w = Math.Max(1, per_w);//避免报错“尝试除以零”
  2126. //hlines.Clear();
  2127. //for (int i = 0; i < n; i++)
  2128. //{
  2129. // Line l = new Line(new System.Drawing.Point(0, linebottom.startPoint.Y + (int)(mouse_y - yPos) - per_w * i), new System.Drawing.Point(this.bitmap/*lab1Img*/.Width, linebottom.startPoint.Y + (int)(mouse_y - yPos) - per_w * i));
  2130. // //drawg.DrawLine(new Pen(Color.FromArgb(255, 0, 208, 202), zoom), l.startPoint, l.endPoint);
  2131. // hlines.Add(l);
  2132. //}
  2133. //honlines.Clear();
  2134. btnflag = 1;
  2135. //pictureBox1.Image = map;
  2136. linebottom.startPoint.Y = linebottom.startPoint.Y + (int)(mouse_y - yPos);
  2137. this.documentWorkspace.Refresh();
  2138. }
  2139. catch (Exception ex)
  2140. {
  2141. MessageBox.Show(ex.Message);
  2142. }
  2143. }
  2144. mouseFlag = 0;
  2145. }
  2146. #endregion
  2147. #region 分析结果的方法
  2148. /// <summary>
  2149. /// 点击保存结果按钮,用来返回需要新增的一行数据
  2150. /// </summary>
  2151. /// <param name="tag"></param>
  2152. /// <param name="imgName"></param>
  2153. /// <returns></returns>
  2154. protected override DataTable toInsertTableRow(string tag, string imgName)
  2155. {
  2156. DataTable dt = new DataTable(tag);
  2157. dt.Columns.Add(PdnResources.GetString("Menu.picture.Text"));
  2158. dt.Columns.Add(PdnResources.GetString("Menu.rea.Text"));
  2159. dt.Columns.Add(PdnResources.GetString("Menu.area.text"));
  2160. dt.Columns.Add(PdnResources.GetString("Menu.Thetotalarea.text"));
  2161. dt.Columns.Add(PdnResources.GetString("Menu.Percentageofholevolume.text"));
  2162. dt.Columns.Add(PdnResources.GetString("Menu.Totallengthofintercept.text"));
  2163. dt.Columns.Add(PdnResources.GetString("Menu.Meanporeintercept.text"));
  2164. dt.Columns.Add(PdnResources.GetString("Menu.Numberofintercept.text"));
  2165. {
  2166. DataRow dataRow = dt.NewRow();
  2167. dataRow[PdnResources.GetString("Menu.picture.Text")] = imgName;
  2168. dataRow[PdnResources.GetString("Menu.rea.Text")] = PdnResources.GetString("Menu.rea.Text") + 1;
  2169. if (true || checkBox2.Checked)
  2170. {
  2171. dataRow[PdnResources.GetString("Menu.area.text")] = this.area1;
  2172. dataRow[PdnResources.GetString("Menu.Thetotalarea.text")] = this.allarea1;
  2173. dataRow[PdnResources.GetString("Menu.Percentageofholevolume.text")] = this.area1 * 100 / this.allarea1;
  2174. }
  2175. else
  2176. {
  2177. dataRow[PdnResources.GetString("Menu.area.text")] = "";
  2178. dataRow[PdnResources.GetString("Menu.Thetotalarea.text")] = "";
  2179. dataRow[PdnResources.GetString("Menu.Percentageofholevolume.text")] = "";
  2180. }
  2181. if (true || checkBox3.Checked)
  2182. {
  2183. dataRow[PdnResources.GetString("Menu.Totallengthofintercept.text")] = this.totallength1;
  2184. dataRow[PdnResources.GetString("Menu.Meanporeintercept.text")] = this.perlength1;
  2185. dataRow[PdnResources.GetString("Menu.Numberofintercept.text")] = this.pointsum1;
  2186. }
  2187. else
  2188. {
  2189. dataRow[PdnResources.GetString("Menu.Totallengthofintercept.text")] = "";
  2190. dataRow[PdnResources.GetString("Menu.Meanporeintercept.text")] = "";
  2191. dataRow[PdnResources.GetString("Menu.Numberofintercept.text")] = "";
  2192. }
  2193. dt.Rows.Add(dataRow);
  2194. }
  2195. {
  2196. DataRow dataRow = dt.NewRow();
  2197. dataRow[PdnResources.GetString("Menu.picture.Text")] = imgName;
  2198. dataRow[PdnResources.GetString("Menu.rea.Text")] = PdnResources.GetString("Menu.rea.Text") + 2;
  2199. if (true || checkBox2.Checked)
  2200. {
  2201. dataRow[PdnResources.GetString("Menu.area.text")] = this.area2;
  2202. dataRow[PdnResources.GetString("Menu.Thetotalarea.text")] = this.allarea2;
  2203. dataRow[PdnResources.GetString("Menu.Percentageofholevolume.text")] = this.area2 * 100 / this.allarea2;
  2204. }
  2205. else
  2206. {
  2207. dataRow[PdnResources.GetString("Menu.area.text")] = "";
  2208. dataRow[PdnResources.GetString("Menu.Thetotalarea.text")] = "";
  2209. dataRow[PdnResources.GetString("Menu.Percentageofholevolume.text")] = "";
  2210. }
  2211. if (true || checkBox3.Checked)
  2212. {
  2213. dataRow[PdnResources.GetString("Menu.Totallengthofintercept.text")] = this.totallength2;
  2214. dataRow[PdnResources.GetString("Menu.Meanporeintercept.text")] = this.perlength2;
  2215. dataRow[PdnResources.GetString("Menu.Numberofintercept.text")] = this.pointsum2;
  2216. }
  2217. else
  2218. {
  2219. dataRow[PdnResources.GetString("Menu.Totallengthofintercept.text")] = "";
  2220. dataRow[PdnResources.GetString("Menu.Meanporeintercept.text")] = "";
  2221. dataRow[PdnResources.GetString("Menu.Numberofintercept.text")] = "";
  2222. }
  2223. dt.Rows.Add(dataRow);
  2224. }
  2225. {
  2226. DataRow dataRow = dt.NewRow();
  2227. dataRow[PdnResources.GetString("Menu.picture.Text")] = imgName;
  2228. dataRow[PdnResources.GetString("Menu.rea.Text")] = PdnResources.GetString("Menu.rea.Text") + 3;
  2229. if (true || checkBox2.Checked)
  2230. {
  2231. dataRow[PdnResources.GetString("Menu.area.text")] = this.area3;
  2232. dataRow[PdnResources.GetString("Menu.Thetotalarea.text")] = this.allarea3;
  2233. dataRow[PdnResources.GetString("Menu.Percentageofholevolume.text")] = this.area3 * 100 / this.allarea3;
  2234. }
  2235. else
  2236. {
  2237. dataRow[PdnResources.GetString("Menu.area.text")] = "";
  2238. dataRow[PdnResources.GetString("Menu.Thetotalarea.text")] = "";
  2239. dataRow[PdnResources.GetString("Menu.Percentageofholevolume.text")] = "";
  2240. }
  2241. if (true || checkBox3.Checked)
  2242. {
  2243. dataRow[PdnResources.GetString("Menu.Totallengthofintercept.text")] = this.totallength3;
  2244. dataRow[PdnResources.GetString("Menu.Meanporeintercept.text")] = this.perlength3;
  2245. dataRow[PdnResources.GetString("Menu.Numberofintercept.text")] = this.pointsum3;
  2246. }
  2247. else
  2248. {
  2249. dataRow[PdnResources.GetString("Menu.Totallengthofintercept.text")] = "";
  2250. dataRow[PdnResources.GetString("Menu.Meanporeintercept.text")] = "";
  2251. dataRow[PdnResources.GetString("Menu.Numberofintercept.text")] = "";
  2252. }
  2253. dt.Rows.Add(dataRow);
  2254. }
  2255. ////dt.Columns.Add(PdnResources.GetString("Menu.picture.Text"));
  2256. ////dt.Columns.Add(PdnResources.GetString("Menu.Averagethickness(μm).text"));
  2257. ////dt.Columns.Add(PdnResources.GetString("Menu.standarddeviation.text"));
  2258. ////dt.Columns.Add(PdnResources.GetString("Menu.confidencebound.text"));
  2259. //DataRow dataRow = dt.NewRow();
  2260. //dataRow[PdnResources.GetString("Menu.picture.Text")] = imgName;
  2261. //dataRow[PdnResources.GetString("Menu.Totallengthofporeintercepts.text")] = res_totalL;
  2262. //dataRow[PdnResources.GetString("Menu.Meanporeintercept.text")] = res_perL;
  2263. //dataRow[PdnResources.GetString("Menu.Numberofintercept.text")] = res_count;
  2264. //dt.Rows.Add(dataRow);
  2265. return dt;
  2266. }
  2267. /// <summary>
  2268. /// 计算结果是否存在
  2269. /// </summary>
  2270. /// <returns>返回是否可以计算和保存结果</returns>
  2271. protected override bool resultCalculateExist()
  2272. {
  2273. return this.documentWorkspace.PhaseModels[0].mat != null;// tempHoleMat != null;// vlines.Count > 0;
  2274. }
  2275. /// <summary>
  2276. /// 拼接中间数据
  2277. /// </summary>
  2278. /// <returns></returns>
  2279. protected override List<List<string>> buildTempDataList()
  2280. {
  2281. //return null;
  2282. List<List<string>> dataList = new List<List<string>>();
  2283. List<string> columnName = new List<string>();
  2284. //columnName.Add(PdnResources.GetString("Menu.Imagement.Measurementlist.ordernumber.text"));
  2285. //columnName.Add(PdnResources.GetString("Menu.Tools.AuxiliaryLine.Text") + PdnResources.GetString("Menu.Xoordinate.Text"));
  2286. //columnName.Add(PdnResources.GetString("Menu.ToYcoordinate.Text"));
  2287. //columnName.Add(PdnResources.GetString("Menu.ToYcoonate.Text"));
  2288. //columnName.Add(PdnResources.GetString("Menu.Tools.AuxiliaryLine.Text") + PdnResources.GetString("Menu.MeasureAction.MeasureLength.Text"));
  2289. //columnName.Add(PdnResources.GetString("Menu.Physicallength.text"));//addAction:这里
  2290. columnName.Add("截线" + PdnResources.GetString("Menu.Imagement.Measurementlist.ordernumber.text"));
  2291. columnName.Add(PdnResources.GetString("Menu.eauxiliarylineYcoordinate.Text"));
  2292. columnName.Add(PdnResources.GetString("Menu.LeftXcoordinate.Text"));
  2293. columnName.Add(PdnResources.GetString("Menu.RightXcoordinate.Text"));
  2294. columnName.Add(PdnResources.GetString("Menu.Lengthofauxiliaryline.Text"));
  2295. columnName.Add(PdnResources.GetString("Menu.Physicallength.text"));//addAction:这里
  2296. dataList.Add(columnName);
  2297. int index = 0;
  2298. //if (honlines != null && honlines.Count() > 0)
  2299. //{
  2300. // foreach (Line l in honlines)
  2301. // {
  2302. // graphics.DrawLine(yellowPen, l.startPoint, l.endPoint);
  2303. // }
  2304. //}
  2305. //循环辅助线的集合
  2306. if (lineDraws != null && lineDraws.Count() > 0)
  2307. {
  2308. //循环每条线,找到和轮廓的交点
  2309. for (int i = 0; i < lineDraws.Count(); i++)
  2310. {
  2311. //Line l = lineDraws[i];
  2312. List<string> strList = new List<string>();
  2313. strList.Add((++index).ToString());
  2314. strList.Add(lineDraws[i].startPoint.Y.ToString());
  2315. strList.Add(lineDraws[i].startPoint.X.ToString());
  2316. strList.Add(lineDraws[i].endPoint.X.ToString());
  2317. strList.Add((lineDraws[i].endPoint.X - lineDraws[i].startPoint.X).ToString());
  2318. strList.Add(((lineDraws[i].endPoint.X - lineDraws[i].startPoint.X) * physical_length).ToString());
  2319. dataList.Add(strList);
  2320. }
  2321. }
  2322. //int index = 0;
  2323. //////厚度的数组
  2324. ////int[] thickness = new int[vlines.Count()];
  2325. ////循环辅助线的集合
  2326. //if (this.vlines.Count > 0)
  2327. //{
  2328. // //循环每条线,找到和轮廓的交点
  2329. // for (int i = 0; i < vlines.Count(); i++)
  2330. // {
  2331. // ////计算厚度,像素
  2332. // //thickness[i] = lineNum - vlines[i].startPoint.Y;
  2333. // List<string> strList = new List<string>();
  2334. // strList.Add((++index).ToString());
  2335. // strList.Add(vlines[i].startPoint.X.ToString());
  2336. // strList.Add(vlines[i].startPoint.Y.ToString());
  2337. // strList.Add(lineNum.ToString());
  2338. // strList.Add((lineNum - vlines[i].startPoint.Y).ToString());
  2339. // strList.Add(((lineNum - vlines[i].startPoint.Y) * physical_length).ToString());
  2340. // dataList.Add(strList);
  2341. // }
  2342. //}
  2343. return dataList;
  2344. }
  2345. /// <summary>
  2346. /// 孔隙体积百分比
  2347. /// </summary>
  2348. /// <param name="sender"></param>
  2349. /// <param name="e"></param>
  2350. private void Button3_Click(object sender, EventArgs e)
  2351. {
  2352. int planesnum = top.startPoint.Y;// int.Parse(Intent.dict["planesnum"].ToString());
  2353. int planesbottom3 = bottom.startPoint.Y;// int.Parse(Intent.dict["planesbottom"].ToString());
  2354. if (((planesbottom3 - planesnum) * physical_length) > 600)
  2355. {
  2356. planesbottom3 = planesnum + +(int)(600 / physical_length);
  2357. }
  2358. int planesbottom1 = planesnum + +(int)(200 / physical_length);
  2359. int planesbottom2 = planesnum + +(int)(400 / physical_length);
  2360. //计算三个区域的孔隙体积百分比
  2361. //if (top == null || bottom == null)
  2362. //{
  2363. // MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectareafirst.text"));
  2364. // return;
  2365. //}
  2366. Mat lab1Img = this.documentWorkspace.PhaseModels[0].mat;
  2367. ////重新进行处理
  2368. Mat src2 = new Mat();
  2369. lab1Img.CopyTo(src2);
  2370. //简单计算孔隙面积和总面积等
  2371. area1 = 0;
  2372. allarea1 = 0;
  2373. area2 = 0;
  2374. allarea2 = 0;
  2375. area3 = 0;
  2376. allarea3 = 0;
  2377. int leftX = lineleft.startPoint.X;
  2378. int rightX = lineright.startPoint.X;
  2379. //区域1
  2380. try
  2381. {
  2382. //获取用户指定的区域
  2383. Rect rect = new Rect(leftX, planesnum, Math.Max(1, rightX - leftX), planesbottom1 - planesnum);
  2384. Mat tempMat = src2.Clone(rect);
  2385. this.leftX11 = leftX;
  2386. this.topX11 = planesnum;
  2387. Mat tempHole1Mat = new Mat(tempMat.Size(), MatType.CV_8UC4, new Scalar(0, 0, 0, 0));
  2388. Vec4b tempHoleVec4b = new Vec4b(panel2_0.BackColor.B, panel2_0.BackColor.G, panel2_0.BackColor.R, 255);
  2389. area1 = 0;
  2390. int Rows = tempMat.Rows;
  2391. int Cols = tempMat.Cols;
  2392. int[] point = new int[2];
  2393. //简单计算孔隙面积和总面积等
  2394. for (point[1] = 0; point[1] < Cols; point[1]++)
  2395. for (point[0] = 0; point[0] < Rows; point[0]++)
  2396. if (tempMat.At<Vec4b>(point[0], point[1]).Item3 <= 0)
  2397. {
  2398. tempHole1Mat.Set(point, tempHoleVec4b);
  2399. area1++;
  2400. }
  2401. allarea1 = tempMat.Width * (planesbottom1 - planesnum);
  2402. if (tempHole1Bitmap != null)
  2403. {
  2404. tempHole1Bitmap.Dispose();
  2405. tempHole1Bitmap = null;
  2406. }
  2407. tempHole1Bitmap = OpenCvSharp.Extensions.BitmapConverter.ToBitmap(tempHole1Mat);
  2408. tempHole1Mat.Dispose();
  2409. tempHole1Mat = null;
  2410. //this.documentWorkspace.Refresh();
  2411. }
  2412. catch
  2413. {
  2414. }
  2415. //区域2
  2416. try
  2417. {
  2418. //获取用户指定的区域
  2419. Rect rect = new Rect(leftX, planesbottom1, Math.Max(1, rightX - leftX), planesbottom2 - planesbottom1);
  2420. Mat tempMat = src2.Clone(rect);
  2421. this.leftX22 = leftX;
  2422. this.topX22 = planesbottom1;
  2423. Mat tempHole2Mat = new Mat(tempMat.Size(), MatType.CV_8UC4, new Scalar(0, 0, 0, 0));
  2424. Vec4b tempHoleVec4b = new Vec4b(panel5.BackColor.B, panel5.BackColor.G, panel5.BackColor.R, 255);
  2425. area2 = 0;
  2426. int Rows = tempMat.Rows;
  2427. int Cols = tempMat.Cols;
  2428. int[] point = new int[2];
  2429. //简单计算孔隙面积和总面积等
  2430. for (point[1] = 0; point[1] < Cols; point[1]++)
  2431. for (point[0] = 0; point[0] < Rows; point[0]++)
  2432. if (tempMat.At<Vec4b>(point[0], point[1]).Item3 <= 0)
  2433. {
  2434. tempHole2Mat.Set(point, tempHoleVec4b);
  2435. area2++;
  2436. }
  2437. allarea2 = tempMat.Width * (planesbottom2 - planesbottom1);
  2438. if (tempHole2Bitmap != null)
  2439. {
  2440. tempHole2Bitmap.Dispose();
  2441. tempHole2Bitmap = null;
  2442. }
  2443. tempHole2Bitmap = OpenCvSharp.Extensions.BitmapConverter.ToBitmap(tempHole2Mat);
  2444. tempHole2Mat.Dispose();
  2445. tempHole2Mat = null;
  2446. //this.documentWorkspace.Refresh();
  2447. }
  2448. catch
  2449. {
  2450. }
  2451. //区域3
  2452. try
  2453. {
  2454. //获取用户指定的区域
  2455. Rect rect = new Rect(leftX, planesbottom2, Math.Max(1, rightX - leftX), planesbottom3 - planesbottom2);
  2456. Mat tempMat = src2.Clone(rect);
  2457. this.leftX33 = leftX;
  2458. this.topX33 = planesbottom2;
  2459. Mat tempHole3Mat = new Mat(tempMat.Size(), MatType.CV_8UC4, new Scalar(0, 0, 0, 0));
  2460. Vec4b tempHoleVec4b = new Vec4b(panel4.BackColor.B, panel4.BackColor.G, panel4.BackColor.R, 255);
  2461. area3 = 0;
  2462. int Rows = tempMat.Rows;
  2463. int Cols = tempMat.Cols;
  2464. int[] point = new int[2];
  2465. //简单计算孔隙面积和总面积等
  2466. for (point[1] = 0; point[1] < Cols; point[1]++)
  2467. for (point[0] = 0; point[0] < Rows; point[0]++)
  2468. if (tempMat.At<Vec4b>(point[0], point[1]).Item3 <= 0)
  2469. {
  2470. tempHole3Mat.Set(point, tempHoleVec4b);
  2471. area3++;
  2472. }
  2473. allarea3 = tempMat.Width * (planesbottom3 - planesbottom2);
  2474. if (tempHole3Bitmap != null)
  2475. {
  2476. tempHole3Bitmap.Dispose();
  2477. tempHole3Bitmap = null;
  2478. }
  2479. tempHole3Bitmap = OpenCvSharp.Extensions.BitmapConverter.ToBitmap(tempHole3Mat);
  2480. tempHole3Mat.Dispose();
  2481. tempHole3Mat = null;
  2482. //this.documentWorkspace.Refresh();
  2483. }
  2484. catch
  2485. {
  2486. }
  2487. }
  2488. /// <summary>
  2489. /// 相颜色点击事件
  2490. /// </summary>
  2491. /// <param name="sender"></param>
  2492. /// <param name="e"></param>
  2493. private void panel2_Click(object sender, EventArgs e)
  2494. {
  2495. this.panelC = (Panel)sender;
  2496. this.colorsFormGrid.UserPrimaryColor = ColorBgra.FromColor(((Panel)sender).BackColor);
  2497. this.colorsFormGrid.ShowDialog();
  2498. }
  2499. /// <summary>
  2500. /// PanelC的调色板颜色改变
  2501. /// </summary>
  2502. /// <param name="sender"></param>
  2503. /// <param name="e"></param>
  2504. private void gridColorChanged(object sender, EventArgs e)
  2505. {
  2506. Color color = this.colorsFormGrid.UserPrimaryColor.ToColor();
  2507. //更改背景色,触发事件
  2508. this.panelC.BackColor = color;
  2509. if (this.panelC == this.panel2_0 || this.panelC == this.panel5 || this.panelC == this.panel4
  2510. || this.panelC == this.panel3)
  2511. {
  2512. if (this.panelC == this.panel2_0 && tempHole1Bitmap != null)
  2513. {
  2514. Mat tempHole1Mat = OpenCvSharp.Extensions.BitmapConverter.ToMat(tempHole1Bitmap);
  2515. Mat tempHole1MatCopy = new Mat(tempHole1Mat.Size(), MatType.CV_8UC4, new Scalar(0, 0, 0, 0));
  2516. Vec4b tempHoleVec4b = new Vec4b(panel2_0.BackColor.B, panel2_0.BackColor.G, panel2_0.BackColor.R, 255);
  2517. area1 = 0;
  2518. int Rows = tempHole1Mat.Rows;
  2519. int Cols = tempHole1Mat.Cols;
  2520. int[] point = new int[2];
  2521. //简单计算孔隙面积和总面积等
  2522. for (point[1] = 0; point[1] < Cols; point[1]++)
  2523. for (point[0] = 0; point[0] < Rows; point[0]++)
  2524. if (tempHole1Mat.At<Vec4b>(point[0], point[1]).Item3 > 0)
  2525. {
  2526. tempHole1MatCopy.Set(point, tempHoleVec4b);
  2527. area1++;
  2528. }
  2529. if (tempHole1Bitmap != null)
  2530. {
  2531. tempHole1Bitmap.Dispose();
  2532. tempHole1Bitmap = null;
  2533. }
  2534. tempHole1Bitmap = OpenCvSharp.Extensions.BitmapConverter.ToBitmap(tempHole1MatCopy);
  2535. tempHole1Mat.Dispose();
  2536. tempHole1Mat = null;
  2537. tempHole1MatCopy.Dispose();
  2538. tempHole1MatCopy = null;
  2539. }
  2540. if (this.panelC == this.panel5 && tempHole2Bitmap != null)
  2541. {
  2542. Mat tempHole2Mat = OpenCvSharp.Extensions.BitmapConverter.ToMat(tempHole2Bitmap);
  2543. Mat tempHole2MatCopy = new Mat(tempHole2Mat.Size(), MatType.CV_8UC4, new Scalar(0, 0, 0, 0));
  2544. Vec4b tempHoleVec4b = new Vec4b(panel5.BackColor.B, panel5.BackColor.G, panel5.BackColor.R, 255);
  2545. area1 = 0;
  2546. int Rows = tempHole2Mat.Rows;
  2547. int Cols = tempHole2Mat.Cols;
  2548. int[] point = new int[2];
  2549. //简单计算孔隙面积和总面积等
  2550. for (point[1] = 0; point[1] < Cols; point[1]++)
  2551. for (point[0] = 0; point[0] < Rows; point[0]++)
  2552. if (tempHole2Mat.At<Vec4b>(point[0], point[1]).Item3 > 0)
  2553. {
  2554. tempHole2MatCopy.Set(point, tempHoleVec4b);
  2555. area1++;
  2556. }
  2557. if (tempHole2Bitmap != null)
  2558. {
  2559. tempHole2Bitmap.Dispose();
  2560. tempHole2Bitmap = null;
  2561. }
  2562. tempHole2Bitmap = OpenCvSharp.Extensions.BitmapConverter.ToBitmap(tempHole2MatCopy);
  2563. tempHole2Mat.Dispose();
  2564. tempHole2Mat = null;
  2565. tempHole2MatCopy.Dispose();
  2566. tempHole2MatCopy = null;
  2567. }
  2568. if (this.panelC == this.panel4 && tempHole3Bitmap != null)
  2569. {
  2570. Mat tempHole3Mat = OpenCvSharp.Extensions.BitmapConverter.ToMat(tempHole3Bitmap);
  2571. Mat tempHole3MatCopy = new Mat(tempHole3Mat.Size(), MatType.CV_8UC4, new Scalar(0, 0, 0, 0));
  2572. Vec4b tempHoleVec4b = new Vec4b(panel4.BackColor.B, panel4.BackColor.G, panel4.BackColor.R, 255);
  2573. area1 = 0;
  2574. int Rows = tempHole3Mat.Rows;
  2575. int Cols = tempHole3Mat.Cols;
  2576. int[] point = new int[2];
  2577. //简单计算孔隙面积和总面积等
  2578. for (point[1] = 0; point[1] < Cols; point[1]++)
  2579. for (point[0] = 0; point[0] < Rows; point[0]++)
  2580. if (tempHole3Mat.At<Vec4b>(point[0], point[1]).Item3 > 0)
  2581. {
  2582. tempHole3MatCopy.Set(point, tempHoleVec4b);
  2583. area1++;
  2584. }
  2585. if (tempHole3Bitmap != null)
  2586. {
  2587. tempHole3Bitmap.Dispose();
  2588. tempHole3Bitmap = null;
  2589. }
  2590. tempHole3Bitmap = OpenCvSharp.Extensions.BitmapConverter.ToBitmap(tempHole3MatCopy);
  2591. tempHole3Mat.Dispose();
  2592. tempHole3Mat = null;
  2593. tempHole3MatCopy.Dispose();
  2594. tempHole3MatCopy = null;
  2595. }
  2596. this.documentWorkspace.Refresh();
  2597. }
  2598. //关闭色板
  2599. this.colorsFormGrid.Close();
  2600. }
  2601. /// <summary>
  2602. /// 绘制辅助线
  2603. /// </summary>
  2604. private void drawLines11()
  2605. {
  2606. //string line = this.textBox6.Text.Trim();
  2607. this.refreshPerWidth();
  2608. string width = this.textBox4.Text.Trim();
  2609. try
  2610. {
  2611. //drawg.Clear(Color.FromArgb(0, 11, 11, 11));
  2612. //drawg.DrawLine(new Pen(Color.Blue, zoom), lineleft.startPoint, lineleft.endPoint);
  2613. //drawg.DrawLine(new Pen(Color.Blue, zoom), lineright.startPoint, lineright.endPoint);
  2614. //bluePen = new Pen(Color.FromArgb(255, 0, 208, 202), zoom);
  2615. //画平行的多条辅助线
  2616. //int n = int.Parse(line); //线的数量
  2617. int per_w = (int)(double.Parse(width) / this.physical_length); //线的间距(目前当成像素,将来需要从微米转成像素)
  2618. per_w = Math.Max(1, per_w);//避免报错“尝试除以零”
  2619. line1s.Clear();
  2620. line2s.Clear();
  2621. line3s.Clear();
  2622. lines.Clear();
  2623. int rect_3n = (int)(200 / double.Parse(width));
  2624. int planesnum = top.startPoint.Y;// int.Parse(Intent.dict["planesnum"].ToString());
  2625. int planesbottom1 = planesnum + +(int)(200 / physical_length);
  2626. int planesbottom2 = planesnum + +(int)(400 / physical_length);
  2627. int planesbottom3 = bottom.startPoint.Y;// int.Parse(Intent.dict["planesbottom"].ToString());
  2628. if (((bottom.startPoint.Y - planesnum) * physical_length) > 600)
  2629. {
  2630. planesbottom3 = planesnum + +(int)(600 / physical_length);
  2631. }
  2632. else
  2633. {
  2634. rect_3n = (int)(((bottom.startPoint.Y - planesnum) * physical_length - 400) / double.Parse(width));
  2635. }
  2636. rect_n = (int)(200 / double.Parse(width));
  2637. int rightX = lineright.startPoint.X;
  2638. for (int i = 0; i < rect_n; i++)
  2639. {
  2640. int lypos = planesnum + per_w * i + per_w;
  2641. lypos = Math.Min(planesbottom1 - (int)1, lypos);
  2642. Line l = new Line(new System.Drawing.Point(leftX11, lypos), new System.Drawing.Point(rightX, lypos));
  2643. //drawg.DrawLine(bluePen, l.startPoint, l.endPoint);
  2644. line1s.Add(l);
  2645. lines.Add(l);
  2646. }
  2647. for (int i = 0; i < rect_n; i++)
  2648. {
  2649. int lypos = planesbottom1 + per_w * i + per_w;
  2650. lypos = Math.Min(planesbottom2 - (int)/*zoom*/1, lypos);
  2651. Line l = new Line(new System.Drawing.Point(leftX22, lypos), new System.Drawing.Point(rightX, lypos));
  2652. //drawg.DrawLine(bluePen, l.startPoint, l.endPoint);
  2653. line2s.Add(l);
  2654. lines.Add(l);
  2655. }
  2656. for (int i = 0; i < rect_3n/*(n - rect_n * 2)*/; i++)
  2657. {
  2658. int lypos = planesbottom2 + per_w * i + per_w;
  2659. lypos = Math.Min(planesbottom3 - (int)1, lypos);
  2660. Line l = new Line(new System.Drawing.Point(leftX33, lypos), new System.Drawing.Point(rightX, lypos));
  2661. //drawg.DrawLine(bluePen, l.startPoint, l.endPoint);
  2662. line3s.Add(l);
  2663. lines.Add(l);
  2664. }
  2665. //drawg.DrawLine(new Pen(Color.Blue/*Red*/, zoom), new System.Drawing.Point(0, planesbottom1), new System.Drawing.Point(lab1Img.Width, planesbottom1));
  2666. //drawg.DrawLine(new Pen(Color.Blue/*Red*/, zoom), new System.Drawing.Point(0, planesbottom2), new System.Drawing.Point(lab1Img.Width, planesbottom2));
  2667. //if (((bottom.startPoint.Y - planesnum) * physical_length) > 600)
  2668. //{
  2669. // drawg.DrawLine(new Pen(Color.Blue/*Red*/, zoom), new System.Drawing.Point(0, planesbottom3), new System.Drawing.Point(lab1Img.Width, planesbottom3));
  2670. //}
  2671. //drawg.DrawLine(new Pen(Color.Yellow/*White*/, zoom), top.startPoint, top.endPoint);
  2672. //drawg.DrawLine(new Pen(Color.Yellow, zoom), bottom.startPoint, bottom.endPoint);
  2673. //pictureBox1.Image = map;
  2674. this.documentWorkspace.Refresh();
  2675. }
  2676. catch (Exception ex)
  2677. {
  2678. MessageBox.Show(ex.Message);
  2679. }
  2680. }
  2681. /// <summary>
  2682. /// 平均孔隙截距
  2683. /// </summary>
  2684. /// <param name="sender"></param>
  2685. /// <param name="e"></param>
  2686. private void Button11_Click(object sender, EventArgs e)
  2687. {
  2688. //if (top == null/* || bottom == null*/)
  2689. //{
  2690. // MessageBox.Show(PdnResources.GetString("Menu.Pleasedefinetnterfacefirst.text"));
  2691. // return;
  2692. //}
  2693. Mat analyzeMat = this.documentWorkspace.PhaseModels[0].mat;
  2694. if (this.documentWorkspace.PhaseModels[0].mat == null)
  2695. {
  2696. MessageBox.Show(PdnResources.GetString("Menu.Pleasebinarizefirst.text"));
  2697. return;
  2698. }
  2699. //if (contours == null)
  2700. //{
  2701. // MessageBox.Show(PdnResources.GetString("Menu.Pleaseclicktodrawtheoutlinefirst.text"));
  2702. // return;
  2703. //}
  2704. drawLines11();
  2705. int n = line1s.Count + line2s.Count + line3s.Count;
  2706. string width = this.textBox4.Text.Trim();
  2707. //string width = this.textBox4__Text.Trim();
  2708. double result = 0;
  2709. if (!double.TryParse(width, out result))
  2710. {
  2711. MessageBox.Show(PdnResources.GetString("Menu.Linespacinginputformatincorrect.text"));
  2712. return;
  2713. }
  2714. //if (double.Parse(width) > 100)//######################
  2715. //{
  2716. // MessageBox.Show("线的间距不应超过100微米");
  2717. // return;
  2718. //}
  2719. //rect_n = (int)(200 / double.Parse(width));
  2720. if ((n - rect_n * 2) < 1)
  2721. {
  2722. MessageBox.Show(PdnResources.GetString("Menu.Pleaserepartition.text"));
  2723. return;
  2724. }
  2725. linePoints.Clear();
  2726. calculation = true;
  2727. int drawsize = 3;
  2728. totallength1 = 0;
  2729. pointsum1 = 0;
  2730. totallength2 = 0;
  2731. pointsum2 = 0;
  2732. totallength3 = 0;
  2733. pointsum3 = 0;
  2734. List<List<OpenCvSharp.Point>> ddd = new List<List<OpenCvSharp.Point>>();
  2735. for (int i = 0; i < lines.Count; i++)
  2736. {
  2737. List<OpenCvSharp.Point> list = new List<OpenCvSharp.Point>();
  2738. int xMinPoint = Math.Min(lineleft.endPoint.X, lineright.endPoint.X);
  2739. int xMaxPoint = Math.Max(lineleft.endPoint.X, lineright.endPoint.X);
  2740. int yLinePoint = lines[i].endPoint.Y;// - 1;
  2741. bool holeLineStart = true;//结束于视场的边缘或孔隙区域的中间,则这个区域不应包括在内
  2742. OpenCvSharp.Point startPoint = new OpenCvSharp.Point(-1, yLinePoint);
  2743. for (int j = xMinPoint; j <= xMaxPoint; j++)
  2744. {
  2745. if (analyzeMat.At<Vec4b>(yLinePoint, j).Item3 <= 0)
  2746. {
  2747. if (!holeLineStart)
  2748. {
  2749. startPoint.X = j;
  2750. //list.Add(new OpenCvSharp.Point(j, yLinePoint));//记录网格线的起始点
  2751. holeLineStart = true;
  2752. }
  2753. }
  2754. else if (holeLineStart)
  2755. {
  2756. holeLineStart = false;
  2757. if (startPoint.X > 0)
  2758. {
  2759. ++pointsum;
  2760. totallength += (j - startPoint.X);
  2761. //honlines.Add(new Line(new System.Drawing.Point(startPoint.X, yLinePoint), new System.Drawing.Point(j, yLinePoint)));
  2762. list.Add(new OpenCvSharp.Point(startPoint.X, yLinePoint));//记录网格线的结束点
  2763. list.Add(new OpenCvSharp.Point(j, yLinePoint));//记录网格线的结束点
  2764. }
  2765. }
  2766. }
  2767. //for (int j = contours.Count() - 1; j >= 0; j--)
  2768. //{
  2769. // List<OpenCvSharp.Point> dsd = contours[j].ToList<OpenCvSharp.Point>();
  2770. // List<OpenCvSharp.Point> lll = dsd.FindAll(a => a.Y == lines[i].endPoint.Y - 1 && a.X > lineleft.endPoint.X && a.X < lineright.endPoint.X);
  2771. // if (lll != null && lll.Count > 0)
  2772. // {
  2773. // //过滤一下,如果点密集,只要一个
  2774. // int finetuning = 0;
  2775. // //过滤,如果一个轮廓返回了一个点或者奇数点,则抛弃
  2776. // List<OpenCvSharp.Point> temp = new List<OpenCvSharp.Point>();
  2777. // foreach (var Point in lll)
  2778. // {
  2779. // //过滤一下,如果点密集,只要一个
  2780. // if (finetuning == 0)
  2781. // {
  2782. // finetuning = Point.X;
  2783. // }
  2784. // else
  2785. // {
  2786. // if ((Point.X == finetuning + 1) || (Point.X == finetuning - 1))
  2787. // {
  2788. // finetuning = Point.X;
  2789. // continue;
  2790. // }
  2791. // finetuning = Point.X;
  2792. // }
  2793. // temp.Add(new OpenCvSharp.Point(Point.X, Point.Y));
  2794. // }
  2795. // list.AddRange(temp);
  2796. // }
  2797. //}
  2798. //list.Sort((a, b) => a.X.CompareTo(b.X));
  2799. ddd.Add(list);
  2800. }
  2801. lineDraws.Clear();
  2802. for (int j = 0; j < n/*rect_n*/; j++)
  2803. {
  2804. var point = ddd[j];
  2805. for (int k = 0; k < point.Count - 1; k+=2)
  2806. {
  2807. //drawg.DrawEllipse(new Pen(Color.Yellow, drawsize), point[k].X, point[k].Y, drawsize, drawsize);
  2808. OpenCvSharp.Point a = point[k];
  2809. OpenCvSharp.Point b = point[k + 1];
  2810. int x = (a.X + b.X) / 2;
  2811. //if (dst1234.At<byte>(a.Y, x) <= 0)
  2812. {
  2813. //++pointsum;
  2814. if (j < rect_n)
  2815. {
  2816. ++pointsum1;
  2817. totallength1 += (b.X - a.X);
  2818. }
  2819. else if (j < rect_n * 2)
  2820. {
  2821. ++pointsum2;
  2822. totallength2 += (b.X - a.X);
  2823. }
  2824. else
  2825. {
  2826. ++pointsum3;
  2827. totallength3 += (b.X - a.X);
  2828. }
  2829. lineDraws.Add(new Line(new System.Drawing.Point(a.X, a.Y), new System.Drawing.Point(b.X, b.Y)));
  2830. ////drawg.DrawLine(new Pen(Color.Yellow, drawsize + 2), temp[k].X, temp[k].Y, temp[k + 1].X, temp[k + 1].Y);
  2831. //drawg.DrawLine(new Pen(Color.Yellow, drawsize), a.X, a.Y, b.X, b.Y);
  2832. }
  2833. }
  2834. }
  2835. //else
  2836. //{
  2837. // //Form8 form = new Form8(lab1Img, null, physical_length, top, bottom, lineleft, lineright);
  2838. // //form.StartPosition = FormStartPosition.CenterParent;
  2839. // //if (form.ShowDialog() != DialogResult.OK)
  2840. // //{
  2841. // // return;
  2842. // //}
  2843. //}
  2844. this.documentWorkspace.Refresh();
  2845. //pictureBox1.Image = map;
  2846. calculate1d = true;
  2847. //循环计算有效的网格线平均孔隙密度
  2848. totallength = 0;
  2849. pointsum = 0;
  2850. totallength1 = (float)(totallength1 * physical_length);
  2851. perlength1 = totallength1 / Math.Max(1, pointsum1);
  2852. pointsum1 = (pointsum1 * 2);
  2853. totallength2 = (float)(totallength2 * physical_length);
  2854. perlength2 = totallength2 / Math.Max(1, pointsum2);
  2855. pointsum2 = (pointsum2 * 2);
  2856. totallength3 = (float)(totallength3 * physical_length);
  2857. perlength3 = totallength3 / Math.Max(1, pointsum3);
  2858. pointsum3 = (pointsum3 * 2);
  2859. }
  2860. /// <summary>
  2861. /// 向数据展示表插入数据
  2862. /// </summary>
  2863. private void AddContentToDataGridView()
  2864. {
  2865. this.dataGridView1.Rows.Clear();
  2866. {
  2867. DataGridViewRow row = new DataGridViewRow();
  2868. row.Height = 21;
  2869. row.Cells.Add(CreateTextBoxCell(PdnResources.GetString("Menu.rea.Text") + 1, ""));
  2870. if (true || checkBox2.Checked)
  2871. {
  2872. row.Cells.Add(CreateTextBoxCell(this.resShow(this.area1.ToString()), ""));
  2873. row.Cells.Add(CreateTextBoxCell(this.resShow(this.allarea1.ToString()), ""));
  2874. row.Cells.Add(CreateTextBoxCell(this.resShow((this.area1 * 100 / this.allarea1).ToString()), ""));
  2875. }
  2876. else
  2877. {
  2878. row.Cells.Add(CreateTextBoxCell("", ""));
  2879. row.Cells.Add(CreateTextBoxCell("", ""));
  2880. row.Cells.Add(CreateTextBoxCell("", ""));
  2881. }
  2882. if (true || checkBox3.Checked)
  2883. {
  2884. row.Cells.Add(CreateTextBoxCell(this.resShow(this.totallength1.ToString()), ""));
  2885. row.Cells.Add(CreateTextBoxCell(this.resShow(this.perlength1.ToString()), ""));
  2886. row.Cells.Add(CreateTextBoxCell(this.resShow(this.pointsum1.ToString()), ""));
  2887. }
  2888. else
  2889. {
  2890. row.Cells.Add(CreateTextBoxCell("", ""));
  2891. row.Cells.Add(CreateTextBoxCell("", ""));
  2892. row.Cells.Add(CreateTextBoxCell("", ""));
  2893. }
  2894. this.dataGridView1.Rows.Add(row);
  2895. }
  2896. {
  2897. DataGridViewRow row = new DataGridViewRow();
  2898. row.Height = 21;
  2899. row.Cells.Add(CreateTextBoxCell(PdnResources.GetString("Menu.rea.Text") + 2, ""));
  2900. if (true || checkBox2.Checked)
  2901. {
  2902. row.Cells.Add(CreateTextBoxCell(this.resShow(this.area2.ToString()), ""));
  2903. row.Cells.Add(CreateTextBoxCell(this.resShow(this.allarea2.ToString()), ""));
  2904. row.Cells.Add(CreateTextBoxCell(this.resShow((this.area2 * 100 / this.allarea2).ToString()), ""));
  2905. }
  2906. else
  2907. {
  2908. row.Cells.Add(CreateTextBoxCell("", ""));
  2909. row.Cells.Add(CreateTextBoxCell("", ""));
  2910. row.Cells.Add(CreateTextBoxCell("", ""));
  2911. }
  2912. if (true || checkBox3.Checked)
  2913. {
  2914. row.Cells.Add(CreateTextBoxCell(this.resShow(this.totallength2.ToString()), ""));
  2915. row.Cells.Add(CreateTextBoxCell(this.resShow(this.perlength2.ToString()), ""));
  2916. row.Cells.Add(CreateTextBoxCell(this.resShow(this.pointsum2.ToString()), ""));
  2917. }
  2918. else
  2919. {
  2920. row.Cells.Add(CreateTextBoxCell("", ""));
  2921. row.Cells.Add(CreateTextBoxCell("", ""));
  2922. row.Cells.Add(CreateTextBoxCell("", ""));
  2923. }
  2924. this.dataGridView1.Rows.Add(row);
  2925. }
  2926. {
  2927. DataGridViewRow row = new DataGridViewRow();
  2928. row.Height = 21;
  2929. row.Cells.Add(CreateTextBoxCell(PdnResources.GetString("Menu.rea.Text") + 3, ""));
  2930. if (true || checkBox2.Checked)
  2931. {
  2932. row.Cells.Add(CreateTextBoxCell(this.resShow(this.area3.ToString()), ""));
  2933. row.Cells.Add(CreateTextBoxCell(this.resShow(this.allarea3.ToString()), ""));
  2934. row.Cells.Add(CreateTextBoxCell(this.resShow((this.area3 * 100 / this.allarea3).ToString()), ""));
  2935. }
  2936. else
  2937. {
  2938. row.Cells.Add(CreateTextBoxCell("", ""));
  2939. row.Cells.Add(CreateTextBoxCell("", ""));
  2940. row.Cells.Add(CreateTextBoxCell("", ""));
  2941. }
  2942. if (true || checkBox3.Checked)
  2943. {
  2944. row.Cells.Add(CreateTextBoxCell(this.resShow(this.totallength3.ToString()), ""));
  2945. row.Cells.Add(CreateTextBoxCell(this.resShow(this.perlength3.ToString()), ""));
  2946. row.Cells.Add(CreateTextBoxCell(this.resShow(this.pointsum3.ToString()), ""));
  2947. }
  2948. else
  2949. {
  2950. row.Cells.Add(CreateTextBoxCell("", ""));
  2951. row.Cells.Add(CreateTextBoxCell("", ""));
  2952. row.Cells.Add(CreateTextBoxCell("", ""));
  2953. }
  2954. this.dataGridView1.Rows.Add(row);
  2955. }
  2956. this.dataGridView1.ClearSelection();
  2957. //this.dataGridView1.Rows[this.dataGridView1.Rows.Count - 2].Selected = true;
  2958. }
  2959. /// <summary>
  2960. /// 计算结果
  2961. /// </summary>
  2962. /// <param name="sender"></param>
  2963. /// <param name="e"></param>
  2964. protected override void buttonCalculate_Click(object sender, EventArgs e)
  2965. {
  2966. if (this.documentWorkspace.PhaseModels[0].mat == null)
  2967. {
  2968. MessageBox.Show(PdnResources.GetString("Menu.Pleasebinarizefirst.text"));
  2969. return;
  2970. }
  2971. //if (!checkBox2.Checked && !checkBox3.Checked)
  2972. //{
  2973. // MessageBox.Show(PdnResources.GetString("Menu.Pleasechrceptinthesetting.text"));
  2974. // return;
  2975. //}
  2976. if (top == null/* || bottom == null*/)
  2977. {
  2978. MessageBox.Show(PdnResources.GetString("Menu.Pleasedefinetnterfacefirst.text"));
  2979. return;
  2980. }
  2981. this.Button3_Click(sender, e);
  2982. this.Button11_Click(sender, e);
  2983. if (calculate1d)
  2984. this.AddContentToDataGridView();
  2985. ////if (top == null || bottom == null)
  2986. ////{
  2987. //// MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectareafirst.text"));
  2988. //// return;
  2989. ////}
  2990. ////int result = 0;
  2991. //if (hlines.Count == 0)
  2992. //{
  2993. // MessageBox.Show(PdnResources.GetString("Menu.Pleasedrawauxiliarylinesfirst.text"));
  2994. // return;
  2995. //}
  2996. //if (!resultCalculateExist())
  2997. //{
  2998. // MessageBox.Show("请先进行寻找孔隙操作");//PdnResources.GetString("Menu.Pleaselookfortheoutlinefirst.text") ;//点击绘制轮廓
  2999. // return;
  3000. // //MessageBox.Show(PdnResources.GetString("Menu.Pleasedrawauxiliarylinesfirst.text"));
  3001. // //return;
  3002. //}
  3003. ////calculation = true;
  3004. ////循环计算有效的网格线平均孔隙密度
  3005. //float totallength = 0;
  3006. ////float perlength = 0;
  3007. //int pointsum = 0;
  3008. ////List<List<OpenCvSharp.Point>> ddd = new List<List<OpenCvSharp.Point>>();
  3009. //honlines.Clear();
  3010. //for (int i = 0; i < hlines.Count; i++)//hlines
  3011. //{
  3012. // //List<OpenCvSharp.Point> list = new List<OpenCvSharp.Point>();
  3013. // int xMinPoint = Math.Min(lineleft.endPoint.X, lineright.endPoint.X);
  3014. // int xMaxPoint = Math.Max(lineleft.endPoint.X, lineright.endPoint.X);
  3015. // int yLinePoint = hlines[i].endPoint.Y;// - 1;
  3016. // bool holeLineStart = true;//结束于视场的边缘或孔隙区域的中间,则这个区域不应包括在内
  3017. // OpenCvSharp.Point startPoint = new OpenCvSharp.Point(-1, yLinePoint);
  3018. // for (int j = xMinPoint; j <= xMaxPoint; j++)
  3019. // {
  3020. // if (tempHoleMat.At<Vec4b>(yLinePoint, j).Item3 > 0)
  3021. // {
  3022. // if (!holeLineStart)
  3023. // {
  3024. // startPoint.X = j;
  3025. // //list.Add(new OpenCvSharp.Point(j, yLinePoint));//记录网格线的起始点
  3026. // holeLineStart = true;
  3027. // }
  3028. // }
  3029. // else if (holeLineStart)
  3030. // {
  3031. // holeLineStart = false;
  3032. // if (startPoint.X > 0)
  3033. // {
  3034. // ++pointsum;
  3035. // totallength += (j - startPoint.X);
  3036. // honlines.Add(new Line(new System.Drawing.Point(startPoint.X, yLinePoint), new System.Drawing.Point(j, yLinePoint)));
  3037. // //list.Add(new OpenCvSharp.Point(j, yLinePoint));//记录网格线的结束点
  3038. // }
  3039. // }
  3040. // }
  3041. // //if (!holeLineStart && list.Count > 0)//起始于视场的边缘或孔隙区域的中间,则这个区域不应包括在内
  3042. // // list.RemoveAt(list.Count - 1);
  3043. // //////for (int j = contours.Count() - 1; j >= 0; j--)//#
  3044. // //////{
  3045. // ////// List<OpenCvSharp.Point> dsd = contours[j].ToList<OpenCvSharp.Point>();
  3046. // ////// List<OpenCvSharp.Point> lll = dsd.FindAll(a => a.Y == hlines[i].endPoint.Y - 1 && a.X > lineleft.endPoint.X && a.X < lineright.endPoint.X);
  3047. // ////// if (lll != null && lll.Count > 0)
  3048. // ////// {
  3049. // ////// //过滤一下,如果点密集,只要一个
  3050. // ////// int finetuning = 0;
  3051. // ////// //过滤,如果一个轮廓返回了一个点或者奇数点,则抛弃
  3052. // ////// List<OpenCvSharp.Point> temp = new List<OpenCvSharp.Point>();
  3053. // ////// foreach (var Point in lll)
  3054. // ////// {
  3055. // ////// //过滤一下,如果点密集,只要一个
  3056. // ////// if (finetuning == 0)
  3057. // ////// {
  3058. // ////// finetuning = Point.X;
  3059. // ////// }
  3060. // ////// else
  3061. // ////// {
  3062. // ////// if ((Point.X == finetuning + 1) || (Point.X == finetuning - 1))
  3063. // ////// {
  3064. // ////// finetuning = Point.X;
  3065. // ////// continue;
  3066. // ////// }
  3067. // ////// finetuning = Point.X;
  3068. // ////// }
  3069. // ////// temp.Add(new OpenCvSharp.Point(Point.X, Point.Y));
  3070. // ////// }
  3071. // ////// list.AddRange(temp);
  3072. // ////// }
  3073. // //////}
  3074. // ////list.Sort((a, b) => a.X.CompareTo(b.X));
  3075. // //ddd.Add(list);
  3076. //}
  3077. //////Cv2.ImShow("dst12344", dst1234);
  3078. ////honlines.Clear();
  3079. //////绘制所有交点
  3080. ////foreach (var point in ddd)
  3081. ////{
  3082. //// for (int k = 0; k < point.Count - 1; k += 2)
  3083. //// {
  3084. //// ////drawg.DrawEllipse(new Pen(Color.Yellow, drawsize), point[k].X, point[k].Y, drawsize, drawsize);
  3085. //// OpenCvSharp.Point a = point[k];
  3086. //// OpenCvSharp.Point b = point[k + 1];
  3087. //// //int x = (a.X + b.X) / 2;
  3088. //// ////lab1NoneContourImg
  3089. //// //if (dst1234.At<byte>(a.Y, x) <= 0)
  3090. //// //{
  3091. //// // ++pointsum;
  3092. //// // totallength += (b.X - a.X);
  3093. //// //honlines.Add(new Line(new System.Drawing.Point(a.X, a.Y), new System.Drawing.Point(b.X, b.Y)));
  3094. //// // //drawg.DrawLine(new Pen(Color.Yellow, drawsize), a.X, a.Y, b.X, b.Y);
  3095. //// //}
  3096. //// ////double innum = Cv2.PointPolygonTest(contours[j], new Point2f(x, a.Y), false);
  3097. //// ////if (innum > 0)
  3098. //// ////{
  3099. //// //// drawg.DrawLine(new Pen(Color.Yellow, drawsize), a.X, a.Y, b.X, b.Y);
  3100. //// //// break;
  3101. //// ////}//########################################
  3102. //// }
  3103. ////}
  3104. ////////Cv2.DrawContours(lab1Img, contours, -1, Scalar.Blue, Cv2.FILLED);
  3105. ////////pictureBox1.BackgroundImage = OpenCvSharp.Extensions.BitmapConverter.ToBitmap(lab1Img);
  3106. //////pictureBox1.Image = map;
  3107. //this.documentWorkspace.Refresh();
  3108. //res_totalL = totallength * physical_length;
  3109. //res_perL = res_totalL / Math.Max(1, pointsum);
  3110. //res_count = Math.Max(1, pointsum);
  3111. ////计算结果
  3112. ////this.label2.Text = this.resShow(res_totalL.ToString());
  3113. ////this.label7.Text = this.resShow(res_perL.ToString());
  3114. ////this.label14.Text = res_count.ToString(); ;
  3115. //calculate1d = true;
  3116. }
  3117. ///// <summary>
  3118. ///// 记录输入文字改变的状态
  3119. ///// </summary>
  3120. //int textBoxChanged = -1;
  3121. ///// <summary>
  3122. ///// 上辅助线居顶距离改变
  3123. ///// </summary>
  3124. ///// <param name="sender"></param>
  3125. ///// <param name="e"></param>
  3126. //private void TextBox4_TextChanged(object sender, EventArgs e)
  3127. //{
  3128. // if (this.bitmap == null)
  3129. // {
  3130. // return;
  3131. // }
  3132. // string width2 = this.textBox6.Text.Trim();
  3133. // int result2;
  3134. // if (!int.TryParse(width2, out result2))
  3135. // {
  3136. // //MessageBox.Show("线的数量输入格式不正确");
  3137. // return;
  3138. // }
  3139. // string width = this.textBox4.Text.Trim();
  3140. // double result;
  3141. // if (!double.TryParse(width, out result))
  3142. // {
  3143. // return;
  3144. // }
  3145. // this.drawLines();
  3146. // this.documentWorkspace.Refresh();
  3147. //}
  3148. /// <summary>
  3149. /// 辅助线数量改变
  3150. /// </summary>
  3151. /// <param name="sender"></param>
  3152. /// <param name="e"></param>
  3153. private void textBox6_TextChanged(object sender, EventArgs e)
  3154. {
  3155. refreshPerWidth();
  3156. }
  3157. /// <summary>
  3158. /// 更新计算平均涂层厚度辅助线的间距
  3159. /// </summary>
  3160. private void refreshPerWidth()
  3161. {
  3162. if (this.bitmap == null)
  3163. {
  3164. return;
  3165. }
  3166. //画左右辅助线
  3167. if (lineleft == null || lineright == null)
  3168. {
  3169. return;//#21375
  3170. //int margin = Math.Min(this.bitmap.Width / 2 - 5, (int)(this.scopeMarginLeft / this.physical_length));// this.bitmap.Width / 20;
  3171. //lineleft = new Line(new System.Drawing.Point(margin, 0), new System.Drawing.Point(margin, this.bitmap.Height));
  3172. //lineright = new Line(new System.Drawing.Point(this.bitmap.Width - margin, 0), new System.Drawing.Point(this.bitmap.Width - margin, this.bitmap.Height));
  3173. }
  3174. if (string.IsNullOrWhiteSpace(this.textBox6.Text) || textBox6.Text == "")
  3175. {
  3176. return;
  3177. }
  3178. int w;
  3179. try
  3180. {
  3181. w = int.Parse(this.textBox6.Text);
  3182. }
  3183. catch (Exception b)
  3184. {
  3185. MessageBox.Show(b.Message);
  3186. return;
  3187. }
  3188. textBox6__Text = textBox6.Text;
  3189. double per_w = ((lineright.startPoint.X - lineleft.startPoint.X) / Math.Max(1, (w + 1))) * physical_length;
  3190. textBox4__Text = per_w.ToString();
  3191. }
  3192. ///// <summary>
  3193. ///// 下辅助线居底距离改变
  3194. ///// </summary>
  3195. ///// <param name="sender"></param>
  3196. ///// <param name="e"></param>
  3197. //private void TextBox6_TextChanged(object sender, EventArgs e)
  3198. //{
  3199. // if (this.bitmap == null)
  3200. // {
  3201. // return;
  3202. // }
  3203. // string width = this.textBox4.Text.Trim();
  3204. // double result;
  3205. // if (!double.TryParse(width, out result))
  3206. // {
  3207. // //MessageBox.Show(PdnResources.GetString("Menu.Linespacinginputformatincorrect.text"));
  3208. // return;
  3209. // }
  3210. // string width2 = this.textBox6.Text.Trim();
  3211. // int result2;
  3212. // if (!int.TryParse(width2, out result2))
  3213. // {
  3214. // //MessageBox.Show("线的数量输入格式不正确");
  3215. // return;
  3216. // }
  3217. // this.drawLines();
  3218. // this.documentWorkspace.Refresh();
  3219. //}
  3220. /// <summary>
  3221. /// 小数点位数变化时刷新界面的数据
  3222. /// </summary>
  3223. protected override void RefreshDataGridView1()
  3224. {
  3225. if (calculate1d)
  3226. {
  3227. //this.label2.Text = this.resShow(res_totalL.ToString());
  3228. //this.label7.Text = this.resShow(res_perL.ToString());
  3229. //this.label14.Text = this.resShow(res_count.ToString());
  3230. }
  3231. }
  3232. #endregion 分析结果的方法
  3233. #region 参数保存及提取
  3234. /// <summary>
  3235. /// 保存参数的key,value和type
  3236. /// </summary>
  3237. /// <param name="param_key"></param>
  3238. /// <param name="param_value"></param>
  3239. /// <param name="param_type"></param>
  3240. private void saveParamValue(string param_key, string param_value, int param_type)
  3241. {
  3242. bool foundItem = false;
  3243. foreach (var item in this.analysisModel.ListParam)
  3244. {
  3245. if (item.param_key.Equals(param_key) && item.menuId == this.menuId)
  3246. {
  3247. item.param_value = param_value;
  3248. item.setValue();
  3249. foundItem = true;
  3250. break;
  3251. }
  3252. }
  3253. if (!foundItem)
  3254. {
  3255. GrainSizeAnalysisModel analysisItem = new GrainSizeAnalysisModel();
  3256. analysisItem.menuId = this.menuId;
  3257. analysisItem.param_key = param_key;
  3258. analysisItem.param_type = param_type;
  3259. analysisItem.param_value = param_value;
  3260. analysisItem.setValue();
  3261. this.analysisModel.ListParam.Add(analysisItem);
  3262. }
  3263. }
  3264. /// <summary>
  3265. /// 保存界面中的参数到model
  3266. /// </summary>
  3267. private void saveDialogParamValues()
  3268. {
  3269. saveParamValue(ParamKey_Report, checkBox_generateReport_opensetting.Checked ? "0" : "1", (int)Base.Dtryt.Boolean);//报告设置
  3270. saveParamValue(ParamKey_SetGuideNumber, textBox6.Text, (int)Base.Dtryt.ItemString);//设置辅助线条数
  3271. saveParamValue(ParamKey_SetShow, checkBox3.Checked ? "0" : "1", (int)Base.Dtryt.Boolean);//设置显示
  3272. saveParamValue(ParamKey_PoreRatioColour1, panel2_0.BackColor.ToArgb().ToString(), (int)Base.Dtryt.Color);//孔隙1体积百分比颜色
  3273. saveParamValue(ParamKey_PoreRatioColour2, panel5.BackColor.ToArgb().ToString(), (int)Base.Dtryt.Color);//孔隙2体积百分比颜色
  3274. saveParamValue(ParamKey_PoreRatioColour3, panel4.BackColor.ToArgb().ToString(), (int)Base.Dtryt.Color);//孔隙3体积百分比颜色
  3275. saveParamValue(ParamKey_PoreRatioShow, checkBox2.Checked ? "0" : "1", (int)Base.Dtryt.Boolean);//孔隙体积百分比显示
  3276. saveParamValue(ParamKey_AvgRangeColour, panel3.BackColor.ToArgb().ToString(), (int)Base.Dtryt.Color);//平均截距颜色
  3277. saveParamValue(ParamKey_AvgRangeWidth, textBox10.Text, (int)Base.Dtryt.ItemString);//平均截距线宽
  3278. saveParamValue(ParamKey_AvgRangeSpacing, textBox4.Text, (int)Base.Dtryt.ItemString);//平均截距间距
  3279. saveParamValue(ParamKey_AvgRangeShow, checkBox1.Checked ? "0" : "1", (int)Base.Dtryt.Boolean);//平均截距显示
  3280. saveParamValue(ParamKey_DecimalPlace, numericUpDown1_0 != null ? numericUpDown1_0.Value.ToString() : "", (int)Base.Dtryt.Decimal);//保留小数位数
  3281. //更多
  3282. saveParamValue(ParamKey_RectLineColor, rectLineColor.ToArgb().ToString(), (int)Base.Dtryt.Color);
  3283. saveParamValue(ParamKey_BaseLineColor, baseLineColor.ToArgb().ToString(), (int)Base.Dtryt.Color);
  3284. saveParamValue(ParamKey_ScopeLineColor, scopeLineColor.ToArgb().ToString(), (int)Base.Dtryt.Color);
  3285. saveParamValue(ParamKey_OrgLineColor, orgLineColor.ToArgb().ToString(), (int)Base.Dtryt.Color);
  3286. saveParamValue(ParamKey_Rect1LineColor, rect1LineColor.ToArgb().ToString(), (int)Base.Dtryt.Color);
  3287. saveParamValue(ParamKey_Rect2LineColor, rect2LineColor.ToArgb().ToString(), (int)Base.Dtryt.Color);
  3288. saveParamValue(ParamKey_Rect3LineColor, rect3LineColor.ToArgb().ToString(), (int)Base.Dtryt.Color);
  3289. saveParamValue(ParamKey_AssistLineColor, assistLineColor.ToArgb().ToString(), (int)Base.Dtryt.Color);
  3290. saveParamValue(ParamKey_RectLineWidth, rectLineWidth.ToString(), (int)Base.Dtryt.Interger);
  3291. saveParamValue(ParamKey_BaseLineWidth, baseLineWidth.ToString(), (int)Base.Dtryt.Interger);
  3292. saveParamValue(ParamKey_ScopeLineWidth, scopeLineWidth.ToString(), (int)Base.Dtryt.Interger);
  3293. saveParamValue(ParamKey_OrgLineWidth, orgLineWidth.ToString(), (int)Base.Dtryt.Interger);
  3294. saveParamValue(ParamKey_Rect1LineWidth, rect1LineWidth.ToString(), (int)Base.Dtryt.Interger);
  3295. saveParamValue(ParamKey_Rect2LineWidth, rect2LineWidth.ToString(), (int)Base.Dtryt.Interger);
  3296. saveParamValue(ParamKey_Rect3LineWidth, rect3LineWidth.ToString(), (int)Base.Dtryt.Interger);
  3297. saveParamValue(ParamKey_AssistLineWidth, assistLineWidth.ToString(), (int)Base.Dtryt.Interger);
  3298. saveParamValue(ParamKey_ScopeMarginLeft, scopeMarginLeft.ToString(), (int)Base.Dtryt.Interger);
  3299. }
  3300. /// <summary>
  3301. /// 获取保存的参数
  3302. /// </summary>
  3303. private void GetListParamModel()
  3304. {
  3305. if (this.analysisModel != null)
  3306. {
  3307. for (int i = 0; i < this.analysisModel.ListParam.Count; i++)
  3308. {
  3309. switch (this.analysisModel.ListParam[i].param_key)
  3310. {
  3311. case ParamKey_RectLineColor:
  3312. rectLineColor = Color.FromArgb((int)this.analysisModel.ListParam[i].value);
  3313. break;
  3314. case ParamKey_BaseLineColor:
  3315. baseLineColor = Color.FromArgb((int)this.analysisModel.ListParam[i].value);
  3316. break;
  3317. case ParamKey_ScopeLineColor:
  3318. scopeLineColor = Color.FromArgb((int)this.analysisModel.ListParam[i].value);
  3319. break;
  3320. case ParamKey_OrgLineColor:
  3321. orgLineColor = Color.FromArgb((int)this.analysisModel.ListParam[i].value);
  3322. break;
  3323. case ParamKey_Rect1LineColor:
  3324. rect1LineColor = Color.FromArgb((int)this.analysisModel.ListParam[i].value);
  3325. break;
  3326. case ParamKey_Rect2LineColor:
  3327. rect2LineColor = Color.FromArgb((int)this.analysisModel.ListParam[i].value);
  3328. break;
  3329. case ParamKey_Rect3LineColor:
  3330. rect3LineColor = Color.FromArgb((int)this.analysisModel.ListParam[i].value);
  3331. break;
  3332. case ParamKey_AssistLineColor:
  3333. assistLineColor = Color.FromArgb((int)this.analysisModel.ListParam[i].value);
  3334. break;
  3335. case ParamKey_RectLineWidth:
  3336. rectLineWidth = (int)this.analysisModel.ListParam[i].value;
  3337. break;
  3338. case ParamKey_BaseLineWidth:
  3339. baseLineWidth = (int)this.analysisModel.ListParam[i].value;
  3340. break;
  3341. case ParamKey_ScopeLineWidth:
  3342. scopeLineWidth = (int)this.analysisModel.ListParam[i].value;
  3343. break;
  3344. case ParamKey_OrgLineWidth:
  3345. orgLineWidth = (int)this.analysisModel.ListParam[i].value;
  3346. break;
  3347. case ParamKey_Rect1LineWidth:
  3348. rect1LineWidth = (int)this.analysisModel.ListParam[i].value;
  3349. break;
  3350. case ParamKey_Rect2LineWidth:
  3351. rect2LineWidth = (int)this.analysisModel.ListParam[i].value;
  3352. break;
  3353. case ParamKey_Rect3LineWidth:
  3354. rect3LineWidth = (int)this.analysisModel.ListParam[i].value;
  3355. break;
  3356. case ParamKey_AssistLineWidth:
  3357. assistLineWidth = (int)this.analysisModel.ListParam[i].value;
  3358. break;
  3359. case ParamKey_ScopeMarginLeft:
  3360. scopeMarginLeft = (int)this.analysisModel.ListParam[i].value;
  3361. break;
  3362. case ParamKey_Report:
  3363. checkBox_generateReport_opensetting.Checked = (Boolean)this.analysisModel.ListParam[i].value;
  3364. break;
  3365. case ParamKey_SetGuideNumber:
  3366. textBox6.Text = this.analysisModel.ListParam[i].value.ToString();
  3367. break;
  3368. case ParamKey_SetShow:
  3369. checkBox3.Checked = (Boolean)this.analysisModel.ListParam[i].value;
  3370. break;
  3371. case ParamKey_PoreRatioColour1:
  3372. panel2_0.BackColor = Color.FromArgb((int)this.analysisModel.ListParam[i].value);
  3373. break;
  3374. case ParamKey_PoreRatioColour2:
  3375. panel5.BackColor = Color.FromArgb((int)this.analysisModel.ListParam[i].value);
  3376. break;
  3377. case ParamKey_PoreRatioColour3:
  3378. panel4.BackColor = Color.FromArgb((int)this.analysisModel.ListParam[i].value);
  3379. break;
  3380. case ParamKey_PoreRatioShow:
  3381. checkBox2.Checked = (Boolean)this.analysisModel.ListParam[i].value;
  3382. break;
  3383. case ParamKey_AvgRangeColour:
  3384. panel3.BackColor = Color.FromArgb((int)this.analysisModel.ListParam[i].value);
  3385. break;
  3386. case ParamKey_AvgRangeWidth:
  3387. textBox10.Text = this.analysisModel.ListParam[i].value.ToString();
  3388. trackBar4.Value = Convert.ToInt32(this.textBox10.Text);
  3389. break;
  3390. case ParamKey_AvgRangeSpacing:
  3391. textBox4.Text = this.analysisModel.ListParam[i].value.ToString();
  3392. break;
  3393. case ParamKey_AvgRangeShow:
  3394. checkBox1.Checked = (Boolean)this.analysisModel.ListParam[i].value;
  3395. break;
  3396. case ParamKey_DecimalPlace:
  3397. numericUpDown1_0.Value = decimal.Parse(this.analysisModel.ListParam[i].param_value);
  3398. break;
  3399. }
  3400. }
  3401. }
  3402. }
  3403. /// <summary>
  3404. /// 关闭窗体时保存参数
  3405. /// </summary>
  3406. /// <param name="sender"></param>
  3407. /// <param name="e"></param>
  3408. private void TABM4Dialog_FormClosing(object sender, FormClosingEventArgs e)
  3409. {
  3410. this.saveDialogParamValues();
  3411. //xml保存路径
  3412. string filePath = Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\GrainSizeAnalyze\\GrainSizeAnalysisModel.xml";
  3413. GrainSizeAnalysisModel analysisModelXml = XmlSerializeHelper.DESerializer<GrainSizeAnalysisModel>(FileOperationHelper.ReadStringFromFile(filePath, System.IO.FileMode.Open));
  3414. foreach (var analysisItem in this.analysisModel.ListParam)
  3415. {
  3416. bool foundItem = false;
  3417. foreach (var item in analysisModelXml.ListParam)
  3418. {
  3419. if (item.param_key.Equals(analysisItem.param_key) && item.menuId == analysisItem.menuId)
  3420. {
  3421. item.param_value = analysisItem.param_value;
  3422. foundItem = true;
  3423. break;
  3424. }
  3425. }
  3426. if (!foundItem)
  3427. analysisModelXml.ListParam.Add(analysisItem.cloneModel());
  3428. }
  3429. //按路径和名称保存xml文件
  3430. string userInfoXml = XmlSerializeHelper.XmlSerialize<GrainSizeAnalysisModel>(analysisModelXml);
  3431. //保存xml
  3432. FileOperationHelper.WriteStringToFile(userInfoXml, filePath, System.IO.FileMode.Create);
  3433. }
  3434. #endregion
  3435. }
  3436. }