TwoPhaseScaleDialog.cs 172 KB

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