12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001 |
- 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>
- /// 选中图片的bitmap
- /// </summary>
- private Bitmap bitmap;
- /// <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.bitmap != null)
- this.documentWorkspace.ZoomIn();
- }
- private void zoomOutButton_Click(object sender, EventArgs e)
- {
- if (this.bitmap != 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.bitmap = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].CompositionSurface.CreateAliasedBitmap();
- Document document = Document.FromImage(bitmap);
- 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);
- this.panel1.Paint += new System.Windows.Forms.PaintEventHandler(this.panel1_Paint);
- //
- // 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 panel1_Paint(object sender, PaintEventArgs e)
- {
- }
- 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
- }
- }
|