PV1112Dialog.cs 151 KB

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