PV1112Dialog.cs 152 KB

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