123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993 |
- using OpenCvSharp;
- using PaintDotNet.Base.Functionodel;
- using PaintDotNet.CustomControl;
- using PaintDotNet.GeneralAnalysis.AnalysisResultTemplate;
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Windows.Forms;
- using PaintDotNet.DbOpreate.DbBll;
- using PaintDotNet.DbOpreate.DbModel;
- using Point = OpenCvSharp.Point;
- using PaintDotNet.Base.CommTool;
- using PaintDotNet.Instrument;
- using PaintDotNet.Annotation.Enum;
- using Metis.ParameterSet;
- using System.IO;
- using PaintDotNet.Data.Param;
- using PaintDotNet.Base;
- namespace PaintDotNet.GeneralAnalysis
- {
- /// <summary>
- /// 两相比例
- /// </summary>
- internal class TwoPhaseScaleDialog : PdnBaseForm
- {
- #region 控件
- private System.Windows.Forms.GroupBox groupBox4;
- private System.Windows.Forms.ListView listView1;
- private System.Windows.Forms.GroupBox groupBox1;
- private System.Windows.Forms.Button button2;
- private System.Windows.Forms.CheckBox checkBox1;
- private System.Windows.Forms.Button button1;
- private System.Windows.Forms.GroupBox groupBox_review;
- private System.Windows.Forms.GroupBox groupBox5;
- private System.Windows.Forms.GroupBox groupBox6;
- private System.Windows.Forms.GroupBox groupBox7;
- private System.Windows.Forms.Label label1;
- private System.Windows.Forms.Button button4;
- private System.Windows.Forms.Button button3;
- private System.Windows.Forms.ImageList imageList1;
- private DataGridView dataGridView_results;
- private Button button_remove;
- private Button button_all;
- private Button button5;
- private GroupBox groupBox8;
- private Label label6;
- private Label label5;
- private Label label7;
- private Label label8;
- private TextBox txt_UnSelectArea;
- private TextBox txt_UnSelectCount;
- private TextBox txt_SelectCountPersent;
- private TextBox txt_SelectArea;
- private TextBox txt_SelectCount;
- private Label label9;
- private TextBox txt_UnSelectCountPersent;
- private Label label10;
- private IContainer components;
- private Label label13;
- private TextBox txt_UnSelectContent;
- private TextBox txt_SelectContent;
- private Label label12;
- private Label label11;
- private Label label14;
- private TextBox txt_UnSelectCountFromAll;
- private TextBox txt_SelectContentFromAll;
- private Label label15;
- private Label label16;
- private TextBox txt_UnSelectDivSelectCount;
- private TextBox txt_SelectCountDivUnSelect;
- private ColorsForm oneColorsForm;
- private ColorsForm twoColorsForm;
- private NumericUpDown numericUpDown3;
- #endregion
- private CommonControlButtons commonControlButtons;
- /// <summary>
- /// 主空间
- /// </summary>
- private AppWorkspace appWorkspace;
- /// <summary>
- /// 选中图片的mat
- /// </summary>
- private Mat imageMat;
- /// <summary>
- /// 选择物相index
- /// </summary>
- int selectIndex = 0;
- /// <summary>
- /// 当前选择的图片index
- /// </summary>
- int selectImageIndex = 0;
- int decnum = 2;
- /// <summary>
- /// 分析类型 0 面积 1 面积比 2 长宽比 4 最大卡规直径
- /// </summary>
- int workType = 0;
- TwoPhaseScaleResult selectResults = new TwoPhaseScaleResult();
- TwoPhaseScaleResult unSelectResults = new TwoPhaseScaleResult();
- PhaseModel onePhase = new PhaseModel();
- private DocumentWorkspaceWindow documentWorkspace;
- private List<TwoPhaseScaleExportResult> finalResults = new List<TwoPhaseScaleExportResult>();
- private List<Bitmap> bitList = new List<Bitmap>();
- private Button button9;
- private CheckedListBox listBox_analysisResult;
- private Dictionary<string, List<Bitmap>> bitDic = new Dictionary<string, List<Bitmap>>();
- private Label label2;
- private Label label3;
- private Label label4;
- private NumericUpDown numericUpDown1;
- private NumericUpDown numericUpDown2;
- private ComboBox comboBox1;
- private Label label17;
- private Label label18;
- private TriangleTrackBar trackBar2;
- private TriangleTrackBar trackBar1;
- private Label label19;
- private Label label20;
- private Panel panel1;
- private Panel panel2;
- private GroupBox groupBox2;
- private Label label21;
- private int is_all = 0;
- private int menuId;
- private string menuName;
- /// <summary>
- /// 是否脚本运行
- /// </summary>
- private Boolean initScriptValues = false;
- private List<Point[]> points = new List<Point[]>();
- /// <summary>
- /// 当前选择的搜索选项
- /// </summary>
- int selectSearchIndex = 0;
- private DataGridViewTextBoxColumn Column12;
- private DataGridViewTextBoxColumn Column1;
- private DataGridViewTextBoxColumn Column2;
- private DataGridViewTextBoxColumn Column3;
- private DataGridViewTextBoxColumn Column4;
- private DataGridViewTextBoxColumn Column5;
- private DataGridViewTextBoxColumn Column6;
- private DataGridViewTextBoxColumn Column7;
- private DataGridViewTextBoxColumn Column8;
- private DataGridViewTextBoxColumn Column9;
- private DataGridViewTextBoxColumn Column10;
- private DataGridViewTextBoxColumn Column11;
- private DataGridViewTextBoxColumn Column13;
- private int imgIndex = -1;
- private ComboBox comboBox2;
- private GeneralAnalysisModel generalAnalysisModel = new GeneralAnalysisModel();
- private string selectedImg = string.Empty;
- private Dictionary<string, GeneralAnalysisModel.TwoPhaseScaleModel> everyImgData = new Dictionary<string, GeneralAnalysisModel.TwoPhaseScaleModel>();
- public TwoPhaseScaleDialog()
- {
- InitializeComponent();
- }
- private void showImg(object sender, EventArgs e)
- {
- listView1.Focus();
- //滚动到指定的行位置
- if (this.imgIndex != -1)
- {
- this.listView1.EnsureVisible(this.imgIndex);
- this.listView1.Items[imgIndex].Focused = true;
- this.listView1.Items[imgIndex].Selected = true;
- //如果是脚本执行,将参数带入
- if (appWorkspace.ScriptRunning && appWorkspace.ScriptCurrentParam != null)
- {
- this.initScriptValues = true;//ScriptAutomatic
- //Boolean initScriptValues = true;
- ////在这里反射出对应功能的参数类
- string className = InvariantData.path_Action + ".Action" + menuId;
- ParamObject param = (ParamObject)System.Reflection.Assembly.Load(InvariantData.assembly_Data).CreateInstance(className);
- foreach (Args arg in param.Lists)
- {
- Args param1 = appWorkspace.ScriptCurrentParam.Lists.Find(m => m.Key.Equals(arg.Key));
- if (param1.value != null)
- arg.Value = param1.value;
- getValue(arg.key, arg.Value);
- }
- appWorkspace.ScriptCurrentParam = null;//阻止第二次进入仍然被赋值参数
- }
- else
- {//读取上次关闭窗口时保存的参数
- getLastData();
- }
- }
- }
- /// <summary>
- /// 获取上次操作参数
- /// </summary>
- private void getLastData()
- {
- string filePath = Application.StartupPath + "\\Config\\Default\\ParameterSaving\\ParameterGeneralAnalysis.xml";
- if (!System.IO.File.Exists(filePath))
- {
- generalAnalysisModel = new GeneralAnalysisModel();
- generalAnalysisModel.PolyphaseMutiAreaContentModels = new GeneralAnalysisModel.PolyphaseMutiAreaContentModel();
- generalAnalysisModel.PolyphaseCounterAnalysisModels = new GeneralAnalysisModel.PolyphaseCounterAnalysisModel();
- generalAnalysisModel.TwoPhaseScaleModels = new GeneralAnalysisModel.TwoPhaseScaleModel();
- generalAnalysisModel.PolyphaseContentModels = new GeneralAnalysisModel.PolyphaseContentModel();
- generalAnalysisModel.PolyphaseDistanceModels = new GeneralAnalysisModel.PolyphaseDistanceModel();
- generalAnalysisModel.DebrisSelectionModels = new GeneralAnalysisModel.DebrisSelectionModel();
- generalAnalysisModel.CountNumberAnalysisModels = new GeneralAnalysisModel.CountNumberAnalysisModel();
- generalAnalysisModel.PolyphaseMutiAreaContentModels.hasUsed = false;
- generalAnalysisModel.PolyphaseCounterAnalysisModels.hasUsed = false;
- generalAnalysisModel.TwoPhaseScaleModels.hasUsed = false;
- generalAnalysisModel.PolyphaseContentModels.hasUsed = false;
- generalAnalysisModel.PolyphaseDistanceModels.hasUsed = false;
- generalAnalysisModel.DebrisSelectionModels.hasUsed = false;
- generalAnalysisModel.CountNumberAnalysisModels.hasUsed = false;
- string porosityInfoXml = XmlSerializeHelper.XmlSerialize<GeneralAnalysisModel>(generalAnalysisModel);
- Directory.CreateDirectory(Application.StartupPath + "\\Config\\Default\\ParameterSaving\\");
- FileOperationHelper.WriteStringToFile(porosityInfoXml, filePath, FileMode.CreateNew);
- }
- else
- {
- generalAnalysisModel = XmlSerializeHelper.DESerializer<GeneralAnalysisModel>(FileOperationHelper.ReadStringFromFile(filePath, FileMode.Open));
- if (generalAnalysisModel.TwoPhaseScaleModels == null) {
- generalAnalysisModel.TwoPhaseScaleModels = new GeneralAnalysisModel.TwoPhaseScaleModel();
- }
- if (generalAnalysisModel.TwoPhaseScaleModels.hasUsed)
- {
- if (this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].phaseModels.Count != 0)
- {
- if (!string.IsNullOrEmpty(generalAnalysisModel.TwoPhaseScaleModels.parameter1))
- {
- comboBox1.SelectedItem = generalAnalysisModel.TwoPhaseScaleModels.parameter1;
- }
- if (!string.IsNullOrEmpty(generalAnalysisModel.TwoPhaseScaleModels.parameter2))
- {
- comboBox2.SelectedItem = generalAnalysisModel.TwoPhaseScaleModels.parameter2;
- }
- if (numericUpDown1.Minimum > generalAnalysisModel.TwoPhaseScaleModels.parameter3 || numericUpDown1.Maximum < generalAnalysisModel.TwoPhaseScaleModels.parameter3)
- {
- numericUpDown1.Value = 0;
- }
- else {
- numericUpDown1.Value = generalAnalysisModel.TwoPhaseScaleModels.parameter3;
- }
- if (numericUpDown2.Minimum > generalAnalysisModel.TwoPhaseScaleModels.parameter4 || numericUpDown2.Maximum < generalAnalysisModel.TwoPhaseScaleModels.parameter4)
- {
- numericUpDown2.Value = 0;
- }
- else
- {
- numericUpDown2.Value = generalAnalysisModel.TwoPhaseScaleModels.parameter4;
- }
- if (trackBar1.Minimum > generalAnalysisModel.TwoPhaseScaleModels.parameter3 || trackBar1.Maximum < generalAnalysisModel.TwoPhaseScaleModels.parameter3)
- {
- trackBar1.Value = 0;
- }
- else
- {
- trackBar1.Value = (int)generalAnalysisModel.TwoPhaseScaleModels.parameter3;
- }
- if (trackBar2.Minimum > generalAnalysisModel.TwoPhaseScaleModels.parameter4 || trackBar2.Maximum < generalAnalysisModel.TwoPhaseScaleModels.parameter4)
- {
- trackBar2.Value = 0;
- }
- else
- {
- trackBar2.Value = (int)generalAnalysisModel.TwoPhaseScaleModels.parameter4;
- }
- panel1.BackColor = generalAnalysisModel.TwoPhaseScaleModels.parameter5 == 0 ? Color.Red: Color.FromArgb(generalAnalysisModel.TwoPhaseScaleModels.parameter5);
- panel2.BackColor = generalAnalysisModel.TwoPhaseScaleModels.parameter6 == 0 ? Color.Yellow:Color.FromArgb(generalAnalysisModel.TwoPhaseScaleModels.parameter6);
- }
- numericUpDown3.Value = generalAnalysisModel.TwoPhaseScaleModels.parameter7;
- checkBox1.Checked = generalAnalysisModel.TwoPhaseScaleModels.parameter8;
- if (comboBox1.SelectedIndex != -1 && comboBox2.SelectedIndex != -1)
- {
- GetAreaBetweenMinToMax(generalAnalysisModel.TwoPhaseScaleModels.parameter3, generalAnalysisModel.TwoPhaseScaleModels.parameter4, this.documentWorkspace.phaseModels[selectIndex].mat);
- }
- for (int i = 0; i < listView1.Items.Count; i++)
- {
- if (everyImgData.ContainsKey(listView1.Items[i].Name))
- {
- everyImgData[listView1.Items[i].Name] = generalAnalysisModel.TwoPhaseScaleModels;
- }
- else
- {
- everyImgData.Add(listView1.Items[i].Name, generalAnalysisModel.TwoPhaseScaleModels);
- }
- }
- }
- }
- }
- /// <summary>
- /// 保存上次操作参数
- /// </summary>
- private void saveLastData(object sender, EventArgs e)
- {
- #region [开启脚本录制]
- if (appWorkspace.startScriptRecording)
- {
- getScriptRecording();
- }
- #endregion
- if (generalAnalysisModel.TwoPhaseScaleModels == null)
- {
- generalAnalysisModel.TwoPhaseScaleModels = new GeneralAnalysisModel.TwoPhaseScaleModel();
- }
- generalAnalysisModel.TwoPhaseScaleModels.hasUsed = true;
- if (this.listView1.FocusedItem != null && this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].phaseModels != null && this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].phaseModels.Count != 0)
- {
- if (this.listView1.FocusedItem != null && this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].phaseModels.Count != 0)
- {
- if (comboBox1.SelectedIndex != -1)
- {
- generalAnalysisModel.TwoPhaseScaleModels.parameter1 = comboBox1.SelectedItem.ToString();
- }
- if (comboBox2.SelectedIndex != -1)
- {
- generalAnalysisModel.TwoPhaseScaleModels.parameter2 = comboBox2.SelectedItem.ToString();
- }
- }
- generalAnalysisModel.TwoPhaseScaleModels.parameter3 = numericUpDown1.Value;
- generalAnalysisModel.TwoPhaseScaleModels.parameter4 = numericUpDown2.Value;
- generalAnalysisModel.TwoPhaseScaleModels.parameter5 = panel1.BackColor.ToArgb();
- generalAnalysisModel.TwoPhaseScaleModels.parameter6 = panel2.BackColor.ToArgb();
- }
- generalAnalysisModel.TwoPhaseScaleModels.parameter7 = (int)numericUpDown3.Value;
- generalAnalysisModel.TwoPhaseScaleModels.parameter8 = checkBox1.Checked;
- string filePath = Application.StartupPath + "\\Config\\Default\\ParameterSaving\\ParameterGeneralAnalysis.xml";
- string porosityInfoXml = XmlSerializeHelper.XmlSerialize<GeneralAnalysisModel>(generalAnalysisModel);
- FileOperationHelper.WriteStringToFile(porosityInfoXml, filePath, FileMode.Create);
- }
- /// <summary>
- /// 初始化图片列表数据
- /// </summary>
- public void InitPicList()
- {
- //初始化图片列表
- for (int i = 0; i < this.appWorkspace.DocumentWorkspaces.Length; i++)
- {
- this.imageList1.Images.Add("img" + i, this.appWorkspace.DocumentWorkspaces[i].BinarizationThumbnail);
- this.listView1.Items.Add("", i);
- this.listView1.Items[i].ImageIndex = i;
- String imageName = this.appWorkspace.DocumentWorkspaces[i].GetFriendlyName();
- if (listView1.Items.Find(imageName, false).Count() > 0)
- {
- if (imageName.Split('.').Count() > 1)
- {
- imageName = imageName.Split('.')[0] + "(" + listView1.Items.Find(imageName, false).Count() + ")." + imageName.Split('.')[1];
- }
- }
- this.listView1.Items[i].Text = imageName;
- this.listView1.Items[i].Name = imageName;
- if (this.appWorkspace.DocumentWorkspaces[i].Equals(this.appWorkspace.ActiveDocumentWorkspace))
- {
- this.imgIndex = i;
- }
- }
- }
- public TwoPhaseScaleDialog(AppWorkspace appWorkspace, PdnMenuItem menuItem)
- {
- InitializeComponent();
- InitializeLanguageText();
- this.appWorkspace = appWorkspace;
- this.menuId = menuItem.MenuId;
- this.menuName = menuItem.Text;
- this.documentWorkspace = new DocumentWorkspaceWindow(appWorkspace);
- this.documentWorkspace.Dock = DockStyle.Fill;
- this.documentWorkspace.HookMouseEvents();
- this.documentWorkspace.AuxiliaryLineEnabled = false;
- this.documentWorkspace.Visible = false;
- oneColorsForm = new ColorsForm();
- this.oneColorsForm.StartPosition = FormStartPosition.CenterScreen;
- twoColorsForm = new ColorsForm();
- this.twoColorsForm.StartPosition = FormStartPosition.CenterParent;
- this.groupBox_review.Controls.Add(documentWorkspace);
- this.commonControlButtons = new CommonControlButtons();
- this.commonControlButtons.Dock = DockStyle.Top;
- this.commonControlButtons.Height = 30;
- this.commonControlButtons.HideZoomToWindowAndActualSize();
- this.groupBox_review.Controls.Add(commonControlButtons);
- InitPicList();
- SetAnalyzeModelFromXml("Template.Manager.item2.TwoPhaseScale");
- this.listView1.SelectedIndexChanged += new EventHandler(this.ListViewSelectedIndexChanged);
- SetStyle(ControlStyles.UserPaint, true);
- SetStyle(ControlStyles.AllPaintingInWmPaint, true); // 禁止擦除背景.
- SetStyle(ControlStyles.DoubleBuffer, true); // 双缓冲
- InitCommonButtonEvent();
- this.Shown += showImg;
- this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.saveLastData);
- }
- private void InitCommonButtonEvent()
- {
- this.commonControlButtons.zoomInButton.Click += new EventHandler(zoomInButton_Click);
- this.commonControlButtons.zoomOutButton.Click += new EventHandler(zoomOutButton_Click);
- this.commonControlButtons.zoomToWindowButton.Click += new EventHandler(zoomToWindowButton_Click);
- this.commonControlButtons.actualSizeButton.Click += new EventHandler(actualSizeButton_Click);
- this.commonControlButtons.pointerButton.Click += new EventHandler(pointerButton_Click);
- this.commonControlButtons.mobileModeButton.Click += new EventHandler(mobileModeButton_Click);
- }
- private void zoomInButton_Click(object sender, EventArgs e)
- {
- if (this.imageMat != null)
- this.documentWorkspace.ZoomIn();
- }
- private void zoomOutButton_Click(object sender, EventArgs e)
- {
- if (this.imageMat != null)
- this.documentWorkspace.ZoomOut();
- }
- private void zoomToWindowButton_Click(object sender, EventArgs e)
- {
- this.documentWorkspace.ZoomBasis = ZoomBasis.FitToWindow;
- }
- private void actualSizeButton_Click(object sender, EventArgs e)
- {
- this.documentWorkspace.ZoomBasis = ZoomBasis.ScaleFactor;
- this.documentWorkspace.ScaleFactor = ScaleFactor.OneToOne;
- }
- private void pointerButton_Click(object sender, EventArgs e)
- {
- this.documentWorkspace.ActiveTool = Annotation.Enum.DrawToolType.Pointer;
- }
- private void mobileModeButton_Click(object sender, EventArgs e)
- {
- this.documentWorkspace.ActiveTool = Annotation.Enum.DrawToolType.MoveMode;
- }
- private void Init()
- {
- //this.trackBar1.Value = 0;
- //this.trackBar2.Value = 0;
- //this.numericUpDown1.Value = 0;
- //this.numericUpDown2.Value = 0;
- selectResults = new TwoPhaseScaleResult();
- unSelectResults = new TwoPhaseScaleResult();
- //InitUI();
- }
- /// <summary>
- /// ListView图片选择改变事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void ListViewSelectedIndexChanged(object sender, EventArgs e)
- {
- if (listView1.SelectedItems.Count == 1)
- {
- if (this.listView1.SelectedItems.Count > 0 && this.listView1.FocusedItem != null)
- {
- if (!string.IsNullOrEmpty(this.selectedImg))
- {
- #region [保存参数]
- var model = new GeneralAnalysisModel.TwoPhaseScaleModel();
- if (comboBox1.SelectedIndex != -1)
- {
- model.parameter1 = comboBox1.SelectedItem.ToString();
- }
- if (comboBox2.SelectedIndex != -1)
- {
- model.parameter2 = comboBox2.SelectedItem.ToString();
- }
- model.parameter3 = (int)numericUpDown1.Value;
- model.parameter4 = (int)numericUpDown2.Value;
- model.parameter5 = panel1.BackColor.ToArgb();
- model.parameter6 = panel2.BackColor.ToArgb();
- if (everyImgData.ContainsKey(this.selectedImg))
- {
- everyImgData[this.selectedImg] = model;
- }
- else
- {
- everyImgData.Add(this.selectedImg, model);
- }
- #endregion
- }
- this.imageMat = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].CompositionSurface.CreatedAliasedMat();
- Document document = Document.FromImageMat(imageMat.Clone());
- this.documentWorkspace.Document = document;
- this.documentWorkspace.Visible = true;
- this.documentWorkspace.GraphicsList = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].GraphicsList;
- this.documentWorkspace.phaseModels = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].PhaseModelsForCopy;
- if (this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].phaseModels.Count == 0)
- {
- System.Windows.Forms.MessageBox.Show(PdnResources.GetString("Menu.enophasesavailableforanalysi.text"));
- //return;
- }
- comboBox1.Items.Clear();
- comboBox1.Text = "";
- comboBox1.SelectedIndex = -1;
- comboBox2.SelectedIndex = -1;
- onePhase.mat = null;
- documentWorkspace.phaseModels.RemoveAll(u => u.name == "one");
- for (int i = 0; i < this.documentWorkspace.phaseModels.Count; i++)
- {
- comboBox1.Items.Add(this.documentWorkspace.phaseModels[i].name);
- }
- #region [设置参数]
- this.selectedImg = this.listView1.FocusedItem.Name;
- if (everyImgData.ContainsKey(selectedImg))
- {
- var model = everyImgData[selectedImg];
- if (this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].phaseModels.Count != 0)
- {
- if (!string.IsNullOrEmpty(model.parameter1))
- {
- comboBox1.SelectedItem = model.parameter1;
- comboBox1_SelectedIndexChanged(sender, e);
- }
- if (!string.IsNullOrEmpty(model.parameter2))
- {
- comboBox2.SelectedItem = model.parameter2;
- }
- //numericUpDown1.Value = model.parameter3;
- //numericUpDown2.Value = model.parameter4;
- //trackBar1.Value = (int)model.parameter3;
- //trackBar2.Value = (int)model.parameter4;
- if (numericUpDown1.Minimum > model.parameter3 || numericUpDown1.Maximum < model.parameter3)
- {
- numericUpDown1.Value = 0;
- }
- else
- {
- numericUpDown1.Value = model.parameter3;
- }
- if (numericUpDown2.Minimum > model.parameter4 || numericUpDown2.Maximum < model.parameter4)
- {
- numericUpDown2.Value = 0;
- }
- else
- {
- numericUpDown2.Value = model.parameter4;
- }
- if (trackBar1.Minimum > model.parameter3 || trackBar1.Maximum < model.parameter3)
- {
- trackBar1.Value = 0;
- }
- else
- {
- trackBar1.Value = (int)model.parameter3;
- }
- if (trackBar2.Minimum > model.parameter4 || trackBar2.Maximum < model.parameter4)
- {
- trackBar2.Value = 0;
- }
- else
- {
- trackBar2.Value = (int)model.parameter4;
- }
- panel1.BackColor = model.parameter5 == 0 ? Color.Red : Color.FromArgb(model.parameter5);
- panel2.BackColor = model.parameter5 == 0 ? Color.Yellow : Color.FromArgb(model.parameter6);
- }
- numericUpDown3.Value = model.parameter7;
- checkBox1.Checked = model.parameter8;
- if (comboBox1.SelectedIndex != -1 && comboBox2.SelectedIndex != -1)
- {
- GetAreaBetweenMinToMax(model.parameter3, model.parameter4, this.documentWorkspace.phaseModels[selectIndex].mat);
- }
- UpdateUI();
- }
- else {
- InitUI();
- }
- #endregion
- Init();
- }
- }
- }
- private void UpdateUI()
- {
- //double pxPerUnit = Startup.instance.rules[MeasurementUnit.Micron];
- double pxPerUnit = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].GetRuler(MeasurementUnit.Micron);
- this.txt_SelectCount.Text = selectResults.Count.ToString();
- this.txt_SelectArea.Text = (AnalysisTools.GetDecNum(selectResults.Area, decnum)).ToString();
- this.txt_SelectCountPersent.Text = AnalysisTools.GetDecNum(selectResults.CountPercent, decnum) + " %";
- this.txt_SelectContent.Text = AnalysisTools.GetDecNum(selectResults.Content, decnum) + " %";
- this.txt_SelectContentFromAll.Text = AnalysisTools.GetDecNum(selectResults.ContentFromAll, decnum) + " %";
- this.txt_SelectCountDivUnSelect.Text = AnalysisTools.GetDecNum(selectResults.CountScaleU, decnum) + " %";
- this.txt_UnSelectCount.Text = unSelectResults.Count.ToString();
- this.txt_UnSelectArea.Text = (AnalysisTools.GetDecNum(unSelectResults.Area, decnum)).ToString();
- this.txt_UnSelectCountPersent.Text = AnalysisTools.GetDecNum(unSelectResults.CountPercent, decnum) + " %";
- this.txt_UnSelectCountFromAll.Text = AnalysisTools.GetDecNum(unSelectResults.ContentFromAll, decnum) + " %";
- this.txt_UnSelectContent.Text = AnalysisTools.GetDecNum(unSelectResults.Content, decnum) + " %";
- this.txt_UnSelectDivSelectCount.Text = AnalysisTools.GetDecNum(unSelectResults.CountScaleU, decnum) + " %";
- }
- private void InitUI()
- {
- this.txt_SelectCount.Text = PdnResources.GetString("Menu.Nottochoose.text");
- this.txt_SelectArea.Text = PdnResources.GetString("Menu.Nottochoose.text");
- this.txt_SelectCountPersent.Text = PdnResources.GetString("Menu.Nottochoose.text");
- this.txt_SelectContent.Text = PdnResources.GetString("Menu.Nottochoose.text");
- this.txt_SelectContentFromAll.Text = PdnResources.GetString("Menu.Nottochoose.text");
- this.txt_SelectCountDivUnSelect.Text = PdnResources.GetString("Menu.Nottochoose.text");
- this.txt_UnSelectCount.Text = PdnResources.GetString("Menu.Nottochoose.text");
- this.txt_UnSelectArea.Text = PdnResources.GetString("Menu.Nottochoose.text");
- this.txt_UnSelectCountPersent.Text = PdnResources.GetString("Menu.Nottochoose.text");
- this.txt_UnSelectCountFromAll.Text = PdnResources.GetString("Menu.Nottochoose.text");
- this.txt_UnSelectContent.Text = PdnResources.GetString("Menu.Nottochoose.text");
- this.txt_UnSelectDivSelectCount.Text = PdnResources.GetString("Menu.Nottochoose.text");
- }
- private void GetAreaBetweenMinToMax(decimal areaMin, decimal areaMax, Mat pMat)
- {
- if (onePhase.mat == null)
- {
- System.Windows.MessageBox.Show(PdnResources.GetString("Menu.Nooperationalphasefound.text"));
- return;
- }
- List<Point[]> oneContours = new List<Point[]>();
- List<Point[]> twoContours = new List<Point[]>();
- Mat mat = Mat.FromImageData(pMat.ToBytes(), ImreadModes.Grayscale);
- HierarchyIndex[] hierarchy;
- OpenCvSharp.Point[][] contours;
- Cv2.FindContours(mat, out contours, out hierarchy, RetrievalModes.External, ContourApproximationModes.ApproxNone);
- int amount = contours.Length;
- //double pxPerUnit = Startup.instance.rules[MeasurementUnit.Micron];
- double pxPerUnit = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].GetRuler(MeasurementUnit.Micron);
- #region [获取总面积]
- int allArea = 0;
- if (this.documentWorkspace.GraphicsList.IsExsitView())
- {
- for (int i = 0; i < this.documentWorkspace.GraphicsList.Count; i++)
- {
- switch (this.documentWorkspace.GraphicsList[i].drawToolType)
- {
- case DrawToolType.ViewOval:
- allArea = (int)(Math.PI * this.documentWorkspace.GraphicsList[i].Rectangle.Width * this.documentWorkspace.GraphicsList[i].Rectangle.Height);
- break;
- case DrawToolType.ViewCircle:
- allArea = (int)(Math.PI * (this.documentWorkspace.GraphicsList[i].Rectangle.Width * this.documentWorkspace.GraphicsList[i].Rectangle.Height * 0.25));
- break;
- case DrawToolType.ViewRectangle:
- allArea = (int)(this.documentWorkspace.GraphicsList[i].Rectangle.Width * this.documentWorkspace.GraphicsList[i].Rectangle.Height);
- break;
- case DrawToolType.ViewTriangle:
- allArea = (int)(0.5 * this.documentWorkspace.GraphicsList[i].Rectangle.Width * this.documentWorkspace.GraphicsList[i].Rectangle.Height);
- break;
- case DrawToolType.ViewSquare:
- allArea = (int)(this.documentWorkspace.GraphicsList[i].Rectangle.Width * this.documentWorkspace.GraphicsList[i].Rectangle.Height);
- break;
- case DrawToolType.ViewRectangleEx:
- case DrawToolType.ViewPolygon:
- case DrawToolType.ViewTriangleEx:
- for (int k = 0; k < this.documentWorkspace.GraphicsList[i].Rectangle.Height; k++)
- {
- for (int j = 0; j < this.documentWorkspace.GraphicsList[i].Rectangle.Width; j++)
- {
- allArea += 1;
- }
- }
- break;
- }
- }
- }
- else
- {
- allArea = (int)(mat.Height * mat.Width);
- }
- allArea = (int)(allArea * pxPerUnit * pxPerUnit);
- #endregion
- int selectCount = 0;
- double areaAmount = 0;
- double selectAreaAmount = 0;
- List<Int32> areaList = new List<int>();
- selectResults = new TwoPhaseScaleResult();
- unSelectResults = new TwoPhaseScaleResult();
- switch (workType)
- {
- case 1://面积过滤
- for (int i = 0; i < contours.Length; i++)
- {
- double area = (Cv2.FloodFill(mat, contours[i][0], new Scalar(0, 0, 0, 0))) * pxPerUnit * pxPerUnit;
- areaAmount += area;
- if ((decimal)area >= areaMin && (decimal)area <= areaMax)
- {
- selectCount++;
- selectAreaAmount += area;
- oneContours.Add(contours[i]);
- }
- else
- {
- twoContours.Add(contours[i]);
- }
- }
- break;
- case 2://面积比
- Point2f center;
- for (int i = 0; i < contours.Length; i++)
- {
- double area = (Cv2.FloodFill(mat, contours[i][0], new Scalar(0, 0, 0, 0)));
- float radius;
- Cv2.MinEnclosingCircle(contours[i], out center, out radius);
- double areaPercent = area / (Math.PI * radius * radius);
- area = (int)(area * pxPerUnit * pxPerUnit);
- areaAmount += area;
- if (areaPercent >= Convert.ToSingle(areaMin) && areaPercent <= Convert.ToSingle(areaMax))
- {
- selectCount++;
- selectAreaAmount += area;
- oneContours.Add(contours[i]);
- }
- else
- {
- twoContours.Add(contours[i]);
- }
- }
- break;
- case 3: //周长
- for (int i = 0; i < contours.Length; i++)
- {
- int p = (int)(contours[i].Length * pxPerUnit);
- double area = (Cv2.FloodFill(mat, contours[i][0], new Scalar(0, 0, 0, 0))) * pxPerUnit * pxPerUnit;
- areaAmount += area;
- if (p >= Convert.ToSingle(areaMin) && p <= Convert.ToSingle(areaMax))
- {
- selectCount++;
- selectAreaAmount += area;
- oneContours.Add(contours[i]);
- }
- else
- {
- twoContours.Add(contours[i]);
- }
- }
- break;
- case 4: // 长轴
- for (int i = 0; i < contours.Length; i++)
- {
- RotatedRect ellipsemege = Cv2.MinAreaRect(contours[i]);
- double width = ellipsemege.Size.Width > ellipsemege.Size.Height ? ellipsemege.Size.Width * pxPerUnit : ellipsemege.Size.Height * pxPerUnit;
- double area = (Cv2.FloodFill(mat, contours[i][0], new Scalar(0, 0, 0, 0))) * pxPerUnit * pxPerUnit;
- areaAmount += area;
- if (width >= Convert.ToSingle(areaMin) && width <= Convert.ToSingle(areaMax))
- {
- selectCount++;
- selectAreaAmount += area;
- oneContours.Add(contours[i]);
- }
- else
- {
- twoContours.Add(contours[i]);
- }
- }
- break;
- case 5: // 短轴
- for (int i = 0; i < contours.Length; i++)
- {
- RotatedRect ellipsemege = Cv2.MinAreaRect(contours[i]);
- double width = ellipsemege.Size.Width < ellipsemege.Size.Height ? ellipsemege.Size.Width * pxPerUnit : ellipsemege.Size.Height * pxPerUnit;
- double area = (Cv2.FloodFill(mat, contours[i][0], new Scalar(0, 0, 0, 0))) * pxPerUnit * pxPerUnit;
- areaAmount += area;
- if (width >= Convert.ToSingle(areaMin) && width <= Convert.ToSingle(areaMax))
- {
- selectCount++;
- selectAreaAmount += area;
- oneContours.Add(contours[i]);
- }
- else
- {
- twoContours.Add(contours[i]);
- }
- }
- break;
- case 6: // 倾斜角度
- for (int i = 0; i < contours.Length; i++)
- {
- if (contours[i].Count() < 5)
- {
- continue;
- }
- RotatedRect ellipsemege = Cv2.FitEllipse(contours[i]);
- float width = ellipsemege.Angle;
- double area = (Cv2.FloodFill(mat, contours[i][0], new Scalar(0, 0, 0, 0))) * pxPerUnit * pxPerUnit;
- areaAmount += area;
- if (width >= Convert.ToSingle(areaMin) && width <= Convert.ToSingle(areaMax))
- {
- selectCount++;
- selectAreaAmount += area;
- oneContours.Add(contours[i]);
- }
- else
- {
- twoContours.Add(contours[i]);
- }
- }
- break;
- case 7: // 高度
- for (int i = 0; i < contours.Length; i++)
- {
- Rect ellipsemege = Cv2.BoundingRect(contours[i]);
- double width = ellipsemege.Size.Height * pxPerUnit;
- double area = (Cv2.FloodFill(mat, contours[i][0], new Scalar(0, 0, 0, 0))) * pxPerUnit * pxPerUnit;
- areaAmount += area;
- if (width >= Convert.ToSingle(areaMin) && width <= Convert.ToSingle(areaMax))
- {
- selectCount++;
- selectAreaAmount += area;
- oneContours.Add(contours[i]);
- }
- else
- {
- twoContours.Add(contours[i]);
- }
- }
- break;
- case 8:// 宽度
- for (int i = 0; i < contours.Length; i++)
- {
- Rect ellipsemege = Cv2.BoundingRect(contours[i]);
- double width = ellipsemege.Size.Width * pxPerUnit;
- double area = (Cv2.FloodFill(mat, contours[i][0], new Scalar(0, 0, 0, 0))) * pxPerUnit * pxPerUnit;
- areaAmount += area;
- if (width >= Convert.ToSingle(areaMin) && width <= Convert.ToSingle(areaMax))
- {
- selectCount++;
- selectAreaAmount += area;
- oneContours.Add(contours[i]);
- }
- else
- {
- twoContours.Add(contours[i]);
- }
- }
- break;
- case 9://长宽比
- for (int i = 0; i < contours.Length; i++)
- {
- double area = (Cv2.FloodFill(mat, contours[i][0], new Scalar(0, 0, 0, 0))) * pxPerUnit * pxPerUnit;
- areaAmount += area;
- Rect rect = Cv2.BoundingRect(contours[i]);
- decimal ckb = (decimal)(rect.Width / rect.Height);
- if (ckb >= areaMin && ckb <= areaMax)
- {
- selectCount++;
- selectAreaAmount += area;
- oneContours.Add(contours[i]);
- }
- else
- {
- twoContours.Add(contours[i]);
- }
- }
- break;
- case 10: // 长径
- for (int i = 0; i < contours.Length; i++)
- {
- RotatedRect ellipsemege = Cv2.MinAreaRect(contours[i]);
- double width = ellipsemege.Size.Width > ellipsemege.Size.Height ? ellipsemege.Size.Width * 0.5 * pxPerUnit : ellipsemege.Size.Height * 0.5 * pxPerUnit;
- double area = (Cv2.FloodFill(mat, contours[i][0], new Scalar(0, 0, 0, 0))) * pxPerUnit * pxPerUnit;
- areaAmount += area;
- if (width >= Convert.ToSingle(areaMin) && width <= Convert.ToSingle(areaMax))
- {
- selectCount++;
- selectAreaAmount += area;
- oneContours.Add(contours[i]);
- }
- else
- {
- twoContours.Add(contours[i]);
- }
- }
- break;
- case 11: // 短径
- for (int i = 0; i < contours.Length; i++)
- {
- RotatedRect ellipsemege = Cv2.MinAreaRect(contours[i]);
- double width = ellipsemege.Size.Width < ellipsemege.Size.Height ? ellipsemege.Size.Width * 0.5 * pxPerUnit : ellipsemege.Size.Height * 0.5 * pxPerUnit;
- double area = (Cv2.FloodFill(mat, contours[i][0], new Scalar(0, 0, 0, 0))) * pxPerUnit * pxPerUnit;
- areaAmount += area;
- if (width >= Convert.ToSingle(areaMin) && width <= Convert.ToSingle(areaMax))
- {
- selectCount++;
- selectAreaAmount += area;
- oneContours.Add(contours[i]);
- }
- else
- {
- twoContours.Add(contours[i]);
- }
- }
- break;
- case 12: // 外接圆直径
- Point2f point;
- for (int i = 0; i < contours.Length; i++)
- {
- float radius;
- Cv2.MinEnclosingCircle(contours[i], out point, out radius);
- double width = radius * 2 * pxPerUnit;
- double area = (Cv2.FloodFill(mat, contours[i][0], new Scalar(0, 0, 0, 0))) * pxPerUnit * pxPerUnit;
- areaAmount += area;
- if (width >= Convert.ToSingle(areaMin) && width <= Convert.ToSingle(areaMax))
- {
- selectCount++;
- selectAreaAmount += area;
- oneContours.Add(contours[i]);
- }
- else
- {
- twoContours.Add(contours[i]);
- }
- }
- break;
- case 13: // 球化率
- Point2f pointF;
- for (int i = 0; i < contours.Length; i++)
- {
- double area = (Cv2.FloodFill(mat, contours[i][0], new Scalar(0, 0, 0, 0)));
- areaAmount += area;
- float radius;
- Cv2.MinEnclosingCircle(contours[i], out pointF, out radius);
- double width = (area / (Math.PI * radius * radius));
- area = (Cv2.ContourArea(contours[i]) * pxPerUnit * pxPerUnit);
- areaAmount += area;
- if (width >= Convert.ToSingle(areaMin) && width <= Convert.ToSingle(areaMax))
- {
- selectCount++;
- selectAreaAmount += area;
- oneContours.Add(contours[i]);
- }
- else
- {
- twoContours.Add(contours[i]);
- }
- }
- break;
- case 14: // 等积圆直径
- for (int i = 0; i < contours.Length; i++)
- {
- double area = (Cv2.FloodFill(mat, contours[i][0], new Scalar(0, 0, 0, 0))) * pxPerUnit * pxPerUnit;
- areaAmount += area;
- var width = (Math.Sqrt(area / Math.PI) * 2);
- if (width >= Convert.ToSingle(areaMin) && width <= Convert.ToSingle(areaMax))
- {
- selectCount++;
- selectAreaAmount += area;
- oneContours.Add(contours[i]);
- }
- else
- {
- twoContours.Add(contours[i]);
- }
- }
- break;
- case 15://最大卡规直径
- for (int i = 0; i < contours.Length; i++)
- {
- double area = (Cv2.FloodFill(mat, contours[i][0], new Scalar(0, 0, 0, 0))) * pxPerUnit * pxPerUnit;
- areaAmount += area;
- List<int> vs = BasicCalculationHelper.GetCaliperDiameter(contours[i], hierarchy[i], out points);
- decimal diam = (decimal)(vs.Max() * pxPerUnit);
- if (diam >= areaMin && diam <= areaMax)
- {
- selectCount++;
- selectAreaAmount += area;
- oneContours.Add(contours[i]);
- }
- else
- {
- twoContours.Add(contours[i]);
- }
- }
- break;
- case 16://最小卡规直径
- for (int i = 0; i < contours.Length; i++)
- {
- double area = (Cv2.FloodFill(mat, contours[i][0], new Scalar(0, 0, 0, 0))) * pxPerUnit * pxPerUnit;
- areaAmount += area;
- List<int> vs = BasicCalculationHelper.GetCaliperDiameter(contours[i], hierarchy[i], out points);
- decimal diam = (decimal)(vs.Min() * pxPerUnit);
- if (diam >= areaMin && diam <= areaMax)
- {
- selectCount++;
- selectAreaAmount += area;
- oneContours.Add(contours[i]);
- }
- else
- {
- twoContours.Add(contours[i]);
- }
- }
- break;
- case 17://平均卡规直径
- for (int i = 0; i < contours.Length; i++)
- {
- double area = (Cv2.FloodFill(mat, contours[i][0], new Scalar(0, 0, 0, 0))) * pxPerUnit * pxPerUnit;
- areaAmount += area;
- List<int> vs = BasicCalculationHelper.GetCaliperDiameter(contours[i], hierarchy[i], out points);
- decimal diam = (decimal)(vs.Average() * pxPerUnit);
- if (diam >= areaMin && diam <= areaMax)
- {
- selectCount++;
- selectAreaAmount += area;
- oneContours.Add(contours[i]);
- }
- else
- {
- twoContours.Add(contours[i]);
- }
- }
- break;
- case 18: // 纤维长度
- for (int i = 0; i < contours.Length; i++)
- {
- double area = (Cv2.FloodFill(mat, contours[i][0], new Scalar(0, 0, 0, 0)));
- var width = ((contours[i].Length + Math.Sqrt(contours[i].Length * contours[i].Length + 16 * area)) / 4) * pxPerUnit;
- area = (int)(area * pxPerUnit * pxPerUnit);
- areaAmount += area;
- if (width >= Convert.ToSingle(areaMin) && width <= Convert.ToSingle(areaMax))
- {
- selectCount++;
- selectAreaAmount += area;
- oneContours.Add(contours[i]);
- }
- else
- {
- twoContours.Add(contours[i]);
- }
- }
- break;
- }
- Cv2.DrawContours(onePhase.mat, oneContours, -1, new Scalar(panel1.BackColor.B, panel1.BackColor.G, panel1.BackColor.R, 255), Cv2.FILLED);
- Cv2.DrawContours(onePhase.mat, twoContours, -1, new Scalar(panel2.BackColor.B, panel2.BackColor.G, panel2.BackColor.R, 255), Cv2.FILLED);
- documentWorkspace.Refresh();
- if (areaMax == 0)
- {
- selectResults.Count = 0;
- }
- else
- {
- selectResults.Count = selectCount;
- }
- unSelectResults.Count = (contours.Length - selectCount);
- selectResults.Area = selectAreaAmount;
- unSelectResults.Area = areaAmount - selectAreaAmount;
- if (unSelectResults.Area < 0)
- {
- unSelectResults.Area = 0;
- }
- if (contours.Length > 0)
- {
- selectResults.CountPercent = ((Single)selectCount / contours.Length) * 100;
- }
- else
- {
- selectResults.CountPercent = 0;
- }
- if (contours.Length > 0)
- {
- unSelectResults.CountPercent = ((Single)unSelectResults.Count / contours.Length) * 100;
- }
- else
- {
- unSelectResults.CountPercent = 0;
- }
- if (allArea > 0)
- {
- selectResults.Content = ((Single)selectAreaAmount / allArea) * 100;
- }
- else
- {
- selectResults.Content = 0;
- }
- if (allArea > 0)
- {
- unSelectResults.Content = ((Single)unSelectResults.Area / allArea) * 100;
- }
- else
- {
- unSelectResults.Content = 0;
- }
- if (contours.Length > 0)
- {
- selectResults.ContentFromAll = (float)(((Single)selectAreaAmount / areaAmount) * 100);
- }
- else
- {
- selectResults.ContentFromAll = 0;
- }
- if (contours.Length > 0)
- {
- unSelectResults.ContentFromAll = (float)((Single)unSelectResults.Area / areaAmount) * 100;
- }
- else
- {
- unSelectResults.ContentFromAll = 0;
- }
- if ((contours.Length - selectCount) > 0)
- {
- selectResults.CountScaleU = ((Single)selectCount / (contours.Length - selectCount)) * 100;
- }
- else
- {
- selectResults.CountScaleU = 0;
- }
- if (unSelectResults.Area > 0)
- {
- unSelectResults.CountScaleU = (float)((Single)selectAreaAmount / unSelectResults.Area) * 100;
- }
- else
- {
- unSelectResults.CountScaleU = 0;
- }
- UpdateUI();
- }
- private void InitializeLanguageText()
- {
- this.groupBox4.Text = PdnResources.GetString("Menu.Tools.ImageIndex.Text");
- this.groupBox1.Text = PdnResources.GetString("Menu.operation.text");
- this.button5.Text = PdnResources.GetString("Menu.File.Close.Text");
- this.button2.Text = PdnResources.GetString("Menu.Saveresult.text");
- this.checkBox1.Text = PdnResources.GetString("Menu.Opensettingsatingreport.text");
- this.button1.Text = PdnResources.GetString("Menu.Setting.Text");
- this.groupBox2.Text = PdnResources.GetString("Menu.Generalanalysis.Twportion.Phasesetting.text");
- this.label20.Text = PdnResources.GetString("Menu.Generalanalysis.Twportion.Particle2color.text");
- this.label19.Text = PdnResources.GetString("Menu.Generalanalysis.Twportion.Particle1color.text");
- this.label18.Text = PdnResources.GetString("Menu.max.text");
- this.label17.Text = PdnResources.GetString("Menu.minimum.text");
- this.label4.Text = PdnResources.GetString("Menu.max.text");
- this.label3.Text = PdnResources.GetString("Menu.minimum.text");
- this.label2.Text = PdnResources.GetString("Menu.Generalanalysis.Twportion.Selectphase.text");
- this.groupBox_review.Text = PdnResources.GetString("Menu.Preview.text");
- this.groupBox5.Text = PdnResources.GetString("Menu.Analysisresult.text");
- this.button_remove.Text = PdnResources.GetString("Menu.Edit.Delete.Text");
- this.button_all.Text = PdnResources.GetString("Menu.Showall.text");
- this.Column12.HeaderText = PdnResources.GetString("Menu.Generalanalysis.Twportion.imagename.text");
- this.button9.Text = PdnResources.GetString("Menu.Tools.OpenProject.Text");
- this.label1.Text = PdnResources.GetString("Menu.Decimal.text");
- this.button4.Text = PdnResources.GetString("Menu.Exportresults.text");
- this.button3.Text = PdnResources.GetString("Menu.Tools.CreateReport.Text");
- this.groupBox8.Text = PdnResources.GetString("Menu.Analysisresult.text");
- this.label16.Text = PdnResources.GetString("Menu.Generalanalysis.Twportion.Lparticle1/parea).text");
- this.label15.Text = PdnResources.GetString("Menu.Generalanalysis.Twportion.Kparticleumber).text");
- this.label14.Text = PdnResources.GetString("Menu.Generalanalysis.Twportion.Jparticle2rticle2)content.text");
- this.label13.Text = PdnResources.GetString("Menu.Generalanalysis.Twportion.Iparticle1/(ontent.text");
- this.label12.Text = PdnResources.GetString("Menu.Generalanalysis.Twportion.thecontentofHparticle2.text");
- this.label11.Text = PdnResources.GetString("Menu.Gparticle1content.text");
- this.label10.Text = PdnResources.GetString("Menu.Generalanalysis.Twportion.NumberofFparticles2%.text");
- this.label9.Text = PdnResources.GetString("Menu.Generalanalysis.Twportion.NumberofEparticles1%.text");
- this.label8.Text = PdnResources.GetString("Menu.Generalanalysis.Twportion.theareaofDparticle2.text");
- this.label7.Text = PdnResources.GetString("Menu.Generalanalysis.Twportion.ColumnAicles2.text");
- this.label6.Text = PdnResources.GetString("Menu.Generalanalysis.Twportion.theareaofCparticle1.text");
- this.label5.Text = PdnResources.GetString("Menu.Generalanalysis.Twportion.NumberofAparticles1.text");
- this.Text = PdnResources.GetString("Menu.GeneralAnalysis.TwoComparisonCases.Text");
- this.label21.Text = PdnResources.GetString("Menu.Binaryoperation.Removedebris.filtermethod.text");
- }
- #region InitializeComponent
- private void InitializeComponent()
- {
- this.components = new System.ComponentModel.Container();
- this.groupBox4 = new System.Windows.Forms.GroupBox();
- this.listView1 = new System.Windows.Forms.ListView();
- this.imageList1 = new System.Windows.Forms.ImageList(this.components);
- this.groupBox1 = new System.Windows.Forms.GroupBox();
- this.button5 = new System.Windows.Forms.Button();
- this.button2 = new System.Windows.Forms.Button();
- this.checkBox1 = new System.Windows.Forms.CheckBox();
- this.button1 = new System.Windows.Forms.Button();
- this.groupBox_review = new System.Windows.Forms.GroupBox();
- this.groupBox5 = new System.Windows.Forms.GroupBox();
- this.listBox_analysisResult = new System.Windows.Forms.CheckedListBox();
- this.button_remove = new System.Windows.Forms.Button();
- this.button_all = new System.Windows.Forms.Button();
- this.groupBox6 = new System.Windows.Forms.GroupBox();
- this.dataGridView_results = new System.Windows.Forms.DataGridView();
- this.Column12 = new System.Windows.Forms.DataGridViewTextBoxColumn();
- this.Column1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
- this.Column2 = new System.Windows.Forms.DataGridViewTextBoxColumn();
- this.Column3 = new System.Windows.Forms.DataGridViewTextBoxColumn();
- this.Column4 = new System.Windows.Forms.DataGridViewTextBoxColumn();
- this.Column5 = new System.Windows.Forms.DataGridViewTextBoxColumn();
- this.Column6 = new System.Windows.Forms.DataGridViewTextBoxColumn();
- this.Column7 = new System.Windows.Forms.DataGridViewTextBoxColumn();
- this.Column8 = new System.Windows.Forms.DataGridViewTextBoxColumn();
- this.Column9 = new System.Windows.Forms.DataGridViewTextBoxColumn();
- this.Column10 = new System.Windows.Forms.DataGridViewTextBoxColumn();
- this.Column11 = new System.Windows.Forms.DataGridViewTextBoxColumn();
- this.Column13 = new System.Windows.Forms.DataGridViewTextBoxColumn();
- this.groupBox7 = new System.Windows.Forms.GroupBox();
- this.button9 = new System.Windows.Forms.Button();
- this.numericUpDown3 = new System.Windows.Forms.NumericUpDown();
- this.label1 = new System.Windows.Forms.Label();
- this.button4 = new System.Windows.Forms.Button();
- this.button3 = new System.Windows.Forms.Button();
- this.groupBox8 = new System.Windows.Forms.GroupBox();
- this.txt_UnSelectDivSelectCount = new System.Windows.Forms.TextBox();
- this.txt_SelectCountDivUnSelect = new System.Windows.Forms.TextBox();
- this.label16 = new System.Windows.Forms.Label();
- this.label15 = new System.Windows.Forms.Label();
- this.txt_UnSelectCountFromAll = new System.Windows.Forms.TextBox();
- this.txt_SelectContentFromAll = new System.Windows.Forms.TextBox();
- this.label14 = new System.Windows.Forms.Label();
- this.label13 = new System.Windows.Forms.Label();
- this.txt_UnSelectContent = new System.Windows.Forms.TextBox();
- this.txt_SelectContent = new System.Windows.Forms.TextBox();
- this.label12 = new System.Windows.Forms.Label();
- this.label11 = new System.Windows.Forms.Label();
- this.txt_UnSelectCountPersent = new System.Windows.Forms.TextBox();
- this.label10 = new System.Windows.Forms.Label();
- this.txt_UnSelectArea = new System.Windows.Forms.TextBox();
- this.txt_UnSelectCount = new System.Windows.Forms.TextBox();
- this.txt_SelectCountPersent = new System.Windows.Forms.TextBox();
- this.txt_SelectArea = new System.Windows.Forms.TextBox();
- this.txt_SelectCount = new System.Windows.Forms.TextBox();
- this.label9 = new System.Windows.Forms.Label();
- this.label8 = new System.Windows.Forms.Label();
- this.label7 = new System.Windows.Forms.Label();
- this.label6 = new System.Windows.Forms.Label();
- this.label5 = new System.Windows.Forms.Label();
- this.label2 = new System.Windows.Forms.Label();
- this.label3 = new System.Windows.Forms.Label();
- this.label4 = new System.Windows.Forms.Label();
- this.numericUpDown1 = new System.Windows.Forms.NumericUpDown();
- this.numericUpDown2 = new System.Windows.Forms.NumericUpDown();
- this.comboBox1 = new System.Windows.Forms.ComboBox();
- this.label17 = new System.Windows.Forms.Label();
- this.label18 = new System.Windows.Forms.Label();
- this.trackBar2 = new PaintDotNet.CustomControl.TriangleTrackBar();
- this.trackBar1 = new PaintDotNet.CustomControl.TriangleTrackBar();
- this.label19 = new System.Windows.Forms.Label();
- this.label20 = new System.Windows.Forms.Label();
- this.panel1 = new System.Windows.Forms.Panel();
- this.panel2 = new System.Windows.Forms.Panel();
- this.comboBox2 = new System.Windows.Forms.ComboBox();
- this.groupBox2 = new System.Windows.Forms.GroupBox();
- this.label21 = new System.Windows.Forms.Label();
- this.groupBox4.SuspendLayout();
- this.groupBox1.SuspendLayout();
- this.groupBox5.SuspendLayout();
- this.groupBox6.SuspendLayout();
- ((System.ComponentModel.ISupportInitialize)(this.dataGridView_results)).BeginInit();
- this.groupBox7.SuspendLayout();
- ((System.ComponentModel.ISupportInitialize)(this.numericUpDown3)).BeginInit();
- this.groupBox8.SuspendLayout();
- ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).BeginInit();
- ((System.ComponentModel.ISupportInitialize)(this.numericUpDown2)).BeginInit();
- this.groupBox2.SuspendLayout();
- this.SuspendLayout();
- //
- // groupBox4
- //
- this.groupBox4.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
- | System.Windows.Forms.AnchorStyles.Left)));
- this.groupBox4.Controls.Add(this.listView1);
- this.groupBox4.Location = new System.Drawing.Point(13, 72);
- this.groupBox4.Margin = new System.Windows.Forms.Padding(4);
- this.groupBox4.Name = "groupBox4";
- this.groupBox4.Padding = new System.Windows.Forms.Padding(4);
- this.groupBox4.Size = new System.Drawing.Size(158, 483);
- this.groupBox4.TabIndex = 9;
- this.groupBox4.TabStop = false;
- this.groupBox4.Text = "图像索引";
- //
- // listView1
- //
- this.listView1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
- | System.Windows.Forms.AnchorStyles.Left)
- | System.Windows.Forms.AnchorStyles.Right)));
- this.listView1.HideSelection = false;
- this.listView1.LargeImageList = this.imageList1;
- this.listView1.Location = new System.Drawing.Point(8, 26);
- this.listView1.Margin = new System.Windows.Forms.Padding(4);
- this.listView1.MultiSelect = false;
- this.listView1.Name = "listView1";
- this.listView1.Size = new System.Drawing.Size(140, 449);
- this.listView1.TabIndex = 0;
- this.listView1.UseCompatibleStateImageBehavior = false;
- //
- // imageList1
- //
- this.imageList1.ColorDepth = System.Windows.Forms.ColorDepth.Depth8Bit;
- this.imageList1.ImageSize = new System.Drawing.Size(64, 64);
- this.imageList1.TransparentColor = System.Drawing.Color.Transparent;
- //
- // groupBox1
- //
- this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
- | System.Windows.Forms.AnchorStyles.Right)));
- this.groupBox1.Controls.Add(this.button5);
- this.groupBox1.Controls.Add(this.button2);
- this.groupBox1.Controls.Add(this.checkBox1);
- this.groupBox1.Controls.Add(this.button1);
- this.groupBox1.Location = new System.Drawing.Point(20, 12);
- this.groupBox1.Name = "groupBox1";
- this.groupBox1.Size = new System.Drawing.Size(1145, 53);
- this.groupBox1.TabIndex = 10;
- this.groupBox1.TabStop = false;
- this.groupBox1.Text = "操作";
- //
- // button5
- //
- this.button5.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
- this.button5.Location = new System.Drawing.Point(972, 21);
- this.button5.Name = "button5";
- this.button5.Size = new System.Drawing.Size(75, 23);
- this.button5.TabIndex = 3;
- this.button5.Text = "关闭";
- this.button5.UseVisualStyleBackColor = true;
- this.button5.Click += new System.EventHandler(this.button5_Click);
- //
- // button2
- //
- this.button2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
- this.button2.Location = new System.Drawing.Point(1053, 21);
- this.button2.Name = "button2";
- this.button2.Size = new System.Drawing.Size(75, 23);
- this.button2.TabIndex = 2;
- this.button2.Text = "保存结果";
- this.button2.UseVisualStyleBackColor = true;
- this.button2.Click += new System.EventHandler(this.button2_Click);
- //
- // checkBox1
- //
- this.checkBox1.AutoSize = true;
- this.checkBox1.Location = new System.Drawing.Point(98, 24);
- this.checkBox1.Name = "checkBox1";
- this.checkBox1.Size = new System.Drawing.Size(132, 16);
- this.checkBox1.TabIndex = 1;
- this.checkBox1.Text = "生成报告时打开设置";
- this.checkBox1.UseVisualStyleBackColor = true;
- //
- // button1
- //
- this.button1.Location = new System.Drawing.Point(6, 24);
- this.button1.Name = "button1";
- this.button1.Size = new System.Drawing.Size(75, 23);
- this.button1.TabIndex = 0;
- this.button1.Text = "设置";
- this.button1.UseVisualStyleBackColor = true;
- this.button1.Click += new System.EventHandler(this.button1_Click);
- //
- // groupBox_review
- //
- this.groupBox_review.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
- | System.Windows.Forms.AnchorStyles.Left)
- | System.Windows.Forms.AnchorStyles.Right)));
- this.groupBox_review.Location = new System.Drawing.Point(590, 72);
- this.groupBox_review.Name = "groupBox_review";
- this.groupBox_review.Size = new System.Drawing.Size(575, 483);
- this.groupBox_review.TabIndex = 12;
- this.groupBox_review.TabStop = false;
- this.groupBox_review.Text = "预览";
- //
- // groupBox5
- //
- this.groupBox5.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
- this.groupBox5.Controls.Add(this.listBox_analysisResult);
- this.groupBox5.Controls.Add(this.button_remove);
- this.groupBox5.Controls.Add(this.button_all);
- this.groupBox5.Location = new System.Drawing.Point(13, 567);
- this.groupBox5.Name = "groupBox5";
- this.groupBox5.Size = new System.Drawing.Size(224, 165);
- this.groupBox5.TabIndex = 13;
- this.groupBox5.TabStop = false;
- this.groupBox5.Text = "分析结果";
- //
- // listBox_analysisResult
- //
- this.listBox_analysisResult.CheckOnClick = true;
- this.listBox_analysisResult.FormattingEnabled = true;
- this.listBox_analysisResult.HorizontalScrollbar = true;
- this.listBox_analysisResult.Location = new System.Drawing.Point(11, 53);
- this.listBox_analysisResult.Name = "listBox_analysisResult";
- this.listBox_analysisResult.Size = new System.Drawing.Size(202, 100);
- this.listBox_analysisResult.TabIndex = 10;
- this.listBox_analysisResult.SelectedIndexChanged += new System.EventHandler(this.listBox_analysisResult_SelectedIndexChanged);
- //
- // button_remove
- //
- this.button_remove.Location = new System.Drawing.Point(130, 24);
- this.button_remove.Name = "button_remove";
- this.button_remove.Size = new System.Drawing.Size(75, 23);
- this.button_remove.TabIndex = 8;
- this.button_remove.Text = "删除";
- this.button_remove.UseVisualStyleBackColor = true;
- this.button_remove.Click += new System.EventHandler(this.button_remove_Click);
- //
- // button_all
- //
- this.button_all.Location = new System.Drawing.Point(14, 24);
- this.button_all.Name = "button_all";
- this.button_all.Size = new System.Drawing.Size(75, 23);
- this.button_all.TabIndex = 1;
- this.button_all.Text = "全部显示";
- this.button_all.UseVisualStyleBackColor = true;
- this.button_all.Click += new System.EventHandler(this.button_all_Click);
- //
- // groupBox6
- //
- this.groupBox6.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
- | System.Windows.Forms.AnchorStyles.Right)));
- this.groupBox6.Controls.Add(this.dataGridView_results);
- this.groupBox6.Location = new System.Drawing.Point(257, 562);
- this.groupBox6.Name = "groupBox6";
- this.groupBox6.Size = new System.Drawing.Size(678, 165);
- this.groupBox6.TabIndex = 14;
- this.groupBox6.TabStop = false;
- //
- // dataGridView_results
- //
- this.dataGridView_results.AllowUserToAddRows = false;
- this.dataGridView_results.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
- | System.Windows.Forms.AnchorStyles.Right)));
- this.dataGridView_results.BorderStyle = System.Windows.Forms.BorderStyle.None;
- this.dataGridView_results.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
- this.dataGridView_results.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
- this.Column12,
- this.Column1,
- this.Column2,
- this.Column3,
- this.Column4,
- this.Column5,
- this.Column6,
- this.Column7,
- this.Column8,
- this.Column9,
- this.Column10,
- this.Column11,
- this.Column13});
- this.dataGridView_results.Location = new System.Drawing.Point(16, 29);
- this.dataGridView_results.Name = "dataGridView_results";
- this.dataGridView_results.RowHeadersVisible = false;
- this.dataGridView_results.RowHeadersWidth = 51;
- this.dataGridView_results.RowTemplate.Height = 27;
- this.dataGridView_results.Size = new System.Drawing.Size(645, 130);
- this.dataGridView_results.TabIndex = 1;
- //
- // Column12
- //
- this.Column12.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
- this.Column12.HeaderText = "Column12";
- this.Column12.Name = "Column12";
- //
- // Column1
- //
- this.Column1.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
- this.Column1.HeaderText = "A";
- this.Column1.MinimumWidth = 49;
- this.Column1.Name = "Column1";
- //
- // Column2
- //
- this.Column2.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
- this.Column2.HeaderText = "B";
- this.Column2.MinimumWidth = 50;
- this.Column2.Name = "Column2";
- //
- // Column3
- //
- this.Column3.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
- this.Column3.HeaderText = "C";
- this.Column3.MinimumWidth = 49;
- this.Column3.Name = "Column3";
- //
- // Column4
- //
- this.Column4.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
- this.Column4.HeaderText = "D";
- this.Column4.MinimumWidth = 50;
- this.Column4.Name = "Column4";
- //
- // Column5
- //
- this.Column5.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
- this.Column5.HeaderText = "E";
- this.Column5.MinimumWidth = 49;
- this.Column5.Name = "Column5";
- //
- // Column6
- //
- this.Column6.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
- this.Column6.HeaderText = "F";
- this.Column6.MinimumWidth = 50;
- this.Column6.Name = "Column6";
- //
- // Column7
- //
- this.Column7.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
- this.Column7.HeaderText = "G";
- this.Column7.MinimumWidth = 49;
- this.Column7.Name = "Column7";
- //
- // Column8
- //
- this.Column8.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
- this.Column8.HeaderText = "H";
- this.Column8.MinimumWidth = 50;
- this.Column8.Name = "Column8";
- //
- // Column9
- //
- this.Column9.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
- this.Column9.HeaderText = "I";
- this.Column9.MinimumWidth = 49;
- this.Column9.Name = "Column9";
- //
- // Column10
- //
- this.Column10.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
- this.Column10.HeaderText = "J";
- this.Column10.MinimumWidth = 50;
- this.Column10.Name = "Column10";
- //
- // Column11
- //
- this.Column11.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
- this.Column11.HeaderText = "K";
- this.Column11.MinimumWidth = 49;
- this.Column11.Name = "Column11";
- //
- // Column13
- //
- this.Column13.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
- this.Column13.HeaderText = "L";
- this.Column13.MinimumWidth = 50;
- this.Column13.Name = "Column13";
- //
- // groupBox7
- //
- this.groupBox7.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
- this.groupBox7.Controls.Add(this.button9);
- this.groupBox7.Controls.Add(this.numericUpDown3);
- this.groupBox7.Controls.Add(this.label1);
- this.groupBox7.Controls.Add(this.button4);
- this.groupBox7.Controls.Add(this.button3);
- this.groupBox7.Location = new System.Drawing.Point(941, 562);
- this.groupBox7.Name = "groupBox7";
- this.groupBox7.Size = new System.Drawing.Size(224, 165);
- this.groupBox7.TabIndex = 15;
- this.groupBox7.TabStop = false;
- //
- // button9
- //
- this.button9.Location = new System.Drawing.Point(54, 88);
- this.button9.Name = "button9";
- this.button9.Size = new System.Drawing.Size(117, 23);
- this.button9.TabIndex = 10;
- this.button9.Text = "项目工程";
- this.button9.UseVisualStyleBackColor = true;
- this.button9.Click += new System.EventHandler(this.button9_Click);
- //
- // numericUpDown3
- //
- this.numericUpDown3.Location = new System.Drawing.Point(87, 124);
- this.numericUpDown3.Maximum = new decimal(new int[] {
- 10,
- 0,
- 0,
- 0});
- this.numericUpDown3.Name = "numericUpDown3";
- this.numericUpDown3.Size = new System.Drawing.Size(84, 21);
- this.numericUpDown3.TabIndex = 4;
- this.numericUpDown3.Value = new decimal(new int[] {
- 2,
- 0,
- 0,
- 0});
- this.numericUpDown3.ValueChanged += new System.EventHandler(this.numericUpDown3_ValueChanged);
- //
- // label1
- //
- this.label1.AutoSize = true;
- this.label1.Location = new System.Drawing.Point(52, 126);
- this.label1.Name = "label1";
- this.label1.Size = new System.Drawing.Size(0, 12);
- this.label1.TabIndex = 3;
- //
- // button4
- //
- this.button4.Location = new System.Drawing.Point(54, 54);
- this.button4.Name = "button4";
- this.button4.Size = new System.Drawing.Size(117, 23);
- this.button4.TabIndex = 1;
- this.button4.Text = "导出结果";
- this.button4.UseVisualStyleBackColor = true;
- this.button4.Click += new System.EventHandler(this.button4_Click);
- //
- // button3
- //
- this.button3.Location = new System.Drawing.Point(54, 20);
- this.button3.Name = "button3";
- this.button3.Size = new System.Drawing.Size(117, 23);
- this.button3.TabIndex = 0;
- this.button3.Text = "生成报告";
- this.button3.UseVisualStyleBackColor = true;
- this.button3.Click += new System.EventHandler(this.button3_Click);
- //
- // groupBox8
- //
- this.groupBox8.Controls.Add(this.txt_UnSelectDivSelectCount);
- this.groupBox8.Controls.Add(this.txt_SelectCountDivUnSelect);
- this.groupBox8.Controls.Add(this.label16);
- this.groupBox8.Controls.Add(this.label15);
- this.groupBox8.Controls.Add(this.txt_UnSelectCountFromAll);
- this.groupBox8.Controls.Add(this.txt_SelectContentFromAll);
- this.groupBox8.Controls.Add(this.label14);
- this.groupBox8.Controls.Add(this.label13);
- this.groupBox8.Controls.Add(this.txt_UnSelectContent);
- this.groupBox8.Controls.Add(this.txt_SelectContent);
- this.groupBox8.Controls.Add(this.label12);
- this.groupBox8.Controls.Add(this.label11);
- this.groupBox8.Controls.Add(this.txt_UnSelectCountPersent);
- this.groupBox8.Controls.Add(this.label10);
- this.groupBox8.Controls.Add(this.txt_UnSelectArea);
- this.groupBox8.Controls.Add(this.txt_UnSelectCount);
- this.groupBox8.Controls.Add(this.txt_SelectCountPersent);
- this.groupBox8.Controls.Add(this.txt_SelectArea);
- this.groupBox8.Controls.Add(this.txt_SelectCount);
- this.groupBox8.Controls.Add(this.label9);
- this.groupBox8.Controls.Add(this.label8);
- this.groupBox8.Controls.Add(this.label7);
- this.groupBox8.Controls.Add(this.label6);
- this.groupBox8.Controls.Add(this.label5);
- this.groupBox8.Enabled = false;
- this.groupBox8.Location = new System.Drawing.Point(178, 313);
- this.groupBox8.Name = "groupBox8";
- this.groupBox8.Size = new System.Drawing.Size(400, 243);
- this.groupBox8.TabIndex = 17;
- this.groupBox8.TabStop = false;
- this.groupBox8.Text = "分析结果";
- //
- // txt_UnSelectDivSelectCount
- //
- this.txt_UnSelectDivSelectCount.Location = new System.Drawing.Point(179, 216);
- this.txt_UnSelectDivSelectCount.Name = "txt_UnSelectDivSelectCount";
- this.txt_UnSelectDivSelectCount.Size = new System.Drawing.Size(66, 21);
- this.txt_UnSelectDivSelectCount.TabIndex = 23;
- //
- // txt_SelectCountDivUnSelect
- //
- this.txt_SelectCountDivUnSelect.Location = new System.Drawing.Point(179, 192);
- this.txt_SelectCountDivUnSelect.Name = "txt_SelectCountDivUnSelect";
- this.txt_SelectCountDivUnSelect.Size = new System.Drawing.Size(66, 21);
- this.txt_SelectCountDivUnSelect.TabIndex = 22;
- //
- // label16
- //
- this.label16.AutoSize = true;
- this.label16.Location = new System.Drawing.Point(19, 219);
- this.label16.Name = "label16";
- this.label16.Size = new System.Drawing.Size(113, 12);
- this.label16.TabIndex = 21;
- this.label16.Text = "L颗粒1/颗粒2(面积)";
- //
- // label15
- //
- this.label15.AutoSize = true;
- this.label15.Location = new System.Drawing.Point(19, 195);
- this.label15.Name = "label15";
- this.label15.Size = new System.Drawing.Size(113, 12);
- this.label15.TabIndex = 20;
- this.label15.Text = "K颗粒1/颗粒2(个数)";
- //
- // txt_UnSelectCountFromAll
- //
- this.txt_UnSelectCountFromAll.Location = new System.Drawing.Point(179, 165);
- this.txt_UnSelectCountFromAll.Name = "txt_UnSelectCountFromAll";
- this.txt_UnSelectCountFromAll.Size = new System.Drawing.Size(66, 21);
- this.txt_UnSelectCountFromAll.TabIndex = 19;
- //
- // txt_SelectContentFromAll
- //
- this.txt_SelectContentFromAll.Location = new System.Drawing.Point(179, 141);
- this.txt_SelectContentFromAll.Name = "txt_SelectContentFromAll";
- this.txt_SelectContentFromAll.Size = new System.Drawing.Size(66, 21);
- this.txt_SelectContentFromAll.TabIndex = 18;
- //
- // label14
- //
- this.label14.AutoSize = true;
- this.label14.Location = new System.Drawing.Point(19, 168);
- this.label14.Name = "label14";
- this.label14.Size = new System.Drawing.Size(155, 12);
- this.label14.TabIndex = 17;
- this.label14.Text = "J颗粒2/(颗粒1+颗粒2)含量%";
- //
- // label13
- //
- this.label13.AutoSize = true;
- this.label13.Location = new System.Drawing.Point(19, 144);
- this.label13.Name = "label13";
- this.label13.Size = new System.Drawing.Size(155, 12);
- this.label13.TabIndex = 16;
- this.label13.Text = "I颗粒1/(颗粒1+颗粒2)含量%";
- //
- // txt_UnSelectContent
- //
- this.txt_UnSelectContent.Location = new System.Drawing.Point(251, 114);
- this.txt_UnSelectContent.Name = "txt_UnSelectContent";
- this.txt_UnSelectContent.Size = new System.Drawing.Size(66, 21);
- this.txt_UnSelectContent.TabIndex = 15;
- //
- // txt_SelectContent
- //
- this.txt_SelectContent.Location = new System.Drawing.Point(95, 114);
- this.txt_SelectContent.Name = "txt_SelectContent";
- this.txt_SelectContent.Size = new System.Drawing.Size(66, 21);
- this.txt_SelectContent.TabIndex = 14;
- //
- // label12
- //
- this.label12.AutoSize = true;
- this.label12.Location = new System.Drawing.Point(180, 114);
- this.label12.Name = "label12";
- this.label12.Size = new System.Drawing.Size(71, 12);
- this.label12.TabIndex = 13;
- this.label12.Text = "H颗粒2含量%";
- //
- // label11
- //
- this.label11.AutoSize = true;
- this.label11.Location = new System.Drawing.Point(19, 114);
- this.label11.Name = "label11";
- this.label11.Size = new System.Drawing.Size(71, 12);
- this.label11.TabIndex = 12;
- this.label11.Text = "G颗粒1含量%";
- //
- // txt_UnSelectCountPersent
- //
- this.txt_UnSelectCountPersent.Location = new System.Drawing.Point(251, 83);
- this.txt_UnSelectCountPersent.Name = "txt_UnSelectCountPersent";
- this.txt_UnSelectCountPersent.Size = new System.Drawing.Size(66, 21);
- this.txt_UnSelectCountPersent.TabIndex = 11;
- //
- // label10
- //
- this.label10.AutoSize = true;
- this.label10.Location = new System.Drawing.Point(180, 85);
- this.label10.Name = "label10";
- this.label10.Size = new System.Drawing.Size(71, 12);
- this.label10.TabIndex = 10;
- this.label10.Text = "F颗粒2个数%";
- //
- // txt_UnSelectArea
- //
- this.txt_UnSelectArea.Location = new System.Drawing.Point(251, 56);
- this.txt_UnSelectArea.Name = "txt_UnSelectArea";
- this.txt_UnSelectArea.Size = new System.Drawing.Size(66, 21);
- this.txt_UnSelectArea.TabIndex = 9;
- //
- // txt_UnSelectCount
- //
- this.txt_UnSelectCount.Location = new System.Drawing.Point(251, 31);
- this.txt_UnSelectCount.Name = "txt_UnSelectCount";
- this.txt_UnSelectCount.Size = new System.Drawing.Size(66, 21);
- this.txt_UnSelectCount.TabIndex = 8;
- //
- // txt_SelectCountPersent
- //
- this.txt_SelectCountPersent.Location = new System.Drawing.Point(95, 82);
- this.txt_SelectCountPersent.Name = "txt_SelectCountPersent";
- this.txt_SelectCountPersent.Size = new System.Drawing.Size(66, 21);
- this.txt_SelectCountPersent.TabIndex = 7;
- //
- // txt_SelectArea
- //
- this.txt_SelectArea.Location = new System.Drawing.Point(95, 56);
- this.txt_SelectArea.Name = "txt_SelectArea";
- this.txt_SelectArea.Size = new System.Drawing.Size(66, 21);
- this.txt_SelectArea.TabIndex = 6;
- //
- // txt_SelectCount
- //
- this.txt_SelectCount.Location = new System.Drawing.Point(95, 31);
- this.txt_SelectCount.Name = "txt_SelectCount";
- this.txt_SelectCount.Size = new System.Drawing.Size(66, 21);
- this.txt_SelectCount.TabIndex = 5;
- //
- // label9
- //
- this.label9.AutoSize = true;
- this.label9.Location = new System.Drawing.Point(19, 82);
- this.label9.Name = "label9";
- this.label9.Size = new System.Drawing.Size(71, 12);
- this.label9.TabIndex = 4;
- this.label9.Text = "E颗粒1个数%";
- //
- // label8
- //
- this.label8.AutoSize = true;
- this.label8.Location = new System.Drawing.Point(180, 59);
- this.label8.Name = "label8";
- this.label8.Size = new System.Drawing.Size(65, 12);
- this.label8.TabIndex = 3;
- this.label8.Text = "D颗粒2面积";
- //
- // label7
- //
- this.label7.AutoSize = true;
- this.label7.Location = new System.Drawing.Point(180, 34);
- this.label7.Name = "label7";
- this.label7.Size = new System.Drawing.Size(65, 12);
- this.label7.TabIndex = 2;
- this.label7.Text = "B颗粒2个数";
- //
- // label6
- //
- this.label6.AutoSize = true;
- this.label6.Location = new System.Drawing.Point(19, 59);
- this.label6.Name = "label6";
- this.label6.Size = new System.Drawing.Size(65, 12);
- this.label6.TabIndex = 1;
- this.label6.Text = "C颗粒1面积";
- //
- // label5
- //
- this.label5.AutoSize = true;
- this.label5.Location = new System.Drawing.Point(19, 34);
- this.label5.Name = "label5";
- this.label5.Size = new System.Drawing.Size(65, 12);
- this.label5.TabIndex = 0;
- this.label5.Text = "A颗粒1个数";
- //
- // label2
- //
- this.label2.AutoSize = true;
- this.label2.Location = new System.Drawing.Point(17, 26);
- this.label2.Name = "label2";
- this.label2.Size = new System.Drawing.Size(53, 12);
- this.label2.TabIndex = 0;
- this.label2.Text = "选择物相";
- //
- // label3
- //
- this.label3.AutoSize = true;
- this.label3.Location = new System.Drawing.Point(19, 91);
- this.label3.Name = "label3";
- this.label3.Size = new System.Drawing.Size(29, 12);
- this.label3.TabIndex = 5;
- this.label3.Text = "最小";
- //
- // label4
- //
- this.label4.AutoSize = true;
- this.label4.Location = new System.Drawing.Point(164, 91);
- this.label4.Name = "label4";
- this.label4.Size = new System.Drawing.Size(29, 12);
- this.label4.TabIndex = 6;
- this.label4.Text = "最大";
- //
- // numericUpDown1
- //
- this.numericUpDown1.Location = new System.Drawing.Point(54, 89);
- this.numericUpDown1.Maximum = new decimal(new int[] {
- 1000000,
- 0,
- 0,
- 0});
- this.numericUpDown1.Name = "numericUpDown1";
- this.numericUpDown1.Size = new System.Drawing.Size(60, 21);
- this.numericUpDown1.TabIndex = 7;
- this.numericUpDown1.ValueChanged += new System.EventHandler(this.numericUpDown1_ValueChanged);
- this.numericUpDown1.KeyUp += new System.Windows.Forms.KeyEventHandler(this.numericUpDown1_KeyUp);
- //
- // numericUpDown2
- //
- this.numericUpDown2.Location = new System.Drawing.Point(199, 89);
- this.numericUpDown2.Maximum = new decimal(new int[] {
- 1000000,
- 0,
- 0,
- 0});
- this.numericUpDown2.Name = "numericUpDown2";
- this.numericUpDown2.Size = new System.Drawing.Size(60, 21);
- this.numericUpDown2.TabIndex = 8;
- this.numericUpDown2.ValueChanged += new System.EventHandler(this.numericUpDown2_ValueChanged);
- this.numericUpDown2.KeyUp += new System.Windows.Forms.KeyEventHandler(this.numericUpDown2_KeyUp);
- //
- // comboBox1
- //
- this.comboBox1.FormattingEnabled = true;
- this.comboBox1.Location = new System.Drawing.Point(95, 23);
- this.comboBox1.Name = "comboBox1";
- this.comboBox1.Size = new System.Drawing.Size(141, 20);
- this.comboBox1.TabIndex = 9;
- this.comboBox1.SelectedIndexChanged += new System.EventHandler(this.comboBox1_SelectedIndexChanged);
- //
- // label17
- //
- this.label17.AutoSize = true;
- this.label17.Location = new System.Drawing.Point(19, 121);
- this.label17.Name = "label17";
- this.label17.Size = new System.Drawing.Size(29, 12);
- this.label17.TabIndex = 12;
- this.label17.Text = "最小";
- //
- // label18
- //
- this.label18.AutoSize = true;
- this.label18.Location = new System.Drawing.Point(19, 150);
- this.label18.Name = "label18";
- this.label18.Size = new System.Drawing.Size(29, 12);
- this.label18.TabIndex = 13;
- this.label18.Text = "最大";
- //
- // trackBar2
- //
- this.trackBar2.Location = new System.Drawing.Point(59, 150);
- this.trackBar2.Maximum = 10000;
- this.trackBar2.Minimum = 0;
- this.trackBar2.Name = "trackBar2";
- this.trackBar2.Size = new System.Drawing.Size(341, 26);
- this.trackBar2.TabIndex = 14;
- this.trackBar2.Value = 0;
- this.trackBar2.TrackBarScroll += new System.EventHandler(this.trackBar2_TrackBarScroll);
- //
- // trackBar1
- //
- this.trackBar1.Location = new System.Drawing.Point(59, 116);
- this.trackBar1.Maximum = 10000;
- this.trackBar1.Minimum = 0;
- this.trackBar1.Name = "trackBar1";
- this.trackBar1.Size = new System.Drawing.Size(341, 26);
- this.trackBar1.TabIndex = 18;
- this.trackBar1.Value = 0;
- this.trackBar1.TrackBarScroll += new System.EventHandler(this.trackBar1_TrackBarScroll);
- //
- // label19
- //
- this.label19.AutoSize = true;
- this.label19.Location = new System.Drawing.Point(21, 194);
- this.label19.Name = "label19";
- this.label19.Size = new System.Drawing.Size(59, 12);
- this.label19.TabIndex = 19;
- this.label19.Text = "颗粒1颜色";
- //
- // label20
- //
- this.label20.AutoSize = true;
- this.label20.Location = new System.Drawing.Point(193, 194);
- this.label20.Name = "label20";
- this.label20.Size = new System.Drawing.Size(59, 12);
- this.label20.TabIndex = 20;
- this.label20.Text = "颗粒2颜色";
- //
- // panel1
- //
- this.panel1.BackColor = System.Drawing.Color.Red;
- this.panel1.Location = new System.Drawing.Point(87, 190);
- this.panel1.Name = "panel1";
- this.panel1.Size = new System.Drawing.Size(93, 23);
- this.panel1.TabIndex = 21;
- this.panel1.Click += new System.EventHandler(this.panel1_Click);
- //
- // panel2
- //
- this.panel2.BackColor = System.Drawing.Color.Yellow;
- this.panel2.Location = new System.Drawing.Point(258, 190);
- this.panel2.Name = "panel2";
- this.panel2.Size = new System.Drawing.Size(93, 23);
- this.panel2.TabIndex = 22;
- this.panel2.Click += new System.EventHandler(this.panel2_Click);
- //
- // comboBox2
- //
- this.comboBox2.FormattingEnabled = true;
- this.comboBox2.Items.AddRange(new object[] {
- "面积",
- "面积比",
- "周长",
- "短轴",
- "长轴",
- "倾斜角度",
- "高度",
- "宽度",
- "宽高比",
- "长径",
- "短径",
- "外接圆直径",
- "球化率",
- "等积圆直径",
- "最大卡规直径",
- "最小卡规直径",
- "平均卡规直径",
- "纤维长度"});
- this.comboBox2.Location = new System.Drawing.Point(95, 60);
- this.comboBox2.Name = "comboBox2";
- this.comboBox2.Size = new System.Drawing.Size(141, 20);
- this.comboBox2.TabIndex = 23;
- this.comboBox2.SelectedIndexChanged += new System.EventHandler(this.comboBox2_SelectedIndexChanged);
- //
- // groupBox2
- //
- this.groupBox2.Controls.Add(this.label21);
- this.groupBox2.Controls.Add(this.comboBox2);
- this.groupBox2.Controls.Add(this.panel2);
- this.groupBox2.Controls.Add(this.panel1);
- this.groupBox2.Controls.Add(this.label20);
- this.groupBox2.Controls.Add(this.label19);
- this.groupBox2.Controls.Add(this.trackBar1);
- this.groupBox2.Controls.Add(this.trackBar2);
- this.groupBox2.Controls.Add(this.label18);
- this.groupBox2.Controls.Add(this.label17);
- this.groupBox2.Controls.Add(this.comboBox1);
- this.groupBox2.Controls.Add(this.numericUpDown2);
- this.groupBox2.Controls.Add(this.numericUpDown1);
- this.groupBox2.Controls.Add(this.label4);
- this.groupBox2.Controls.Add(this.label3);
- this.groupBox2.Controls.Add(this.label2);
- this.groupBox2.Location = new System.Drawing.Point(178, 72);
- this.groupBox2.Name = "groupBox2";
- this.groupBox2.Size = new System.Drawing.Size(406, 235);
- this.groupBox2.TabIndex = 11;
- this.groupBox2.TabStop = false;
- this.groupBox2.Text = "物相设置";
- //
- // label21
- //
- this.label21.AutoSize = true;
- this.label21.Location = new System.Drawing.Point(19, 63);
- this.label21.Name = "label21";
- this.label21.Size = new System.Drawing.Size(53, 12);
- this.label21.TabIndex = 24;
- this.label21.Text = "筛选条件";
- //
- // TwoPhaseScaleDialog
- //
- this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
- this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- this.ClientSize = new System.Drawing.Size(1177, 744);
- this.Controls.Add(this.groupBox8);
- this.Controls.Add(this.groupBox7);
- this.Controls.Add(this.groupBox6);
- this.Controls.Add(this.groupBox5);
- this.Controls.Add(this.groupBox_review);
- this.Controls.Add(this.groupBox2);
- this.Controls.Add(this.groupBox1);
- this.Controls.Add(this.groupBox4);
- this.Name = "TwoPhaseScaleDialog";
- this.Text = "两相比例";
- this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.TwoPhaseScaleDialog_FormClosing);
- this.Load += new System.EventHandler(this.TwoPhaseScaleDialog_Load);
- this.Controls.SetChildIndex(this.groupBox4, 0);
- this.Controls.SetChildIndex(this.groupBox1, 0);
- this.Controls.SetChildIndex(this.groupBox2, 0);
- this.Controls.SetChildIndex(this.groupBox_review, 0);
- this.Controls.SetChildIndex(this.groupBox5, 0);
- this.Controls.SetChildIndex(this.groupBox6, 0);
- this.Controls.SetChildIndex(this.groupBox7, 0);
- this.Controls.SetChildIndex(this.groupBox8, 0);
- this.groupBox4.ResumeLayout(false);
- this.groupBox1.ResumeLayout(false);
- this.groupBox1.PerformLayout();
- this.groupBox5.ResumeLayout(false);
- this.groupBox6.ResumeLayout(false);
- ((System.ComponentModel.ISupportInitialize)(this.dataGridView_results)).EndInit();
- this.groupBox7.ResumeLayout(false);
- this.groupBox7.PerformLayout();
- ((System.ComponentModel.ISupportInitialize)(this.numericUpDown3)).EndInit();
- this.groupBox8.ResumeLayout(false);
- this.groupBox8.PerformLayout();
- ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).EndInit();
- ((System.ComponentModel.ISupportInitialize)(this.numericUpDown2)).EndInit();
- this.groupBox2.ResumeLayout(false);
- this.groupBox2.PerformLayout();
- this.ResumeLayout(false);
- }
- #endregion
- private void numericUpDown1_ValueChanged(object sender, EventArgs e)
- {
- if (this.documentWorkspace.phaseModels.Count == 0)
- {
- System.Windows.Forms.MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectaphase.text") + "!");
- return;
- }
- if (workType == 2 || workType == 9 || workType == 13)
- {
- trackBar1.Value = (int)(numericUpDown1.Value * 100);
- }
- else
- {
- trackBar1.Value = (int)numericUpDown1.Value;
- }
- GetAreaBetweenMinToMax(numericUpDown1.Value, numericUpDown2.Value, this.documentWorkspace.phaseModels[selectIndex].mat);
- }
- private void numericUpDown2_ValueChanged(object sender, EventArgs e)
- {
- if (this.documentWorkspace.phaseModels.Count == 0)
- {
- System.Windows.Forms.MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectaphase.text") + "!");
- return;
- }
- if (workType == 2 || workType == 9 || workType == 13)
- {
- trackBar2.Value = (int)(numericUpDown2.Value * 100);
- }
- else
- {
- trackBar2.Value = (int)(numericUpDown2.Value);
- }
- GetAreaBetweenMinToMax(numericUpDown1.Value, numericUpDown2.Value, this.documentWorkspace.phaseModels[selectIndex].mat);
- }
- private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
- {
- selectIndex = comboBox1.SelectedIndex;
- Mat oldMat = documentWorkspace.phaseModels[selectIndex].mat;
- onePhase.name = "one";
- onePhase.mat = new Mat(new OpenCvSharp.Size(oldMat.Cols, oldMat.Rows), MatType.CV_8UC4, new Scalar(0, 0, 0, 255));
- onePhase.color = panel1.BackColor.ToArgb();
- onePhase.choise = true;
- oldMat.CopyTo(onePhase.mat);
- PhaseModel oneP = documentWorkspace.phaseModels.Find(u => u.name == "one");
- if (oneP == null)
- {
- documentWorkspace.phaseModels.Add(onePhase);
- }
- else
- {
- oneP = onePhase;
- }
- this.trackBar1.Value = 0;
- this.trackBar2.Value = 0;
- this.numericUpDown1.Value = 0;
- this.numericUpDown2.Value = 0;
- }
- private void trackBar2_TrackBarScroll(object sender, EventArgs e)
- {
- if (workType == 2 || workType == 9 || workType == 13)
- {
- numericUpDown2.Value = (decimal)trackBar2.Value / 100;
- }
- else
- {
- numericUpDown2.Value = trackBar2.Value;
- }
- }
- private void trackBar1_TrackBarScroll(object sender, EventArgs e)
- {
- if (workType == 2 || workType == 9 || workType == 13)
- {
- numericUpDown1.Value = (decimal)trackBar1.Value / 100;
- }
- else
- {
- numericUpDown1.Value = trackBar1.Value;
- }
- }
- private void panel1_Click(object sender, EventArgs e)
- {
- if (this.documentWorkspace.phaseModels.Count == 0)
- {
- System.Windows.Forms.MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectaphase.text") + "!");
- return;
- }
- this.oneColorsForm.UserPrimaryColor = ColorBgra.FromColor(this.panel1.BackColor);
- this.oneColorsForm.setSaveBtn_Click(new System.EventHandler(this.oneColorsChanged));
- this.oneColorsForm.ShowDialog();
- }
- private void panel2_Click(object sender, EventArgs e)
- {
- if (this.documentWorkspace.phaseModels.Count == 0)
- {
- System.Windows.Forms.MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectaphase.text") + "!");
- return;
- }
- this.twoColorsForm.UserPrimaryColor = ColorBgra.FromColor(this.panel2.BackColor);
- this.twoColorsForm.setSaveBtn_Click(new System.EventHandler(this.twoColorsChanged));
- this.twoColorsForm.ShowDialog();
- }
- private void twoColorsChanged(object sender, EventArgs e)
- {
- Color color = this.twoColorsForm.UserPrimaryColor.ToColor();
- //更改背景色,触发事件
- this.panel2.BackColor = color;
- //改变配置文件里面的相颜色
- //this.binaryExtractionModel.PhaseColor = color.ToArgb();
- //关闭色板
- GetAreaBetweenMinToMax(numericUpDown1.Value, numericUpDown2.Value, this.documentWorkspace.phaseModels[selectIndex].mat);
- //this.documentWorkspace.Refresh();
- this.twoColorsForm.Close();
- }
- private void oneColorsChanged(object sender, EventArgs e)
- {
- Color color = this.oneColorsForm.UserPrimaryColor.ToColor();
- //更改背景色,触发事件
- this.panel1.BackColor = color;
- //改变配置文件里面的相颜色
- //this.binaryExtractionModel.PhaseColor = color.ToArgb();
- //关闭色板
- GetAreaBetweenMinToMax(numericUpDown1.Value, numericUpDown2.Value, this.documentWorkspace.phaseModels[selectIndex].mat);
- //this.documentWorkspace.Refresh();
- this.oneColorsForm.Close();
- }
- #region [筛选条件]
- /// <summary>
- /// 面积
- /// </summary>
- private void rb1_CheckedChanged()
- {
- if (this.documentWorkspace.phaseModels.Count == 0)
- {
- System.Windows.Forms.MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectaphase.text") + "!");
- return;
- }
- //double pxPerUnit = Startup.instance.rules[MeasurementUnit.Micron];
- double pxPerUnit = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].GetRuler(MeasurementUnit.Micron);
- decimal maxArea = (decimal)Math.Ceiling((getMaxArea(this.documentWorkspace.phaseModels[selectIndex].mat) * pxPerUnit * pxPerUnit));
- trackBar1.Maximum = (int)((double)maxArea);
- trackBar2.Maximum = (int)((double)maxArea);
- numericUpDown1.DecimalPlaces = 0;
- numericUpDown1.Increment = 1;
- numericUpDown2.DecimalPlaces = 0;
- numericUpDown2.Increment = 1;
- numericUpDown1.Maximum = maxArea;
- numericUpDown2.Maximum = maxArea;
- numericUpDown1.Value = 0;
- numericUpDown2.Value = 0;
- trackBar1.Value = 0;
- trackBar2.Value = 0;
- InitUI();
- selectResults = new TwoPhaseScaleResult();
- unSelectResults = new TwoPhaseScaleResult();
- workType = 1;
- }
- /// <summary>
- /// 面积比
- /// </summary>
- private void rb2_CheckedChanged()
- {
- if (this.documentWorkspace.phaseModels.Count == 0)
- {
- System.Windows.Forms.MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectaphase.text") + "!");
- return;
- }
- trackBar1.Maximum = 100;
- trackBar2.Maximum = 100;
- numericUpDown1.DecimalPlaces = 2;
- numericUpDown1.Increment = 0.01M;
- numericUpDown2.DecimalPlaces = 2;
- numericUpDown2.Increment = 0.01M;
- numericUpDown1.Maximum = 1;
- numericUpDown2.Maximum = 1;
- numericUpDown1.Value = 0;
- numericUpDown2.Value = 0;
- trackBar1.Value = 0;
- trackBar2.Value = 0;
- InitUI();
- workType = 2;
- }
- /// <summary>
- /// 最大卡规直径
- /// </summary>
- private void rb4_CheckedChanged()
- {
- //double pxPerUnit = Startup.instance.rules[MeasurementUnit.Micron];
- double pxPerUnit = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].GetRuler(MeasurementUnit.Micron);
- if (this.documentWorkspace.phaseModels.Count == 0)
- {
- System.Windows.Forms.MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectaphase.text") + "!");
- return;
- }
- decimal maxLength = (decimal)Math.Ceiling(getContoursMaxLength(this.documentWorkspace.phaseModels[selectIndex].mat, 2) * pxPerUnit);
- trackBar1.Maximum = (int)maxLength;
- trackBar2.Maximum = (int)maxLength;
- numericUpDown1.DecimalPlaces = 0;
- numericUpDown1.Increment = 1;
- numericUpDown2.DecimalPlaces = 0;
- numericUpDown2.Increment = 1;
- numericUpDown1.Maximum = maxLength;
- numericUpDown2.Maximum = maxLength;
- numericUpDown1.Value = 0;
- numericUpDown2.Value = 0;
- trackBar1.Value = 0;
- trackBar2.Value = 0;
- InitUI();
- workType = 15;
- }
- /// <summary>
- /// 长宽比
- /// </summary>
- private void rb3_CheckedChanged()
- {
- if (this.documentWorkspace.phaseModels.Count == 0)
- {
- System.Windows.Forms.MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectaphase.text") + "!");
- return;
- }
- decimal maxLength = 0;
- try
- {
- maxLength = (decimal)Math.Ceiling(getAspectRatio(this.documentWorkspace.phaseModels[selectIndex].mat));
- }
- catch (Exception)
- {
- }
- trackBar1.Maximum = (int)(maxLength * 100);
- trackBar2.Maximum = (int)(maxLength * 100);
- numericUpDown1.DecimalPlaces = 2;
- numericUpDown1.Increment = 0.01M;
- numericUpDown2.DecimalPlaces = 2;
- numericUpDown2.Increment = 0.01M;
- numericUpDown1.Maximum = maxLength;
- numericUpDown2.Maximum = maxLength;
- numericUpDown1.Value = 0;
- numericUpDown2.Value = 0;
- trackBar1.Value = 0;
- trackBar2.Value = 0;
- InitUI();
- workType = 9;
- }
- /// <summary>
- /// 最小卡规直径
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void minimumCaliperDiameter()
- {
- //double pxPerUnit = Startup.instance.rules[MeasurementUnit.Micron];
- double pxPerUnit = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].GetRuler(MeasurementUnit.Micron);
- if (this.documentWorkspace.phaseModels.Count == 0)
- {
- System.Windows.Forms.MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectaphase.text") + "!");
- return;
- }
- decimal maxLength = (decimal)Math.Ceiling(getContoursMaxLength(this.documentWorkspace.phaseModels[selectIndex].mat, 1) * pxPerUnit);
- trackBar1.Maximum = (int)maxLength;
- trackBar2.Maximum = (int)maxLength;
- numericUpDown1.DecimalPlaces = 0;
- numericUpDown1.Increment = 1;
- numericUpDown2.DecimalPlaces = 0;
- numericUpDown2.Increment = 1;
- numericUpDown1.Maximum = maxLength;
- numericUpDown2.Maximum = maxLength;
- numericUpDown1.Value = 0;
- numericUpDown2.Value = 0;
- trackBar1.Value = 0;
- trackBar2.Value = 0;
- InitUI();
- workType = 16;
- }
- /// <summary>
- /// 平均卡规直径
- /// </summary>
- private void averageCaliperDiameter()
- {
- if (this.documentWorkspace.phaseModels.Count == 0)
- {
- System.Windows.Forms.MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectaphase.text") + "!");
- return;
- }
- //double pxPerUnit = Startup.instance.rules[MeasurementUnit.Micron];
- double pxPerUnit = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].GetRuler(MeasurementUnit.Micron);
- decimal maxLength = (decimal)Math.Ceiling(getContoursMaxLength(this.documentWorkspace.phaseModels[selectIndex].mat, 3) * pxPerUnit);
- trackBar1.Maximum = (int)maxLength;
- trackBar2.Maximum = (int)maxLength;
- numericUpDown1.DecimalPlaces = 0;
- numericUpDown1.Increment = 1;
- numericUpDown2.DecimalPlaces = 0;
- numericUpDown2.Increment = 1;
- numericUpDown1.Maximum = maxLength;
- numericUpDown2.Maximum = maxLength;
- numericUpDown1.Value = 0;
- numericUpDown2.Value = 0;
- trackBar1.Value = 0;
- trackBar2.Value = 0;
- InitUI();
- workType = 17;
- }
- /// <summary>
- /// 长轴
- /// </summary>
- private void longAxis(int type)
- {
- //double pxPerUnit = Startup.instance.rules[MeasurementUnit.Micron];
- double pxPerUnit = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].GetRuler(MeasurementUnit.Micron);
- if (this.documentWorkspace.phaseModels.Count == 0)
- {
- System.Windows.Forms.MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectaphase.text") + "!");
- return;
- }
- double maxLength = Math.Ceiling(getLongAxis(this.documentWorkspace.phaseModels[selectIndex].mat, type) * pxPerUnit);
- trackBar1.Maximum = (int)maxLength;
- trackBar2.Maximum = (int)maxLength;
- numericUpDown1.DecimalPlaces = 0;
- numericUpDown1.Increment = 1;
- numericUpDown2.DecimalPlaces = 0;
- numericUpDown2.Increment = 1;
- numericUpDown1.Maximum = (decimal)maxLength;
- numericUpDown2.Maximum = (decimal)maxLength;
- numericUpDown1.Value = 0;
- numericUpDown2.Value = 0;
- trackBar1.Value = 0;
- trackBar2.Value = 0;
- InitUI();
- workType = type == 1 ? 4 : 5;
- }
- /// <summary>
- /// 周长
- /// </summary>
- private void perimeter()
- {
- if (this.documentWorkspace.phaseModels.Count == 0)
- {
- System.Windows.Forms.MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectaphase.text") + "!");
- return;
- }
- //double pxPerUnit = Startup.instance.rules[MeasurementUnit.Micron];
- double pxPerUnit = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].GetRuler(MeasurementUnit.Micron);
- decimal maxLength = (decimal)Math.Ceiling(getMaxPerimeter(this.documentWorkspace.phaseModels[selectIndex].mat) * pxPerUnit);
- trackBar1.Maximum = (int)maxLength;
- trackBar2.Maximum = (int)maxLength;
- numericUpDown1.DecimalPlaces = 0;
- numericUpDown1.Increment = 1;
- numericUpDown2.DecimalPlaces = 0;
- numericUpDown2.Increment = 1;
- numericUpDown1.Maximum = maxLength;
- numericUpDown2.Maximum = maxLength;
- numericUpDown1.Value = 0;
- numericUpDown2.Value = 0;
- trackBar1.Value = 0;
- trackBar2.Value = 0;
- InitUI();
- workType = 3;
- }
- /// <summary>
- /// 倾斜角度
- /// </summary>
- private void slope()
- {
- if (this.documentWorkspace.phaseModels.Count == 0)
- {
- System.Windows.Forms.MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectaphase.text") + "!");
- return;
- }
- decimal maxLength = (decimal)getMaxSlope(this.documentWorkspace.phaseModels[selectIndex].mat);
- trackBar1.Maximum = (int)maxLength;
- trackBar2.Maximum = (int)maxLength;
- numericUpDown1.DecimalPlaces = 0;
- numericUpDown1.Increment = 1;
- numericUpDown2.DecimalPlaces = 0;
- numericUpDown2.Increment = 1;
- numericUpDown1.Maximum = maxLength;
- numericUpDown2.Maximum = maxLength;
- numericUpDown1.Value = 0;
- numericUpDown2.Value = 0;
- trackBar1.Value = 0;
- trackBar2.Value = 0;
- InitUI();
- workType = 6;
- }
- /// <summary>
- /// 高度
- /// </summary>
- private void particulatesHeight()
- {
- if (this.documentWorkspace.phaseModels.Count == 0)
- {
- System.Windows.Forms.MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectaphase.text") + "!");
- return;
- }
- //double pxPerUnit = Startup.instance.rules[MeasurementUnit.Micron];
- double pxPerUnit = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].GetRuler(MeasurementUnit.Micron);
- decimal maxLength = (decimal)Math.Ceiling(getHeightOrWidth(this.documentWorkspace.phaseModels[selectIndex].mat, 1) * pxPerUnit);
- trackBar1.Maximum = (int)maxLength;
- trackBar2.Maximum = (int)maxLength;
- numericUpDown1.DecimalPlaces = 0;
- numericUpDown1.Increment = 1;
- numericUpDown2.DecimalPlaces = 0;
- numericUpDown2.Increment = 1;
- numericUpDown1.Maximum = maxLength;
- numericUpDown2.Maximum = maxLength;
- numericUpDown1.Value = 0;
- numericUpDown2.Value = 0;
- trackBar1.Value = 0;
- trackBar2.Value = 0;
- InitUI();
- workType = 7;
- }
- /// <summary>
- /// 宽度
- /// </summary>
- private void particulatesWidth()
- {
- if (this.documentWorkspace.phaseModels.Count == 0)
- {
- System.Windows.Forms.MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectaphase.text") + "!");
- return;
- }
- //double pxPerUnit = Startup.instance.rules[MeasurementUnit.Micron];
- double pxPerUnit = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].GetRuler(MeasurementUnit.Micron);
- decimal maxLength = (decimal)Math.Ceiling(getHeightOrWidth(this.documentWorkspace.phaseModels[selectIndex].mat, 2) * pxPerUnit);
- trackBar1.Maximum = (int)maxLength;
- trackBar2.Maximum = (int)maxLength;
- numericUpDown1.DecimalPlaces = 0;
- numericUpDown1.Increment = 1;
- numericUpDown2.DecimalPlaces = 0;
- numericUpDown2.Increment = 1;
- numericUpDown1.Maximum = maxLength;
- numericUpDown2.Maximum = maxLength;
- numericUpDown1.Value = 0;
- numericUpDown2.Value = 0;
- trackBar1.Value = 0;
- trackBar2.Value = 0;
- InitUI();
- workType = 8;
- }
- /// <summary>
- /// 长径或者短径
- /// </summary>
- private void trail(int type)
- {
- if (this.documentWorkspace.phaseModels.Count == 0)
- {
- System.Windows.Forms.MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectaphase.text") + "!");
- return;
- }
- //double pxPerUnit = Startup.instance.rules[MeasurementUnit.Micron];
- double pxPerUnit = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].GetRuler(MeasurementUnit.Micron);
- decimal maxLength = (decimal)Math.Ceiling(getTrail(this.documentWorkspace.phaseModels[selectIndex].mat, type) * pxPerUnit);
- trackBar1.Maximum = (int)maxLength;
- trackBar2.Maximum = (int)maxLength;
- numericUpDown1.DecimalPlaces = 0;
- numericUpDown1.Increment = 1;
- numericUpDown2.DecimalPlaces = 0;
- numericUpDown2.Increment = 1;
- numericUpDown1.Maximum = maxLength;
- numericUpDown2.Maximum = maxLength;
- numericUpDown1.Value = 0;
- numericUpDown2.Value = 0;
- trackBar1.Value = 0;
- trackBar2.Value = 0;
- InitUI();
- workType = type == 1 ? 10 : 11;
- }
- /// <summary>
- /// 外接圆直径
- /// </summary>
- private void circumscribedCircleDiameter()
- {
- if (this.documentWorkspace.phaseModels.Count == 0)
- {
- System.Windows.Forms.MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectaphase.text") + "!");
- return;
- }
- //double pxPerUnit = Startup.instance.rules[MeasurementUnit.Micron];
- double pxPerUnit = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].GetRuler(MeasurementUnit.Micron);
- decimal maxLength = (decimal)Math.Ceiling(getCircumscribedCircleDiameter(this.documentWorkspace.phaseModels[selectIndex].mat) * pxPerUnit);
- trackBar1.Maximum = (int)maxLength;
- trackBar2.Maximum = (int)maxLength;
- numericUpDown1.DecimalPlaces = 0;
- numericUpDown1.Increment = 1;
- numericUpDown2.DecimalPlaces = 0;
- numericUpDown2.Increment = 1;
- numericUpDown1.Maximum = maxLength;
- numericUpDown2.Maximum = maxLength;
- numericUpDown1.Value = 0;
- numericUpDown2.Value = 0;
- trackBar1.Value = 0;
- trackBar2.Value = 0;
- InitUI();
- workType = 12;
- }
- /// <summary>
- /// 球化率
- /// </summary>
- private void spheroidizationRate()
- {
- if (this.documentWorkspace.phaseModels.Count == 0)
- {
- System.Windows.Forms.MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectaphase.text") + "!");
- return;
- }
- trackBar1.Maximum = 100;
- trackBar2.Maximum = 100;
- numericUpDown1.DecimalPlaces = 2;
- numericUpDown1.Increment = 0.01M;
- numericUpDown2.DecimalPlaces = 2;
- numericUpDown2.Increment = 0.01M;
- numericUpDown1.Maximum = 1;
- numericUpDown2.Maximum = 1;
- numericUpDown1.Value = 0;
- numericUpDown2.Value = 0;
- trackBar1.Value = 0;
- trackBar2.Value = 0;
- InitUI();
- workType = 13;
- }
- /// <summary>
- /// 等积圆直径
- /// </summary>
- private void equalAreaCircle()
- {
- if (this.documentWorkspace.phaseModels.Count == 0)
- {
- System.Windows.Forms.MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectaphase.text") + "!");
- return;
- }
- //double pxPerUnit = Startup.instance.rules[MeasurementUnit.Micron];
- double pxPerUnit = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].GetRuler(MeasurementUnit.Micron);
- decimal maxLength = Math.Ceiling((decimal)(getEqualAreaCircle(this.documentWorkspace.phaseModels[selectIndex].mat) * pxPerUnit));
- trackBar1.Maximum = (int)maxLength;
- trackBar2.Maximum = (int)maxLength;
- numericUpDown1.DecimalPlaces = 0;
- numericUpDown1.Increment = 1;
- numericUpDown2.DecimalPlaces = 0;
- numericUpDown2.Increment = 1;
- numericUpDown1.Maximum = maxLength;
- numericUpDown2.Maximum = maxLength;
- numericUpDown1.Value = 0;
- numericUpDown2.Value = 0;
- trackBar1.Value = 0;
- trackBar2.Value = 0;
- InitUI();
- workType = 14;
- }
- /// <summary>
- /// 纤维长度
- /// </summary>
- private void fiberLength()
- {
- if (this.documentWorkspace.phaseModels.Count == 0)
- {
- System.Windows.Forms.MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectaphase.text") + "!");
- return;
- }
- //double pxPerUnit = Startup.instance.rules[MeasurementUnit.Micron];
- double pxPerUnit = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].GetRuler(MeasurementUnit.Micron);
- decimal maxLength = (decimal)Math.Ceiling(getFiberLength(this.documentWorkspace.phaseModels[selectIndex].mat) * pxPerUnit);
- trackBar1.Maximum = (int)maxLength;
- trackBar2.Maximum = (int)maxLength;
- numericUpDown1.DecimalPlaces = 0;
- numericUpDown1.Increment = 1;
- numericUpDown2.DecimalPlaces = 0;
- numericUpDown2.Increment = 1;
- numericUpDown1.Maximum = maxLength;
- numericUpDown2.Maximum = maxLength;
- numericUpDown1.Value = 0;
- numericUpDown2.Value = 0;
- trackBar1.Value = 0;
- trackBar2.Value = 0;
- InitUI();
- workType = 18;
- }
- #endregion
- #region [基础方法]
- /// <summary>
- /// 获取最大面积
- /// </summary>
- /// <param name="pMat"></param>
- /// <returns></returns>
- private double getMaxArea(Mat pMat)
- {
- double maxArea = 0;
- Mat mat = Mat.FromImageData(pMat.ToBytes(), ImreadModes.Grayscale);
- HierarchyIndex[] hierarchy;
- OpenCvSharp.Point[][] contours;
- Cv2.FindContours(mat, out contours, out hierarchy, RetrievalModes.External, ContourApproximationModes.ApproxNone);
- for (int i = 0; i < contours.Count(); i++)
- {
- double area = (Cv2.FloodFill(mat, contours[i][0], new Scalar(0, 0, 0, 0)));
- if (area > maxArea)
- {
- maxArea = area;
- }
- }
- return Math.Ceiling(maxArea);
- }
- /// <summary>
- /// 获取轮廓的最大卡规直径
- /// </summary>
- /// <param name="pMat"></param>
- /// <returns></returns>
- private double getContoursMaxLength(Mat pMat, int type)
- {
- double maxLength = 0;
- Mat mat = Mat.FromImageData(pMat.ToBytes(), ImreadModes.Grayscale);
- HierarchyIndex[] hierarchy;
- OpenCvSharp.Point[][] contours;
- Cv2.FindContours(mat, out contours, out hierarchy, RetrievalModes.External, ContourApproximationModes.ApproxNone);
- if (type == 2)
- {
- for (int i = 0; i < contours.Count(); i++)
- {
- List<int> vs = BasicCalculationHelper.GetCaliperDiameter(contours[i], hierarchy[i], out points);
- int width = vs.Max();
- if (width > maxLength)
- {
- maxLength = width;
- }
- }
- }
- else if (type == 1)
- {
- for (int i = 0; i < contours.Count(); i++)
- {
- List<int> vs = BasicCalculationHelper.GetCaliperDiameter(contours[i], hierarchy[i], out points);
- int width = vs.Min();
- if (width > maxLength)
- {
- maxLength = width;
- }
- }
- }
- else
- {
- for (int i = 0; i < contours.Count(); i++)
- {
- List<int> vs = BasicCalculationHelper.GetCaliperDiameter(contours[i], hierarchy[i], out points);
- var width = Math.Ceiling(vs.Average());
- if (width > maxLength)
- {
- maxLength = width;
- }
- }
- }
- return Math.Ceiling(maxLength);
- }
- /// <summary>
- /// 获取轮廓的周长
- /// </summary>
- /// <param name="pMat"></param>
- /// <returns></returns>
- private double getMaxPerimeter(Mat pMat)
- {
- Mat mat = Mat.FromImageData(pMat.ToBytes(), ImreadModes.Grayscale);
- HierarchyIndex[] hierarchy;
- OpenCvSharp.Point[][] contours;
- Cv2.FindContours(mat, out contours, out hierarchy, RetrievalModes.External, ContourApproximationModes.ApproxNone);
- return contours.Max(m => m.Length); ;
- }
- /// <summary>
- /// 获取轮廓长轴或者短轴
- /// </summary>
- /// <param name="pMat"></param>
- /// <returns></returns>
- private double getLongAxis(Mat pMat, int type)
- {
- double maxLength = 0;
- Mat mat = Mat.FromImageData(pMat.ToBytes(), ImreadModes.Grayscale);
- HierarchyIndex[] hierarchy;
- OpenCvSharp.Point[][] contours;
- Cv2.FindContours(mat, out contours, out hierarchy, RetrievalModes.External, ContourApproximationModes.ApproxNone);
- for (int i = 0; i < contours.Count(); i++)
- {
- RotatedRect ellipsemege = Cv2.MinAreaRect(contours[i]);
- float width = 0;
- if (type == 1)
- {
- width = ellipsemege.Size.Width > ellipsemege.Size.Height ? ellipsemege.Size.Width : ellipsemege.Size.Height;
- }
- else
- {
- width = ellipsemege.Size.Width < ellipsemege.Size.Height ? ellipsemege.Size.Width : ellipsemege.Size.Height;
- }
- if (width > maxLength)
- {
- maxLength = width;
- }
- }
- return Math.Ceiling(maxLength);
- }
- /// <summary>
- /// 获取轮廓倾斜角度
- /// </summary>
- /// <param name="pMat"></param>
- /// <returns></returns>
- private double getMaxSlope(Mat pMat)
- {
- double maxLength = 0;
- Mat mat = Mat.FromImageData(pMat.ToBytes(), ImreadModes.Grayscale);
- HierarchyIndex[] hierarchy;
- OpenCvSharp.Point[][] contours;
- Cv2.FindContours(mat, out contours, out hierarchy, RetrievalModes.External, ContourApproximationModes.ApproxNone);
- for (int i = 0; i < contours.Count(); i++)
- {
- if (contours[i].Count() < 5)
- {
- continue;
- }
- RotatedRect ellipsemege = Cv2.FitEllipse(contours[i]);
- float width = ellipsemege.Angle;
- if (width > maxLength)
- {
- maxLength = width;
- }
- }
- return Math.Ceiling(maxLength);
- }
- /// <summary>
- /// 获取轮廓高度或者宽度
- /// </summary>
- /// <param name="pMat"></param>
- /// <returns></returns>
- private double getHeightOrWidth(Mat pMat, int type)
- {
- double maxLength = 0;
- Mat mat = Mat.FromImageData(pMat.ToBytes(), ImreadModes.Grayscale);
- HierarchyIndex[] hierarchy;
- OpenCvSharp.Point[][] contours;
- Cv2.FindContours(mat, out contours, out hierarchy, RetrievalModes.External, ContourApproximationModes.ApproxNone);
- for (int i = 0; i < contours.Count(); i++)
- {
- Rect ellipsemege = Cv2.BoundingRect(contours[i]);
- float width = type == 1 ? ellipsemege.Size.Height : ellipsemege.Size.Width;
- if (width > maxLength)
- {
- maxLength = width;
- }
- }
- return Math.Ceiling(maxLength);
- }
- /// <summary>
- /// 获取轮廓长径或者短径
- /// </summary>
- /// <param name="pMat"></param>
- /// <returns></returns>
- private double getTrail(Mat pMat, int type)
- {
- double maxLength = 0;
- Mat mat = Mat.FromImageData(pMat.ToBytes(), ImreadModes.Grayscale);
- HierarchyIndex[] hierarchy;
- OpenCvSharp.Point[][] contours;
- Cv2.FindContours(mat, out contours, out hierarchy, RetrievalModes.External, ContourApproximationModes.ApproxNone);
- for (int i = 0; i < contours.Count(); i++)
- {
- RotatedRect ellipsemege = Cv2.MinAreaRect(contours[i]);
- double width;
- if (type == 1)
- {
- width = ellipsemege.Size.Width > ellipsemege.Size.Height ? ellipsemege.Size.Width * 0.5 : ellipsemege.Size.Height * 0.5;
- }
- else
- {
- width = ellipsemege.Size.Width < ellipsemege.Size.Height ? ellipsemege.Size.Width * 0.5 : ellipsemege.Size.Height * 0.5;
- }
- if (width > maxLength)
- {
- maxLength = width;
- }
- }
- return Math.Ceiling(maxLength);
- }
- /// <summary>
- /// 外接圆直径
- /// </summary>
- /// <param name="pMat"></param>
- /// <returns></returns>
- private double getCircumscribedCircleDiameter(Mat pMat)
- {
- double maxLength = 0;
- Mat mat = Mat.FromImageData(pMat.ToBytes(), ImreadModes.Grayscale);
- HierarchyIndex[] hierarchy;
- OpenCvSharp.Point[][] contours;
- Cv2.FindContours(mat, out contours, out hierarchy, RetrievalModes.External, ContourApproximationModes.ApproxNone);
- Point2f point;
- for (int i = 0; i < contours.Count(); i++)
- {
- float radius;
- Cv2.MinEnclosingCircle(contours[i], out point, out radius);
- double width = radius * 2;
- if (width > maxLength)
- {
- maxLength = width;
- }
- }
- return Math.Ceiling(maxLength);
- }
- /// <summary>
- /// 等积圆直径
- /// </summary>
- /// <param name="pMat"></param>
- /// <returns></returns>
- private double getEqualAreaCircle(Mat pMat)
- {
- double maxLength = 0;
- Mat mat = Mat.FromImageData(pMat.ToBytes(), ImreadModes.Grayscale);
- HierarchyIndex[] hierarchy;
- OpenCvSharp.Point[][] contours;
- Cv2.FindContours(mat, out contours, out hierarchy, RetrievalModes.External, ContourApproximationModes.ApproxNone);
- for (int i = 0; i < contours.Count(); i++)
- {
- double area = (Cv2.FloodFill(mat, contours[i][0], new Scalar(0, 0, 0, 0)));
- double width = Math.Sqrt(area / Math.PI) * 2;
- if (width > maxLength)
- {
- maxLength = width;
- }
- }
- return Math.Ceiling(maxLength);
- }
- /// <summary>
- /// 纤维长度
- /// </summary>
- /// <param name="pMat"></param>
- /// <returns></returns>
- private double getFiberLength(Mat pMat)
- {
- double maxLength = 0;
- Mat mat = Mat.FromImageData(pMat.ToBytes(), ImreadModes.Grayscale);
- HierarchyIndex[] hierarchy;
- OpenCvSharp.Point[][] contours;
- Cv2.FindContours(mat, out contours, out hierarchy, RetrievalModes.External, ContourApproximationModes.ApproxNone);
- for (int i = 0; i < contours.Count(); i++)
- {
- double area = (Cv2.FloodFill(mat, contours[i][0], new Scalar(0, 0, 0, 0)));
- double width = (contours[i].Length + Math.Sqrt(contours[i].Length * contours[i].Length + 16 * area)) / 4;
- if (width > maxLength)
- {
- maxLength = width;
- }
- }
- return Math.Ceiling(maxLength);
- }
- /// <summary>
- /// 长宽比
- /// </summary>
- /// <returns></returns>
- private double getAspectRatio(Mat pMat)
- {
- double maxLength = 0;
- Mat mat = Mat.FromImageData(pMat.ToBytes(), ImreadModes.Grayscale);
- HierarchyIndex[] hierarchy;
- OpenCvSharp.Point[][] contours;
- Cv2.FindContours(mat, out contours, out hierarchy, RetrievalModes.External, ContourApproximationModes.ApproxNone);
- for (int i = 0; i < contours.Count(); i++)
- {
- Rect area = Cv2.BoundingRect(contours[i]);
- double width = (double)area.Width / (double)area.Height;
- if (width > maxLength)
- {
- maxLength = width;
- }
- }
- return Math.Ceiling(maxLength);
- }
- #endregion
- private void button2_Click(object sender, EventArgs e)
- {
- if (listView1.SelectedItems.Count == 0)
- {
- System.Windows.Forms.MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectapicture.text"));
- return;
- }
- if (comboBox1.SelectedIndex == -1)
- {
- System.Windows.Forms.MessageBox.Show(PdnResources.GetString("Menu.Selectthephaseyouwanttoanalyze.text") + "!");
- comboBox1.Focus();
- return;
- }
- String tag = listView1.FocusedItem.Text;
- List<Bitmap> tempBit = new List<Bitmap>();
- if (finalResults.FindAll(u => u.GraphName == listView1.FocusedItem.Text).Count == 0)
- {
- TwoPhaseScaleExportResult activeResult = new TwoPhaseScaleExportResult(listView1.FocusedItem.Text, selectResults, unSelectResults);
- finalResults.Add(activeResult);
- listBox_analysisResult.Items.Add(listView1.FocusedItem.Text);
- listBox_analysisResult.SetItemChecked(listBox_analysisResult.Items.Count - 1, true);
- dataGridView_results.Rows.Add(activeResult.GraphName,
- activeResult.selectResult.Count.ToString(),
- activeResult.unSelectResult.Count.ToString(),
- AnalysisTools.GetDecNum(activeResult.selectResult.Area, decnum).ToString(),
- AnalysisTools.GetDecNum(activeResult.unSelectResult.Area, decnum).ToString(),
- AnalysisTools.GetDecNum(activeResult.selectResult.CountPercent, decnum),
- AnalysisTools.GetDecNum(activeResult.unSelectResult.CountPercent, decnum),
- AnalysisTools.GetDecNum(activeResult.selectResult.Content, decnum),
- AnalysisTools.GetDecNum(activeResult.unSelectResult.Content, decnum),
- AnalysisTools.GetDecNum(activeResult.selectResult.ContentFromAll, decnum),
- AnalysisTools.GetDecNum(activeResult.unSelectResult.ContentFromAll, decnum),
- AnalysisTools.GetDecNum(activeResult.selectResult.CountScaleU, decnum),
- AnalysisTools.GetDecNum(activeResult.unSelectResult.CountScaleU, decnum));
- }
- else
- {
- DialogResult dr = MessageBox.Show(PdnResources.GetString("Menu.Theresuethertoreplace.text") + "?", PdnResources.GetString("Form.OkButton.Text"), MessageBoxButtons.OKCancel, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
- if (dr != DialogResult.OK)
- {
- return;
- }
- finalResults.RemoveAll(u => u.GraphName == listView1.FocusedItem.Text);
- TwoPhaseScaleExportResult activeResult = new TwoPhaseScaleExportResult(listView1.FocusedItem.Text, selectResults, unSelectResults);
- finalResults.Add(activeResult);
- List<string> list = new List<string>();
- foreach (var s in this.listBox_analysisResult.Items)
- {
- list.Add(s.ToString());
- }
- this.listBox_analysisResult.Items.Clear();
- foreach (var s in list)
- {
- this.listBox_analysisResult.Items.Add(s);
- }
- var thisindex = this.listBox_analysisResult.Items.IndexOf(listView1.FocusedItem.Text);
- this.dataGridView_results.Rows.Clear();
- listBox_analysisResult.SetItemChecked(thisindex, true);
- dataGridView_results.Rows.Add(activeResult.GraphName,
- activeResult.selectResult.Count.ToString(),
- activeResult.unSelectResult.Count.ToString(),
- AnalysisTools.GetDecNum(activeResult.selectResult.Area, decnum).ToString(),
- AnalysisTools.GetDecNum(activeResult.unSelectResult.Area, decnum).ToString(),
- AnalysisTools.GetDecNum(activeResult.selectResult.CountPercent, decnum),
- AnalysisTools.GetDecNum(activeResult.unSelectResult.CountPercent, decnum),
- AnalysisTools.GetDecNum(activeResult.selectResult.Content, decnum),
- AnalysisTools.GetDecNum(activeResult.unSelectResult.Content, decnum),
- AnalysisTools.GetDecNum(activeResult.selectResult.ContentFromAll, decnum),
- AnalysisTools.GetDecNum(activeResult.unSelectResult.ContentFromAll, decnum),
- AnalysisTools.GetDecNum(activeResult.selectResult.CountScaleU, decnum),
- AnalysisTools.GetDecNum(activeResult.unSelectResult.CountScaleU, decnum));
- }
- double pantographRatio = (double)this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].GetRulerMultiple(MeasurementUnit.Micron);//标尺*放大倍数
- Bitmap originalBit = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].CompositionSurface.CreateAliasedBitmap();
- originalBit.Tag = pantographRatio;
- tempBit.Add(originalBit);
- Bitmap newBit = originalBit.Clone(new Rectangle(0, 0, originalBit.Width, originalBit.Height), originalBit.PixelFormat);
- Graphics graphics = Graphics.FromImage(newBit);
- Draw(graphics);
- newBit.Tag = pantographRatio;
- tempBit.Add(newBit);
- if (bitDic.ContainsKey(tag))
- {
- bitDic[tag].Clear();
- bitDic[tag] = tempBit;
- }
- else
- {
- bitDic.Add(tag, tempBit);
- }
- }
- private void Draw(Graphics graphics)
- {
- if (this.documentWorkspace.phaseModels.Count > 0)
- {
- foreach (PhaseModel model in this.documentWorkspace.phaseModels)
- {
- if (model.choise && model.mat != null)
- {
- Bitmap map = OpenCvSharp.Extensions.BitmapConverter.ToBitmap(model.mat);
- graphics.DrawImage(map, 0, 0, map.Width, map.Height);
- }
- }
- }
- }
- private void button_all_Click(object sender, EventArgs e)
- {
- dataGridView_results.Rows.Clear();
- if (this.is_all % 2 == 0)
- {
- for (int i = 0; i < listBox_analysisResult.Items.Count; i++)
- {
- listBox_analysisResult.SetItemChecked(i, false);
- }
- }
- else
- {
- for (int i = 0; i < listBox_analysisResult.Items.Count; i++)
- {
- listBox_analysisResult.SetItemChecked(i, true);
- }
- for (int i = 0; i < finalResults.Count; i++)
- {
- dataGridView_results.Rows.Add(finalResults[i].GraphName,
- finalResults[i].selectResult.Count.ToString(),
- finalResults[i].unSelectResult.Count.ToString(),
- AnalysisTools.GetDecNum(finalResults[i].selectResult.Area, decnum),
- AnalysisTools.GetDecNum(finalResults[i].unSelectResult.Area, decnum),
- AnalysisTools.GetDecNum(finalResults[i].selectResult.CountPercent, decnum),
- AnalysisTools.GetDecNum(finalResults[i].unSelectResult.CountPercent, decnum),
- AnalysisTools.GetDecNum(finalResults[i].selectResult.Content, decnum),
- AnalysisTools.GetDecNum(finalResults[i].unSelectResult.Count, decnum),
- AnalysisTools.GetDecNum(finalResults[i].selectResult.ContentFromAll, decnum),
- AnalysisTools.GetDecNum(finalResults[i].unSelectResult.ContentFromAll, decnum),
- AnalysisTools.GetDecNum(finalResults[i].selectResult.CountScaleU, decnum),
- AnalysisTools.GetDecNum(finalResults[i].unSelectResult.CountScaleU, decnum));
- }
- }
- this.is_all += 1;
- }
- private void button_remove_Click(object sender, EventArgs e)
- {
- var removeList = new List<string>();
- if (listBox_analysisResult.CheckedItems != null && listBox_analysisResult.CheckedItems.Count > 0)
- {
- DialogResult dr = MessageBox.Show(PdnResources.GetString("Menu.ertodeletetheselectedanalysisres.Text") + "?", PdnResources.GetString("Menu.Edit.Delete.Text"), MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
- if (dr == DialogResult.OK)
- {
- foreach (var s in listBox_analysisResult.CheckedItems)
- {
- for (int i = 0; i < dataGridView_results.Rows.Count; i++)
- {
- if (dataGridView_results.Rows[i].Cells[0].Value.ToString() == s.ToString())
- {
- dataGridView_results.Rows.RemoveAt(i);
- }
- }
- finalResults.RemoveAll(u => u.GraphName == s.ToString());
- removeList.Add(s.ToString());
- }
- foreach (var m in removeList)
- {
- listBox_analysisResult.Items.Remove(m);
- }
- }
- }
- else
- {
- MessageBox.Show(PdnResources.GetString("Menu.cttheanalysisresultsthatyouwanttod.Text") + "!");
- }
- }
- private void listBox_analysisResult_SelectedIndexChanged(object sender, EventArgs e)
- {
- dataGridView_results.Rows.Clear();
- if (listBox_analysisResult.CheckedItems != null && listBox_analysisResult.CheckedItems.Count > 0)
- {
- foreach (var s in listBox_analysisResult.CheckedItems)
- {
- List<TwoPhaseScaleExportResult> selectItems = finalResults.FindAll(u => u.GraphName == s.ToString());
- for (int i = 0; i < selectItems.Count; i++)
- {
- dataGridView_results.Rows.Add(selectItems[i].GraphName,
- selectItems[i].selectResult.Count.ToString(),
- selectItems[i].unSelectResult.Count.ToString(),
- AnalysisTools.GetDecNum(selectItems[i].selectResult.Area, decnum).ToString(),
- AnalysisTools.GetDecNum(selectItems[i].unSelectResult.Area, decnum).ToString(),
- AnalysisTools.GetDecNum(selectItems[i].selectResult.CountPercent, decnum),
- AnalysisTools.GetDecNum(selectItems[i].unSelectResult.CountPercent, decnum),
- AnalysisTools.GetDecNum(selectItems[i].selectResult.Content, decnum),
- AnalysisTools.GetDecNum(selectItems[i].unSelectResult.Content, decnum),
- AnalysisTools.GetDecNum(selectItems[i].selectResult.ContentFromAll, decnum),
- AnalysisTools.GetDecNum(selectItems[i].unSelectResult.ContentFromAll, decnum),
- AnalysisTools.GetDecNum(selectItems[i].selectResult.CountScaleU, decnum),
- AnalysisTools.GetDecNum(selectItems[i].unSelectResult.CountScaleU, decnum));
- }
- }
- }
- }
- private void numericUpDown3_ValueChanged(object sender, EventArgs e)
- {
- decnum = (int)numericUpDown3.Value;
- for (int i = 0; i < dataGridView_results.Rows.Count; i++)
- {
- TwoPhaseScaleExportResult result = this.finalResults.Find(u => u.GraphName.Equals(dataGridView_results.Rows[i].Cells[0].Value.ToString()));
- if (result != null)
- {
- dataGridView_results.Rows[i].Cells[3].Value = AnalysisTools.GetDecNum(result.selectResult.Area, decnum);
- dataGridView_results.Rows[i].Cells[4].Value = AnalysisTools.GetDecNum(result.unSelectResult.Area, decnum);
- dataGridView_results.Rows[i].Cells[5].Value = AnalysisTools.GetDecNum(result.selectResult.CountPercent, decnum);
- dataGridView_results.Rows[i].Cells[6].Value = AnalysisTools.GetDecNum(result.unSelectResult.CountPercent, decnum);
- dataGridView_results.Rows[i].Cells[7].Value = AnalysisTools.GetDecNum(result.selectResult.Content, decnum);
- dataGridView_results.Rows[i].Cells[8].Value = AnalysisTools.GetDecNum(result.unSelectResult.Content, decnum);
- dataGridView_results.Rows[i].Cells[9].Value = AnalysisTools.GetDecNum(result.selectResult.ContentFromAll, decnum);
- dataGridView_results.Rows[i].Cells[10].Value = AnalysisTools.GetDecNum(result.unSelectResult.ContentFromAll, decnum);
- dataGridView_results.Rows[i].Cells[11].Value = AnalysisTools.GetDecNum(result.selectResult.CountScaleU, decnum);
- dataGridView_results.Rows[i].Cells[12].Value = AnalysisTools.GetDecNum(result.unSelectResult.CountScaleU, decnum);
- }
- }
- }
- private void button5_Click(object sender, EventArgs e)
- {
- this.documentWorkspace.phaseModels.RemoveAll(u => u.name == "one");
- this.Close();
- }
- private void button4_Click(object sender, EventArgs e)
- {
- if (this.dataGridView_results.Rows.Count > 0)
- {
- SaveFileDialog exe = new SaveFileDialog();
- exe.Filter = "Execl files (*.xlsx)|*.xlsx";
- exe.FilterIndex = 0;
- exe.RestoreDirectory = true;
- exe.Title = "Export Excel File";
- exe.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
- exe.FileName = PdnResources.GetString("Menu.GeneralAnalysis.TwoComparisonCases.Text") + PdnResources.GetString("Menu.Analysisresult.text") + DateTime.Now.ToString("yyyyMMddhhmmss");
- DialogResult dr = exe.ShowDialog();
- if (dr == DialogResult.OK)
- {
- DataTable dtb = new DataTable();
- foreach (DataGridViewColumn c in this.dataGridView_results.Columns)
- {
- dtb.Columns.Add(c.HeaderText);
- }
- for (int r = 0; r < this.dataGridView_results.Rows.Count; r++)
- {
- DataRow dataRow = dtb.NewRow();
- for (int c = 0; c < this.dataGridView_results.Rows[r].Cells.Count; c++)
- {
- dataRow[this.dataGridView_results.Columns[c].HeaderText] = this.dataGridView_results.Rows[r].Cells[c].Value;
- }
- dtb.Rows.Add(dataRow);
- }
- List<DataTable> list = new List<DataTable>();
- list.Add(dtb);
- this.appWorkspace.ExportDataToExcelWithProgress(list, exe.FileName, true, false, true);
- }
- }
- else
- {
- System.Windows.Forms.MessageBox.Show(PdnResources.GetString("Menu.Noanalysisresults.text") + "!");
- }
- }
- private void button1_Click(object sender, EventArgs e)
- {
- AnalyzeSettingDialog recombinationRateSetDialog = new AnalyzeSettingDialog(this, "Template.Manager.item2.TwoPhaseScale");
- if (recombinationRateSetDialog.hasModule)
- {
- recombinationRateSetDialog.StartPosition = FormStartPosition.CenterScreen;
- recombinationRateSetDialog.ShowDialog();
- }
- else
- {
- recombinationRateSetDialog = null;
- }
- }
- private void button3_Click(object sender, EventArgs e)
- {
- bitList.Clear();
- if (checkBox1.Checked)
- {
- AnalyzeSettingDialog recombinationRateSetDialog = new AnalyzeSettingDialog(this, "Template.Manager.item2.TwoPhaseScale");
- if (recombinationRateSetDialog.hasModule)
- {
- recombinationRateSetDialog.StartPosition = FormStartPosition.CenterScreen;
- recombinationRateSetDialog.ShowDialog();
- }
- else
- {
- recombinationRateSetDialog = null;
- }
- }
- if (this.analyzeSettingModel != null && !string.IsNullOrEmpty(this.analyzeSettingModel.analyzeClassify))
- {
- //获取word书签与excel单元格的关系,以字典方式存储
- List<mic_module_infos> mic_module_infos = mic_module_infos_BLL.FindAll().FindAll(a => a.analyze_classify == this.analyzeSettingModel.analyzeClassify);
- Dictionary<string, string> tagInfos = new Dictionary<string, string>();
- if (mic_module_infos != null && mic_module_infos.Count > 0)
- {
- foreach (mic_module_infos info in mic_module_infos)
- {
- tagInfos.Add(info.tag_name, info.cell_position);
- }
- }
- List<List<string>> analysisContent = new List<List<string>>();
- for (int i = 0; i < this.dataGridView_results.Rows.Count; i++)
- {
- List<string> content1 = new List<string>();
- if (i == 0)
- {
- content1.Add(this.dataGridView_results.Columns[0].HeaderText);
- content1.Add(this.dataGridView_results.Columns[1].HeaderText);
- content1.Add(this.dataGridView_results.Columns[2].HeaderText);
- content1.Add(this.dataGridView_results.Columns[3].HeaderText);
- content1.Add(this.dataGridView_results.Columns[4].HeaderText);
- content1.Add(this.dataGridView_results.Columns[5].HeaderText);
- content1.Add(this.dataGridView_results.Columns[6].HeaderText);
- content1.Add(this.dataGridView_results.Columns[7].HeaderText);
- content1.Add(this.dataGridView_results.Columns[8].HeaderText);
- content1.Add(this.dataGridView_results.Columns[9].HeaderText);
- content1.Add(this.dataGridView_results.Columns[10].HeaderText);
- content1.Add(this.dataGridView_results.Columns[11].HeaderText);
- content1.Add(this.dataGridView_results.Columns[12].HeaderText);
- analysisContent.Add(content1);
- }
- content1 = new List<string>();
- content1.Add(this.dataGridView_results.Rows[i].Cells[0].Value.ToString());
- content1.Add(this.dataGridView_results.Rows[i].Cells[1].Value.ToString());
- content1.Add(this.dataGridView_results.Rows[i].Cells[2].Value.ToString());
- content1.Add(this.dataGridView_results.Rows[i].Cells[3].Value.ToString());
- content1.Add(this.dataGridView_results.Rows[i].Cells[4].Value.ToString());
- content1.Add(this.dataGridView_results.Rows[i].Cells[5].Value.ToString());
- content1.Add(this.dataGridView_results.Rows[i].Cells[6].Value.ToString());
- content1.Add(this.dataGridView_results.Rows[i].Cells[7].Value.ToString());
- content1.Add(this.dataGridView_results.Rows[i].Cells[8].Value.ToString());
- content1.Add(this.dataGridView_results.Rows[i].Cells[9].Value.ToString());
- content1.Add(this.dataGridView_results.Rows[i].Cells[10].Value.ToString());
- content1.Add(this.dataGridView_results.Rows[i].Cells[11].Value.ToString());
- content1.Add(this.dataGridView_results.Rows[i].Cells[12].Value.ToString());
- analysisContent.Add(content1);
- string tag = this.dataGridView_results.Rows[i].Cells[0].Value.ToString();
- if (bitDic.ContainsKey(tag))
- {
- bitList.Add(bitDic[tag][0]);
- bitList.Add(bitDic[tag][1]);
- }
- }
- this.appWorkspace.CreateAnalysisReport(this.analyzeSettingModel, analysisContent, bitList, tagInfos);
- }
- else
- System.Windows.MessageBox.Show(PdnResources.GetString("Menu.Pleasesettheanalysisreportfirst.text") + "!");
- }
- private void numericUpDown1_KeyUp(object sender, KeyEventArgs e)
- {
- numericUpDown1.Value = numericUpDown1.Value;
- }
- private void numericUpDown2_KeyUp(object sender, KeyEventArgs e)
- {
- numericUpDown2.Value = numericUpDown2.Value;
- }
- private void TwoPhaseScaleDialog_Load(object sender, EventArgs e)
- {
- }
- private void TwoPhaseScaleDialog_FormClosing(object sender, FormClosingEventArgs e)
- {
- this.documentWorkspace.phaseModels.RemoveAll(u => u.name == "one");
- }
- private void button9_Click(object sender, EventArgs e)
- {
- if (this.dataGridView_results.Rows.Count == 0)
- {
- System.Windows.MessageBox.Show(PdnResources.GetString("Menu.Noresults.text"));
- return;
- }
- if (this.analyzeSettingModel == null)
- {
- System.Windows.MessageBox.Show(PdnResources.GetString("Menu.Pleasesetiirst.Text"));
- return;
- }
- //获取项目工程内的文件夹路径
- ProjectEngineering.NodeItem item = this.appWorkspace.GetInsertProjectPath(2, "Menu.GeneralAnalysis.TwoComparisonCases.Text", this.analyzeSettingModel.savePath);
- if (item != null)
- {
- //向文件夹内保存图片和报告
- if (!string.IsNullOrEmpty(this.analyzeSettingModel.analyzeClassify))
- {
- //获取word书签与excel单元格的关系,以字典方式存储
- List<mic_module_infos> mic_module_infos = mic_module_infos_BLL.FindAll().FindAll(a => a.analyze_classify == this.analyzeSettingModel.analyzeClassify);
- Dictionary<string, string> tagInfos = new Dictionary<string, string>();
- if (mic_module_infos != null && mic_module_infos.Count > 0)
- {
- foreach (mic_module_infos info in mic_module_infos)
- {
- tagInfos.Add(info.tag_name, info.cell_position);
- }
- }
- List<List<string>> analysisContent = new List<List<string>>();
- List<List<string>> inclusionList = new List<List<string>>();
- List<ExportProjectModel> exportModel = new List<ExportProjectModel>();
- List<Bitmap> bitImgList = new List<Bitmap>();
- List<string> titleContent = new List<string>();
- for (int i = 0; i < this.dataGridView_results.Rows.Count; i++)
- {
- List<string> content1 = new List<string>();
- if (i == 0)
- {
- content1.Add(this.dataGridView_results.Columns[0].HeaderText);
- content1.Add(this.dataGridView_results.Columns[1].HeaderText);
- content1.Add(this.dataGridView_results.Columns[2].HeaderText);
- content1.Add(this.dataGridView_results.Columns[3].HeaderText);
- content1.Add(this.dataGridView_results.Columns[4].HeaderText);
- content1.Add(this.dataGridView_results.Columns[5].HeaderText);
- content1.Add(this.dataGridView_results.Columns[6].HeaderText);
- content1.Add(this.dataGridView_results.Columns[7].HeaderText);
- content1.Add(this.dataGridView_results.Columns[8].HeaderText);
- content1.Add(this.dataGridView_results.Columns[9].HeaderText);
- content1.Add(this.dataGridView_results.Columns[10].HeaderText);
- content1.Add(this.dataGridView_results.Columns[11].HeaderText);
- content1.Add(this.dataGridView_results.Columns[12].HeaderText);
- analysisContent.Add(content1);
- titleContent.AddRange(content1);
- }
- content1 = new List<string>();
- content1.Add(this.dataGridView_results.Rows[i].Cells[0].Value.ToString());
- content1.Add(this.dataGridView_results.Rows[i].Cells[1].Value.ToString());
- content1.Add(this.dataGridView_results.Rows[i].Cells[2].Value.ToString());
- content1.Add(this.dataGridView_results.Rows[i].Cells[3].Value.ToString());
- content1.Add(this.dataGridView_results.Rows[i].Cells[4].Value.ToString());
- content1.Add(this.dataGridView_results.Rows[i].Cells[5].Value.ToString());
- content1.Add(this.dataGridView_results.Rows[i].Cells[6].Value.ToString());
- content1.Add(this.dataGridView_results.Rows[i].Cells[7].Value.ToString());
- content1.Add(this.dataGridView_results.Rows[i].Cells[8].Value.ToString());
- content1.Add(this.dataGridView_results.Rows[i].Cells[9].Value.ToString());
- content1.Add(this.dataGridView_results.Rows[i].Cells[10].Value.ToString());
- content1.Add(this.dataGridView_results.Rows[i].Cells[11].Value.ToString());
- content1.Add(this.dataGridView_results.Rows[i].Cells[12].Value.ToString());
- analysisContent.Add(content1);
- string tag = this.dataGridView_results.Rows[i].Cells[0].Value.ToString();
- var export = exportModel.Where(m => m.picName == tag).FirstOrDefault();
- if (export == null)
- {
- ExportProjectModel exportProjectModel = new ExportProjectModel();
- exportProjectModel.dataList = new List<List<string>>();
- exportProjectModel.dataList.Add(titleContent);
- exportProjectModel.dataList.Add(content1);
- exportProjectModel.picName = tag;
- exportProjectModel.tagName = PdnResources.GetString("Menu.GeneralAnalysis.TwoComparisonCases.Text");
- exportModel.Add(exportProjectModel);
- }
- else
- {
- exportModel[exportModel.IndexOf(export)].dataList.Add(content1);
- }
- if (bitDic.ContainsKey(tag))
- {
- bitImgList.Add(bitDic[tag][0]);
- bitImgList.Add(bitDic[tag][1]);
- }
- }
- try
- {
- this.appWorkspace.CreateAnalysisReport(this.analyzeSettingModel, analysisContent, exportModel, bitImgList, tagInfos, item.path, item.code);
- }
- catch (Exception ex)
- {
- System.Windows.MessageBox.Show(ex.Message);
- }
- }
- else
- {
- System.Windows.MessageBox.Show(PdnResources.GetString("Menu.Pleasesettheanalysisreportfirst.text") + "!");
- return;
- }
- //保存项目信息到数据库
- this.appWorkspace.InsertIntoDB(this.analyzeSettingModel, item);
- }
- }
- private void comboBox2_SelectedIndexChanged(object sender, EventArgs e)
- {
- if (this.comboBox2.SelectedIndex == -1)
- {
- return;
- }
- switch (this.comboBox2.SelectedItem.ToString())
- {
- case "面积":
- this.selectSearchIndex = 1;
- this.rb1_CheckedChanged();
- break;
- case "面积比":
- this.selectSearchIndex = 2;
- this.rb2_CheckedChanged();
- break;
- case "周长":
- this.selectSearchIndex = 3;
- this.perimeter();
- break;
- case "长轴":
- this.selectSearchIndex = 4;
- this.longAxis(1);
- break;
- case "短轴":
- this.selectSearchIndex = 5;
- this.longAxis(2);
- break;
- case "倾斜角度":
- this.selectSearchIndex = 6;
- this.slope();
- break;
- case "高度":
- this.selectSearchIndex = 7;
- this.particulatesHeight();
- break;
- case "宽度":
- this.selectSearchIndex = 8;
- this.particulatesWidth();
- break;
- case "宽高比":
- this.selectSearchIndex = 9;
- this.rb3_CheckedChanged();
- break;
- case "长径":
- this.selectSearchIndex = 10;
- this.trail(1);
- break;
- case "短径":
- this.selectSearchIndex = 11;
- this.trail(2);
- break;
- case "外接圆直径":
- this.selectSearchIndex = 12;
- this.circumscribedCircleDiameter();
- break;
- case "球化率":
- this.selectSearchIndex = 13;
- this.spheroidizationRate();
- break;
- case "等积圆直径":
- this.selectSearchIndex = 14;
- this.equalAreaCircle();
- break;
- case "最大卡规直径":
- this.selectSearchIndex = 15;
- this.rb4_CheckedChanged();
- break;
- case "最小卡规直径":
- this.selectSearchIndex = 16;
- this.minimumCaliperDiameter();
- break;
- case "平均卡规直径":
- this.selectSearchIndex = 17;
- this.averageCaliperDiameter();
- break;
- case "纤维长度":
- this.selectSearchIndex = 18;
- this.fiberLength();
- break;
- }
- }
- /// <summary>
- /// 应用全部
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void button7_Click(object sender, EventArgs e)
- {
- //if (this.listView1.FocusedItem == null)
- //{
- // return;
- //}
- //for (int i = 0; i < listView1.Items.Count; i++)
- //{
- // this.listView1.EnsureVisible(i);
- // this.listView1.Items[i].Focused = true;
- // this.listView1.Items[i].Selected = true;
- //}
- }
- /// <summary>
- /// 保存全部
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void button6_Click(object sender, EventArgs e)
- {
- }
- private void getValue(string key, Object value)
- {
- switch (key)
- {
- case "parameter1":
- comboBox2.SelectedIndex = (int)value - 1;
- break;
- case "OpenWhileExportReport":
- checkBox1.Checked = Convert.ToBoolean(value);
- break;
- case "CalculatorDecimalDigits":
- numericUpDown3.Value = Convert.ToDecimal(value);
- break;
- }
- }
- #region [脚本录制]
- private void getScriptRecording()
- {
- string className = InvariantData.path_Action + ".Action" + menuId;
- ParamObject param = (ParamObject)System.Reflection.Assembly.Load(InvariantData.assembly_Data).CreateInstance(className);
- List<Args> args = param.Lists;
- foreach (var item in args)
- {
- item.value = setScriptRecording(item.key);
- }
- appWorkspace.SetScriptStartRecording(this.menuId, menuName, args);
- }
- private object setScriptRecording(string key)
- {
- object value = null;
- switch (key)
- {
- case "parameter1":
- value = comboBox2.SelectedIndex + 1;
- break;
- case "OpenWhileExportReport":
- value = checkBox1.Checked;
- break;
- case "CalculatorDecimalDigits":
- value = numericUpDown3.Value;
- break;
- }
- return value;
- }
- #endregion
- }
- }
|