PolyphaseMutiAreaContent.cs 153 KB

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