GrainSizeStandardDialog.cs 273 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534
  1. using OpenCvSharp;
  2. using PaintDotNet.Base.CommTool;
  3. using PaintDotNet.Base.Functionodel;
  4. using PaintDotNet.CustomControl;
  5. using PaintDotNet.DbOpreate.DbModel;
  6. using PaintDotNet.Instrument;
  7. using System;
  8. using System.Linq;
  9. using System.Collections;
  10. using System.Collections.Generic;
  11. using System.ComponentModel;
  12. using System.Drawing;
  13. using System.Drawing.Drawing2D;
  14. using System.Windows.Forms;
  15. using PaintDotNet.DedicatedAnalysis.GrainSizeStandard.IntegrationClass;
  16. using PaintDotNet.Base.DedicatedAnalysis.GrainSize;
  17. using Metis.ParameterSet;
  18. using PaintDotNet.Data.Param;
  19. using PaintDotNet.Base;
  20. using System.IO;
  21. using OpenCvSharp.Extensions;
  22. using PaintDotNet.Base.SettingModel;
  23. namespace PaintDotNet.DedicatedAnalysis.GrainSizeStandard
  24. {
  25. internal class GrainSizeStandardDialog : PdnBaseForm
  26. {
  27. /// <summary>
  28. /// 晶粒度标准的方法类型(0 截点法/截距法, 1 面积法)
  29. /// </summary>
  30. private int grainMethodType = -1;
  31. /// <summary>
  32. /// 晶粒度标准集成
  33. /// </summary>
  34. protected GrainSizeStandardClass GSSClass = new GrainSizeStandardClass();
  35. #region 内部属性
  36. /// <summary>
  37. /// 主控件
  38. /// </summary>
  39. protected AppWorkspace appWorkspace;
  40. /// <summary>
  41. /// 平均截距
  42. /// </summary>
  43. private double value_111 = -1;
  44. /// <summary>
  45. /// 二值化集成
  46. /// </summary>
  47. protected BinaryClass binaryClass;
  48. /// <summary>
  49. /// 公共按钮
  50. /// </summary>
  51. private CommonControlButtons commonControlButtons;
  52. /// <summary>
  53. /// 图像面板
  54. /// </summary>
  55. protected DocumentWorkspaceWindow documentWorkspace;
  56. /// <summary>
  57. /// 当前选择的图片
  58. /// </summary>
  59. protected Bitmap bitmap;
  60. /// <summary>
  61. /// 当前选择的图片
  62. /// </summary>
  63. protected Mat matOrg;
  64. /// <summary>
  65. /// 相0的图片,处理多视场使用
  66. /// </summary>
  67. protected Mat PhaseModel0Mat
  68. {
  69. get
  70. {
  71. if (binaryClass.PhaseModels0Mat != null)
  72. return binaryClass.PhaseModels0Mat;
  73. return this.documentWorkspace.PhaseModels[0].mat;
  74. }
  75. }
  76. /// <summary>
  77. /// 防止进入页面时错误提示辅助线选项信息
  78. /// </summary>
  79. public bool comboboxChange = true;
  80. /// <summary>
  81. /// 当前选择图片的Index
  82. /// </summary>
  83. protected int selectPicture = -1;
  84. /// <summary>
  85. /// 调色板
  86. /// </summary>
  87. private ColorsForm colorsFormGrid;
  88. private Panel panelC;
  89. /// <summary>
  90. /// 保存用于生成报告的图片
  91. /// </summary>
  92. private List<Bitmap> bitList;
  93. /// <summary>
  94. /// 储存点击保存结果后的所有原图与分析图
  95. /// </summary>
  96. protected Dictionary<string, List<Bitmap>> bitDic = new Dictionary<string, List<Bitmap>>();
  97. /// <summary>
  98. /// 中间数据
  99. /// </summary>
  100. protected List<ExportProjectModel> tempDataModel = new List<ExportProjectModel>();
  101. /// <summary>
  102. /// 分析结果暂存
  103. /// </summary>
  104. protected List<System.Data.DataTable> dataTable_Totals = new List<System.Data.DataTable>();
  105. /// <summary>
  106. /// GBT6394面积法 分析结果暂存 -视场面积(Dictionary<string, object>的key为"RectArea")
  107. /// </summary>
  108. private Dictionary<string, Dictionary<string, object>> dict_Totals = new Dictionary<string, Dictionary<string, object>>();
  109. /// <summary>
  110. /// 详细分析结果暂存
  111. /// </summary>
  112. protected List<System.Data.DataTable> dataTables = new List<System.Data.DataTable>();
  113. /// <summary>
  114. /// 全部显示
  115. /// </summary>
  116. protected bool allShow = false;
  117. /// <summary>
  118. /// 详细列表需要求和的index集合
  119. /// </summary>
  120. protected List<int> IndexChangedFromIndex = new List<int>();
  121. /// <summary>
  122. /// 列表需要求和的index集合,value值为:1 求和 2:平均 3:级别计算 + [输入数据index位置,-1则需要调用自定义方法进行计算]
  123. /// </summary>
  124. protected Dictionary<int, int[]> IndexChangedToIndex = new Dictionary<int, int[]>();
  125. /// <summary>
  126. /// 详细列表不需要格式化的字符串数据
  127. /// </summary>
  128. protected List<int> DetailListStringIndex = new List<int>();
  129. /// <summary>
  130. /// 详细列表不需要按double排序的字符串数据
  131. /// </summary>
  132. protected List<int> DetailListNotDoubleIndex = new List<int>();
  133. /// <summary>
  134. /// 为了解决标题文字相同的标准,只能使用name赋值每列的数据
  135. /// </summary>
  136. protected bool HeaderTextUsable = true;
  137. /// <summary>
  138. /// 是否脚本运行
  139. /// </summary>
  140. private Boolean initScriptValues = false;
  141. /// <summary>
  142. /// 数值大于0,则窗口初始化数据完成
  143. /// </summary>
  144. private int finishedLoadAction = -1;
  145. /// <summary>
  146. /// 当前菜单的唯一id
  147. /// </summary>
  148. private int menuId;
  149. private string menuName;
  150. /// <summary>
  151. /// 保存窗口参数
  152. /// </summary>
  153. private GrainSizeAnalysisModel analysisModel;
  154. /// <summary>
  155. /// 保存所有窗口的参数
  156. /// </summary>
  157. private Dictionary<string, GrainSizeAnalysisModel> analysisDict = new Dictionary<string, GrainSizeAnalysisModel>();
  158. /// <summary>
  159. /// 应用到全部之前,记住当前选择的窗口
  160. /// </summary>
  161. private int currentOldSelectIndex = -1;
  162. /// <summary>
  163. /// 晶界重现-保存所有窗口的参数 应用则计算,不应用则清空Mat。应用到全部则提前清空Mat和Model
  164. /// </summary>
  165. private Dictionary<string, Base.SettingModel.GrainBoundryDectModel> grainBoundaryDict = new Dictionary<string, Base.SettingModel.GrainBoundryDectModel>();
  166. /// <summary>
  167. /// 晶界重现-保存所有窗口的计算结果 应用则计算,不应用则清空
  168. /// </summary>
  169. protected Dictionary<string, Mat> grainBoundaryMatDict = new Dictionary<string, Mat>();
  170. protected Dictionary<string, Mat> everyImgPhaseDict = new Dictionary<string, Mat>();
  171. /// <summary>
  172. /// 面积法晶界颜色-保存所有窗口的计算结果 保存结果时一起保存,重新保存则替换
  173. /// </summary>
  174. protected Dictionary<string, Mat> grainColorsMatDict = new Dictionary<string, Mat>();
  175. //private Dictionary<string, Color> grainBoundaryColorDict = new Dictionary<string, Color>();
  176. //string xmlFilePath = Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\GrainSizeAnalyze\\GrainBoundryDectModel_" + this.menuId + ".xml";
  177. //bool createNewFile = !System.IO.File.Exists(xmlFilePath);
  178. // if (createNewFile)
  179. // return;
  180. // Base.SettingModel.GrainBoundryDectModel grainBoundryDectModel = Base.CommTool.XmlSerializeHelper.DESerializer<Base.SettingModel.GrainBoundryDectModel>(Base.CommTool.FileOperationHelper.ReadStringFromFile(xmlFilePath, System.IO.FileMode.Open));
  181. //sigma = grainBoundryDectModel.sigma;
  182. // textBox6.Text = sigma + "";
  183. // grainApplygrainboundaries = grainBoundryDectModel.grainApplygrainboundaries;
  184. // this.applyRadioButton1.Checked = (grainApplygrainboundaries == 1);
  185. // m_iStandardImage = grainBoundryDectModel.m_iStandardImage;
  186. protected static string ParamKey_displaygrainboundaries = "displaygrainboundaries";//显示晶界
  187. protected static string ParamKey_displaygrid = "displaygrid";//显示网格
  188. protected static string ParamKey_displaysections = "displaysections";//显示截点
  189. protected static string ParamKey_comboBox1SelectedItem = "comboBox1SelectedItem";//选择的辅助线
  190. protected static string ParamKey_ShowGrainNumber = "ShowGrainNumber";//显示晶粒编号
  191. protected static string ParamKey_ShowGrainColor = "ShowGrainColor";//用不同颜色显示晶粒
  192. protected static string ParamKey_CalculatorDecimalDigits = "CalculatorDecimalDigits";//小数点位数
  193. protected static string ParamKey_OpenWhileExportReport = "OpenWhileExportReport";//生成报告时打开设置//#22009 22010
  194. protected static string ParamKey_TargetSelection = "TargetSelection";//目标选择
  195. #endregion
  196. #region 组件
  197. private GroupBox groupBox_operating;
  198. protected GroupBox groupBox_img;
  199. protected ListView lstView_img;
  200. private ImageList imageList_img;
  201. private IContainer components;
  202. protected GroupBox groupBox_review;
  203. protected GroupBox groupBox_report;
  204. private Label label_resultPrecision;
  205. private Button button_exportResults;
  206. private Button button_generateReport;
  207. protected GroupBox groupBox6groupBox_analysisResult2;
  208. protected GroupBox groupBox_analysisResult1;
  209. private Button button_setting;
  210. private CheckBox checkBox_generateReport_opensetting;
  211. protected GroupBox groupBox3;
  212. private Button button9;
  213. protected ComboBox comboBox1;
  214. protected DataGridView dataGridView2;
  215. protected ListView listView2;
  216. private Button button16;
  217. private Button button12;
  218. private Button button11;
  219. private NumericUpDown numericUpDown1_0;
  220. private Button button1;
  221. private BinaryControlSmaller bc;
  222. protected DataGridView dataGridView_Total;
  223. protected Button btn_saveresult;
  224. protected Button button_ApplyToAll;
  225. protected Button button_SaveAll;
  226. private Button threeDButton;
  227. protected Button btn_Grainboundarytoreproduce;
  228. private Base.SettingModel.GrainBoundryDectModel GrainBoundryDectModel;
  229. private Mat OrgImg0;
  230. #endregion
  231. #region 构造函数
  232. /// <summary>
  233. /// 构造函数
  234. /// </summary>
  235. /// <param name="appWorkspace"></param>
  236. /// <param name="grainMethodType">晶粒度标准的方法类型(0 截点法/截距法, 1 面积法)</param>
  237. public GrainSizeStandardDialog(AppWorkspace appWorkspace, PdnMenuItem menuItem, MethodOfAssessment methodOfAssessment, int grainMethodType = 1)
  238. {
  239. this.menuId = menuItem.MenuId;
  240. this.menuName = menuItem.Text;
  241. this.appWorkspace = appWorkspace;
  242. this.Icon = PdnInfo.AppIcon;
  243. this.colorsFormGrid = new ColorsForm();
  244. this.colorsFormGrid.StartPosition = FormStartPosition.CenterScreen;
  245. this.colorsFormGrid.setSaveBtn_Click(new System.EventHandler(this.gridColorChanged));
  246. if (GSSClass.InitDialogMethod(methodOfAssessment))
  247. {
  248. this.grainMethodType = grainMethodType;
  249. SetAnalyzeModelFromXml(GSSClass.methodOfAssessment.resourcesName);
  250. }
  251. else
  252. {
  253. this.grainMethodType = grainMethodType;
  254. if (!GSSClass.InitComboboxValue())
  255. {
  256. if (grainMethodType == 1)
  257. GSSClass.GuideClass.createGuideAreaClassModelsNamed(getModelName());
  258. else if (grainMethodType == 0)
  259. GSSClass.GuideClass.createGuideClassModelsNamed(getModelName());
  260. }
  261. SetAnalyzeModelFromXml(getTemplateName());
  262. }
  263. InitializeComponent();
  264. this.binaryClass = new BinaryClass(menuId);
  265. this.binaryClass.ShowDrawClassView = ShowDrawClassView();
  266. InitializeLanguageText();
  267. Initialize();
  268. SubclassInitialize();
  269. //如果是脚本执行,将参数带入
  270. if (appWorkspace.ScriptRunning && appWorkspace.ScriptCurrentParam != null && (int)appWorkspace.ScriptCurrentParam.MenuId == menuId)
  271. {
  272. this.initScriptValues = true;//ScriptAutomatic
  273. ////在这里反射出对应功能的参数类
  274. string className = InvariantData.path_Action + ".Action" + menuId;
  275. ParamObject param = (ParamObject)System.Reflection.Assembly.Load(InvariantData.assembly_Data).CreateInstance(className);
  276. foreach (Args arg in param.Lists)
  277. {
  278. Args param1 = appWorkspace.ScriptCurrentParam.Lists.Find(m => m.Key.Equals(arg.Key));
  279. if (param1.value != null)
  280. arg.Value = param1.value;
  281. //获取晶界重现参数
  282. getBinary(arg.Key, arg.Value);
  283. }
  284. this.analysisModel = GrainSizeAnalysisModel.cloneListParamScript(param);
  285. foreach (var item in this.analysisModel.ListParam)
  286. item.setValue();
  287. getSonData();
  288. if (this.GrainBoundryDectModel != null) {
  289. string xmlFilePath = Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\GrainSizeAnalyze\\GrainBoundryDectModel_" + this.menuId + ".xml";
  290. string userInfoXml = XmlSerializeHelper.XmlSerialize<GrainBoundryDectModel>(this.GrainBoundryDectModel);
  291. FileOperationHelper.WriteStringToFile(userInfoXml, xmlFilePath, FileMode.Create);
  292. this.applyDect();
  293. }
  294. }
  295. else
  296. {//读取上次关闭窗口时保存的参数
  297. string filePath = Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\GrainSizeAnalyze\\GrainSizeAnalysisModel.xml";
  298. GrainSizeAnalysisModel analysisModelXml = XmlSerializeHelper.DESerializer<GrainSizeAnalysisModel>(FileOperationHelper.ReadStringFromFile(filePath, System.IO.FileMode.Open));
  299. this.analysisModel = analysisModelXml.cloneListParamModel(this.menuId);
  300. foreach (var item in this.analysisModel.ListParam)
  301. item.setValue();
  302. }
  303. //初始化头
  304. this.listView2.View = View.Details;
  305. ColumnHeader header0 = new ColumnHeader();
  306. header0.Text = "";
  307. header0.Width = 180;
  308. this.listView2.Columns.Add(header0);
  309. //二值化集成2
  310. bc.OriginCheckedChangedAction += new EventHandler(this.bcOriginCheckedChanged);//初始化原图勾选改变事件
  311. binaryClass.createDocumentItemsSmaller(new string[] { PdnResources.GetString("Menu.BinaryAction.BinaryExtraction.Text"), PdnResources.GetString("Menu.Grainboundarytoreproduce.text"), PdnResources.GetString("Menu.Thegrainsareshownindifferentcolors.text") }
  312. , this.bc, this.appWorkspace, this.documentWorkspace, this.lstView_img);//初始化相的工作结构
  313. //如果是脚本执行,将参数带入二值化集成2 之后:
  314. appWorkspace.ScriptCurrentParam = null;//阻止第二次进入仍然被赋值参数
  315. binaryClass.BinaryImplFinishAction += new EventHandler(this.bClassBinaryImplFinishAction);//二值化后续处理事件
  316. //InitComboboxValue(null);
  317. this.button11.Visible = true;
  318. this.button16.Visible = false;
  319. this.Shown += new EventHandler(this.ShownChoiseItemAndInitData);
  320. }
  321. #region [晶界重现-脚本相关]
  322. /// <summary>
  323. /// 脚本获取晶界重现参数
  324. /// </summary>
  325. private void getBinary(string key, Object value)
  326. {
  327. GrainBoundryDectModel = new Base.SettingModel.GrainBoundryDectModel();
  328. switch (key)
  329. {
  330. case "GrainApplygrainboundaries":
  331. GrainBoundryDectModel.grainApplygrainboundaries = Convert.ToInt32(value);
  332. break;
  333. case "lineColor":
  334. GrainBoundryDectModel.grainColor = Convert.ToInt32(value);
  335. break;
  336. case "GrainIConnect":
  337. GrainBoundryDectModel.iConnect = Convert.ToInt32(value);
  338. break;
  339. case "GrainDisplaysections":
  340. GrainBoundryDectModel.enhance = Convert.ToBoolean(value) ? 1 : 0;
  341. break;
  342. case "GrainSigma":
  343. GrainBoundryDectModel.sigma = Convert.ToDouble(value);
  344. break;
  345. case "GrainCell_size1":
  346. List<double> twoL = (List<double>)value;
  347. GrainBoundryDectModel.cell1_size = (int)twoL[0];
  348. GrainBoundryDectModel.cell2_size = (int)twoL[1];
  349. break;
  350. case "GrainDark":
  351. GrainBoundryDectModel.dark = Convert.ToInt32(value);
  352. break;
  353. case "GrainSmooth_type":
  354. GrainBoundryDectModel.smooth_type = Convert.ToInt32(value);
  355. break;
  356. case "GrainM_iStandardImage":
  357. GrainBoundryDectModel.m_iStandardImage = Convert.ToInt32(value);
  358. break;
  359. }
  360. }
  361. private void applyDect()
  362. {
  363. Bitmap bitmap = this.appWorkspace.DocumentWorkspaces[index].CompositionSurface.CreateAliasedBitmap();
  364. if (this.documentWorkspace.PhaseModels.Count == 0) {
  365. return;
  366. }
  367. Mat PhaseModel0MatCopy = this.documentWorkspace.PhaseModels[0].mat.Clone();
  368. double sigma = this.GrainBoundryDectModel.sigma;
  369. Mat OrgImg = BitmapConverter.ToMat(bitmap);// OpenCvSharp.Cv2.ImRead(inputImageFile);
  370. int grainApplygrainboundaries = this.GrainBoundryDectModel.grainApplygrainboundaries;
  371. int m_iStandardImage = this.GrainBoundryDectModel.m_iStandardImage;
  372. int iConnect = this.GrainBoundryDectModel.iConnect;
  373. /*int */
  374. int dark = this.GrainBoundryDectModel.dark;// 2;//指定晶界类型,暗晶界dark=1, 否则dark=0, dark=2梯度
  375. /*int */
  376. int smooth_type = this.GrainBoundryDectModel.smooth_type;// 1;//去噪类型: 高斯平滑: smooth_type=0; 方向平滑: smooth_type=1
  377. //double sigma = double.Parse(textBox6.Text);// 0.5;//如果是高斯平滑,则指定高斯sigma,如果是方向平滑 则忽略此参数
  378. /*int */
  379. int enhance = this.GrainBoundryDectModel.enhance;// 1;//是否增强晶界?不增强:enhance=0; 增强: enhance=1
  380. /*double[] */
  381. double[] cell_size = new double[2] { this.GrainBoundryDectModel.cell1_size, this.GrainBoundryDectModel.cell2_size }; ;// new double[2] { 0.01, 500 };//晶界大小
  382. procClass = new ProgressThreadProcClass();
  383. procClass.StartProgressAutoAction(this, new System.Threading.ThreadStart(applyDectAction), PdnResources.GetString("Menu.Grainboundarytoreproduce.text"));
  384. if (OrgImg0 != null)
  385. {
  386. if (this.documentWorkspace.GraphicsList.IsExsitView() && ShowDrawClassView())
  387. {
  388. Vec4b vec4 = new Vec4b(0, 0, 0, 0);
  389. //视场图像
  390. Mat exsitViewMatOrg = OpenCvSharp.Extensions.BitmapConverter.ToMat(this.documentWorkspace.GetFullSizeWithRegion());
  391. for (int y = 0; y < exsitViewMatOrg/*temp*/.Rows; y++)
  392. {
  393. for (int x = 0; x < exsitViewMatOrg/*temp*/.Cols; x++)
  394. {
  395. if (exsitViewMatOrg.At<Vec4b>(y, x).Item3 == 0)
  396. OrgImg0.Set(y, x, vec4);//不在视场图像范围内
  397. }
  398. }
  399. }
  400. this.documentWorkspace.PhaseModels[0].mat = OrgImg0.Clone();
  401. this.documentWorkspace.Refresh();
  402. if (PhaseModel0MatCopy != null)
  403. {
  404. PhaseModel0MatCopy.Dispose();
  405. PhaseModel0MatCopy = null;
  406. }
  407. PhaseModel0MatCopy = this.documentWorkspace.PhaseModels[0].mat.Clone();
  408. //this.resetOperationsAction();
  409. OrgImg0 = null;
  410. }
  411. if (OrgImg != null)
  412. {
  413. OrgImg.Dispose();
  414. OrgImg = null;
  415. }
  416. }
  417. #endregion
  418. private void ShownChoiseItemAndInitData(object sender, EventArgs e)
  419. {
  420. //二值化集成3
  421. this.binaryClass.loadParams();
  422. this.binaryClass.guideClass = GSSClass.GuideClass;
  423. this.binaryClass.comboBox1 = this.comboBox1;
  424. if (index > -1)
  425. {
  426. //滚动到指定的行位置
  427. if (index >= 0 && index < this.lstView_img.Items.Count)
  428. this.lstView_img.EnsureVisible(index); //选中行 //##21319
  429. if (this.lstView_img.FocusedItem != null && this.lstView_img.FocusedItem.Selected || this.lstView_img.SelectedItems != null && this.lstView_img.SelectedItems.Count > 0)
  430. {
  431. if (this.selectPicture == index/*this.lstView_img.FocusedItem.Index*/)
  432. return;
  433. this.bitmap = this.appWorkspace.DocumentWorkspaces[index/*this.lstView_img.FocusedItem.Index*/].CompositionSurface.CreateAliasedBitmap();
  434. matOrg = OpenCvSharp.Extensions.BitmapConverter.ToMat(bitmap);
  435. //二值化集成4
  436. //if (!is###OtherGrainSizeStandardDialog)
  437. {
  438. if (ShowDrawClassView())
  439. binaryClass.listView1_SelectedIndexChanged(this.bitmap);
  440. else
  441. binaryClass.listView1_SelectedIndexChangedHideDrawClassView(this.bitmap, getCurrentWorkTag());
  442. this.bcOriginCheckedChanged(null, null);
  443. }
  444. if (!this.analysisDict.ContainsKey(getCurrentWorkTag()))
  445. this.analysisDict.Add(getCurrentWorkTag(), this.analysisModel/*.cloneListParamModel(this.menuId)*/);
  446. else
  447. this.analysisDict[getCurrentWorkTag()] = this.analysisModel/*.cloneListParamModel(this.menuId)*/;
  448. //this.analysisModel = this.analysisDict[getCurrentWorkTag()];
  449. //if (GSSClass.massLabelPointsList != null && GSSClass.massLabelPointsList.Count > 0)
  450. //{
  451. // GSSClass.massLabelPointsList.Clear();//1013###19098(切换图片的时候前一张图的信息不遗留显示)}
  452. // this.documentWorkspace.Refresh();//######
  453. //}
  454. ////if (this.checkBox1.Checked)
  455. ////{
  456. //// this.documentWorkspace.PhaseModels[1].choise = true;//#########################
  457. //// this.applyDect();
  458. ////}
  459. this.selectPicture = index;// this.lstView_img.FocusedItem.Index;
  460. GSSClass.GuideClass.guideModel.loctation = new PointF(this.documentWorkspace.CompositionSurface.Width / 2, this.documentWorkspace.CompositionSurface.Height / 2);
  461. //UpdateGuideStyle(true);//19845
  462. InitRectangleF(false);
  463. AddRectangleToRectangleFCaps();
  464. refreshWhileImgChanged();
  465. }
  466. InitComboboxValue(null);
  467. try
  468. {
  469. object ItemStringObject;
  470. if (GetParamValue1(ParamKey_comboBox1SelectedItem, out ItemStringObject)) {
  471. try
  472. {
  473. this.comboBox1.SelectedIndex = Convert.ToInt32(ItemStringObject);
  474. }
  475. catch (Exception)
  476. {
  477. this.comboBox1.SelectedItem = (string)ItemStringObject;
  478. }
  479. }
  480. }
  481. catch (Exception exc)
  482. {
  483. System.Console.WriteLine("this.comboBox1.SelectedItem: " + exc.ToString());
  484. }
  485. }
  486. //// 初始化数据
  487. //this.bitmap = this.appWorkspace.DocumentWorkspaces[index].CompositionSurface.CreateAliasedBitmap();
  488. //Document document = Document.FromImage(bitmap);
  489. //this.documentWorkspace.Document = document;
  490. //this.documentWorkspace.Visible = true;
  491. //this.documentWorkspace.GraphicsList = this.appWorkspace.DocumentWorkspaces[index].GraphicsList;
  492. //this.applyButtonImpl(null, null);
  493. object ShowGrainBoundry;//#21752
  494. if (GetParamValue1(ParamKey_CalculatorDecimalDigits, out ShowGrainBoundry))//小数点位数
  495. this.numericUpDown1_0.Value = (int)ShowGrainBoundry;
  496. if (GetParamValue1(ParamKey_OpenWhileExportReport, out ShowGrainBoundry))//生成报告时打开设置
  497. this.checkBox_generateReport_opensetting.Checked = (bool)ShowGrainBoundry;
  498. ////显示直方图
  499. //this.histogramControl1.CreateHistogram(this.bitmap, true, 339, 130, 0);
  500. this.finishedLoadAction++;
  501. if (this.finishedLoadAction > 0 && this.initScriptValues && this.appWorkspace.ScriptAutomatic)
  502. this.startScriptAutomaticAction();
  503. }
  504. /// <summary>
  505. /// 执行脚本自动化的步骤
  506. /// </summary>
  507. private void startScriptAutomaticAction()
  508. {
  509. this.button_ApplyToAll.PerformClick();
  510. this.button_SaveAll.PerformClick();
  511. for (int j = 0; j < this.listView2.Items.Count; j++)
  512. this.listView2.Items[j].Selected = true;
  513. object ItemStringObject;
  514. if (GetParamValue1("ExportResults", out ItemStringObject)
  515. && (bool)ItemStringObject)//导出结果
  516. this.button_exportResults.PerformClick();
  517. if (GetParamValue1("ExportReports", out ItemStringObject)
  518. && (bool)ItemStringObject)//生成报告
  519. this.button_generateReport.PerformClick();
  520. if (GetParamValue1("ExportProjects", out ItemStringObject)
  521. && (bool)ItemStringObject)//导出项目
  522. this.button1.PerformClick();
  523. //List<Args> dedicatedLists = new List<Args>();
  524. //IntegerNumber seven = new IntegerNumber(0, 10);
  525. //seven.key = "CalculatorDecimalDigits";
  526. //seven.name = "小数点位数";
  527. //seven.initialValue = 2;
  528. //seven.value = 2;
  529. //dedicatedLists.Add(seven);
  530. //dedicatedLists.Add(new BooleanObject("OpenWhileExportReport", "生成报告时打开设置", true, null));
  531. //dedicatedLists.Add(new BooleanObject("ExportResults", "导出结果", true, null));
  532. //dedicatedLists.Add(new BooleanObject("ExportReports", "生成报告", true, null));
  533. //dedicatedLists.Add(new BooleanObject("ExportProjects", "导出项目", true, null));
  534. this.appWorkspace.ScriptAutomatic = false;
  535. this.Close();
  536. }
  537. public GrainSizeStandardDialog()
  538. {
  539. InitializeComponent();
  540. }
  541. #endregion
  542. #region 初始化组件
  543. private void InitializeLanguageText()
  544. {
  545. //
  546. // bc
  547. //
  548. this.bc = new PaintDotNet.CustomControl.BinaryControlSmaller();
  549. this.bc.BinaryBackColor = System.Drawing.Color.Red;
  550. this.bc.BinaryChecked = false;
  551. this.bc.BinaryStyle = 1;
  552. this.bc.Location = new System.Drawing.Point(176, 70);
  553. this.bc.Name = "bc";
  554. this.bc.OriginChecked = false;
  555. this.bc.scope1End = 0D;
  556. this.bc.scope1Start = 0D;
  557. this.bc.scope2End = 0D;
  558. this.bc.scope2Start = 0D;
  559. this.bc.scope3End = 0D;
  560. this.bc.scope3Start = 0D;
  561. this.bc.Size = new System.Drawing.Size(360, 247);
  562. this.bc.TabIndex = 38;
  563. this.Controls.Add(this.bc);
  564. this.Controls.SetChildIndex(this.bc, 0);
  565. this.button9.Text = PdnResources.GetString("Menu.Auxiliarylinesettings.text");
  566. this.groupBox3.Text = PdnResources.GetString("Menu.Tools.GridLine.Text");
  567. this.button11.Text = PdnResources.GetString("Menu.Showall.text");
  568. this.button16.Text = PdnResources.GetString("Menu.Cancelshowall.text");
  569. this.button12.Text = PdnResources.GetString("Menu.Edit.Delete.Text");
  570. this.groupBox_analysisResult1.Text = PdnResources.GetString("Menu.Analysisresult.text");
  571. this.button_generateReport.Text = PdnResources.GetString("Menu.Tools.CreateReport.Text");
  572. this.button_exportResults.Text = PdnResources.GetString("Menu.Exportresults.text");
  573. this.label_resultPrecision.Text = PdnResources.GetString("Menu.Decimal.text");
  574. this.button1.Text = PdnResources.GetString("Menu.Exportproject.text");
  575. this.threeDButton.Text = "3D效果";
  576. this.groupBox_img.Text = PdnResources.GetString("Menu.Tools.ImageIndex.Text");
  577. this.groupBox_review.Text = PdnResources.GetString("Menu.Preview.text");
  578. this.btn_saveresult.Text = PdnResources.GetString("Menu.Saveresult.text");
  579. this.btn_Grainboundarytoreproduce.Text = PdnResources.GetString("Menu.Grainboundarytoreproduce.text");
  580. this.button_ApplyToAll.Text = "应用到全部";
  581. this.button_SaveAll.Text = "保存全部";
  582. this.button_setting.Text = PdnResources.GetString("Menu.Setting.Text");
  583. this.groupBox_operating.Text = PdnResources.GetString("Menu.operation.text");
  584. this.checkBox_generateReport_opensetting.Text = PdnResources.GetString("Menu.Opensettingsatingreport.text");
  585. }
  586. private void InitializeComponent()
  587. {
  588. this.components = new System.ComponentModel.Container();
  589. System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle();
  590. System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle();
  591. this.groupBox_operating = new System.Windows.Forms.GroupBox();
  592. this.button_SaveAll = new System.Windows.Forms.Button();
  593. this.button_ApplyToAll = new System.Windows.Forms.Button();
  594. this.checkBox_generateReport_opensetting = new System.Windows.Forms.CheckBox();
  595. this.button_setting = new System.Windows.Forms.Button();
  596. this.btn_saveresult = new System.Windows.Forms.Button();
  597. this.btn_Grainboundarytoreproduce = new System.Windows.Forms.Button();
  598. this.groupBox_img = new System.Windows.Forms.GroupBox();
  599. this.lstView_img = new System.Windows.Forms.ListView();
  600. this.imageList_img = new System.Windows.Forms.ImageList(this.components);
  601. this.groupBox_review = new System.Windows.Forms.GroupBox();
  602. this.groupBox_report = new System.Windows.Forms.GroupBox();
  603. this.threeDButton = new System.Windows.Forms.Button();
  604. this.button1 = new System.Windows.Forms.Button();
  605. this.numericUpDown1_0 = new System.Windows.Forms.NumericUpDown();
  606. this.label_resultPrecision = new System.Windows.Forms.Label();
  607. this.button_exportResults = new System.Windows.Forms.Button();
  608. this.button_generateReport = new System.Windows.Forms.Button();
  609. this.groupBox6groupBox_analysisResult2 = new System.Windows.Forms.GroupBox();
  610. this.dataGridView_Total = new System.Windows.Forms.DataGridView();
  611. this.dataGridView2 = new System.Windows.Forms.DataGridView();
  612. this.groupBox_analysisResult1 = new System.Windows.Forms.GroupBox();
  613. this.button11 = new System.Windows.Forms.Button();
  614. this.listView2 = new System.Windows.Forms.ListView();
  615. this.button16 = new System.Windows.Forms.Button();
  616. this.button12 = new System.Windows.Forms.Button();
  617. this.groupBox3 = new System.Windows.Forms.GroupBox();
  618. this.button9 = new System.Windows.Forms.Button();
  619. this.comboBox1 = new System.Windows.Forms.ComboBox();
  620. this.groupBox_operating.SuspendLayout();
  621. this.groupBox_img.SuspendLayout();
  622. this.groupBox_report.SuspendLayout();
  623. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1_0)).BeginInit();
  624. this.groupBox6groupBox_analysisResult2.SuspendLayout();
  625. ((System.ComponentModel.ISupportInitialize)(this.dataGridView_Total)).BeginInit();
  626. ((System.ComponentModel.ISupportInitialize)(this.dataGridView2)).BeginInit();
  627. this.groupBox_analysisResult1.SuspendLayout();
  628. this.groupBox3.SuspendLayout();
  629. this.SuspendLayout();
  630. //
  631. // groupBox_operating
  632. //
  633. this.groupBox_operating.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
  634. | System.Windows.Forms.AnchorStyles.Right)));
  635. this.groupBox_operating.Controls.Add(this.button_SaveAll);
  636. this.groupBox_operating.Controls.Add(this.button_ApplyToAll);
  637. this.groupBox_operating.Controls.Add(this.checkBox_generateReport_opensetting);
  638. this.groupBox_operating.Controls.Add(this.button_setting);
  639. this.groupBox_operating.Controls.Add(this.btn_saveresult);
  640. this.groupBox_operating.Controls.Add(this.btn_Grainboundarytoreproduce);
  641. this.groupBox_operating.Location = new System.Drawing.Point(13, 12);
  642. this.groupBox_operating.Name = "groupBox_operating";
  643. this.groupBox_operating.Size = new System.Drawing.Size(1102, 53);
  644. this.groupBox_operating.TabIndex = 12;
  645. this.groupBox_operating.TabStop = false;
  646. //
  647. // button_SaveAll
  648. //
  649. this.button_SaveAll.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
  650. this.button_SaveAll.Location = new System.Drawing.Point(993, 20);
  651. this.button_SaveAll.Name = "button_SaveAll";
  652. this.button_SaveAll.Size = new System.Drawing.Size(75, 23);
  653. this.button_SaveAll.TabIndex = 8;
  654. this.button_SaveAll.UseVisualStyleBackColor = true;
  655. this.button_SaveAll.Click += new System.EventHandler(this.button_SaveAll_Click);
  656. //
  657. // button_ApplyToAll
  658. //
  659. this.button_ApplyToAll.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
  660. this.button_ApplyToAll.Location = new System.Drawing.Point(751, 20);
  661. this.button_ApplyToAll.Name = "button_ApplyToAll";
  662. this.button_ApplyToAll.Size = new System.Drawing.Size(75, 23);
  663. this.button_ApplyToAll.TabIndex = 7;
  664. this.button_ApplyToAll.UseVisualStyleBackColor = true;
  665. this.button_ApplyToAll.Click += new System.EventHandler(this.button_ApplyToAll_Click);
  666. //
  667. // checkBox_generateReport_opensetting
  668. //
  669. this.checkBox_generateReport_opensetting.AutoSize = true;
  670. this.checkBox_generateReport_opensetting.ForeColor = System.Drawing.SystemColors.ActiveCaptionText;
  671. this.checkBox_generateReport_opensetting.Location = new System.Drawing.Point(91, 24);
  672. this.checkBox_generateReport_opensetting.Name = "checkBox_generateReport_opensetting";
  673. this.checkBox_generateReport_opensetting.Size = new System.Drawing.Size(15, 14);
  674. this.checkBox_generateReport_opensetting.TabIndex = 6;
  675. this.checkBox_generateReport_opensetting.UseVisualStyleBackColor = true;
  676. //
  677. // button_setting
  678. //
  679. this.button_setting.Location = new System.Drawing.Point(6, 20);
  680. this.button_setting.Name = "button_setting";
  681. this.button_setting.Size = new System.Drawing.Size(75, 23);
  682. this.button_setting.TabIndex = 4;
  683. this.button_setting.UseVisualStyleBackColor = true;
  684. this.button_setting.Click += new System.EventHandler(this.button_setting_Click);
  685. //
  686. // btn_saveresult
  687. //
  688. this.btn_saveresult.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
  689. this.btn_saveresult.Location = new System.Drawing.Point(912, 20);
  690. this.btn_saveresult.Name = "btn_saveresult";
  691. this.btn_saveresult.Size = new System.Drawing.Size(75, 23);
  692. this.btn_saveresult.TabIndex = 2;
  693. this.btn_saveresult.UseVisualStyleBackColor = true;
  694. this.btn_saveresult.Click += new System.EventHandler(this.btn_saveresult_Click);
  695. //
  696. // btn_Grainboundarytoreproduce
  697. //
  698. this.btn_Grainboundarytoreproduce.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
  699. this.btn_Grainboundarytoreproduce.Location = new System.Drawing.Point(832, 20);
  700. this.btn_Grainboundarytoreproduce.Name = "btn_Grainboundarytoreproduce";
  701. this.btn_Grainboundarytoreproduce.Size = new System.Drawing.Size(75, 23);
  702. this.btn_Grainboundarytoreproduce.TabIndex = 2;
  703. this.btn_Grainboundarytoreproduce.UseVisualStyleBackColor = true;
  704. this.btn_Grainboundarytoreproduce.Click += new System.EventHandler(this.btn_Grainboundarytoreproduce_Click);
  705. //
  706. // groupBox_img
  707. //
  708. this.groupBox_img.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  709. | System.Windows.Forms.AnchorStyles.Left)));
  710. this.groupBox_img.Controls.Add(this.lstView_img);
  711. this.groupBox_img.Location = new System.Drawing.Point(13, 72);
  712. this.groupBox_img.Margin = new System.Windows.Forms.Padding(4);
  713. this.groupBox_img.Name = "groupBox_img";
  714. this.groupBox_img.Padding = new System.Windows.Forms.Padding(4);
  715. this.groupBox_img.Size = new System.Drawing.Size(158, 502);
  716. this.groupBox_img.TabIndex = 13;
  717. this.groupBox_img.TabStop = false;
  718. //
  719. // lstView_img
  720. //
  721. this.lstView_img.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  722. | System.Windows.Forms.AnchorStyles.Left)
  723. | System.Windows.Forms.AnchorStyles.Right)));
  724. this.lstView_img.HideSelection = false;
  725. this.lstView_img.LargeImageList = this.imageList_img;
  726. this.lstView_img.Location = new System.Drawing.Point(8, 26);
  727. this.lstView_img.Margin = new System.Windows.Forms.Padding(4);
  728. this.lstView_img.MultiSelect = false;
  729. this.lstView_img.Name = "lstView_img";
  730. this.lstView_img.Size = new System.Drawing.Size(140, 468);
  731. this.lstView_img.TabIndex = 0;
  732. this.lstView_img.UseCompatibleStateImageBehavior = false;
  733. this.lstView_img.SelectedIndexChanged += new System.EventHandler(this.lstView_img_SelectedIndexChanged);
  734. //
  735. // imageList_img
  736. //
  737. this.imageList_img.ColorDepth = System.Windows.Forms.ColorDepth.Depth8Bit;
  738. this.imageList_img.ImageSize = new System.Drawing.Size(64, 64);
  739. this.imageList_img.TransparentColor = System.Drawing.Color.Transparent;
  740. //
  741. // groupBox_review
  742. //
  743. this.groupBox_review.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  744. | System.Windows.Forms.AnchorStyles.Left)
  745. | System.Windows.Forms.AnchorStyles.Right)));
  746. this.groupBox_review.Location = new System.Drawing.Point(541, 72);
  747. this.groupBox_review.Name = "groupBox_review";
  748. this.groupBox_review.Size = new System.Drawing.Size(575, 502);
  749. this.groupBox_review.TabIndex = 30;
  750. this.groupBox_review.TabStop = false;
  751. //
  752. // groupBox_report
  753. //
  754. this.groupBox_report.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
  755. this.groupBox_report.Controls.Add(this.threeDButton);
  756. this.groupBox_report.Controls.Add(this.button1);
  757. this.groupBox_report.Controls.Add(this.numericUpDown1_0);
  758. this.groupBox_report.Controls.Add(this.label_resultPrecision);
  759. this.groupBox_report.Controls.Add(this.button_exportResults);
  760. this.groupBox_report.Controls.Add(this.button_generateReport);
  761. this.groupBox_report.Location = new System.Drawing.Point(974, 580);
  762. this.groupBox_report.Name = "groupBox_report";
  763. this.groupBox_report.Size = new System.Drawing.Size(142, 218);
  764. this.groupBox_report.TabIndex = 33;
  765. this.groupBox_report.TabStop = false;
  766. //
  767. // threeDButton
  768. //
  769. this.threeDButton.Location = new System.Drawing.Point(28, 149);
  770. this.threeDButton.Name = "threeDButton";
  771. this.threeDButton.Size = new System.Drawing.Size(75, 23);
  772. this.threeDButton.TabIndex = 24;
  773. this.threeDButton.UseVisualStyleBackColor = true;
  774. this.threeDButton.Click += new System.EventHandler(this.threeDButton_Click);
  775. //
  776. // button1
  777. //
  778. this.button1.Location = new System.Drawing.Point(29, 112);
  779. this.button1.Name = "button1";
  780. this.button1.Size = new System.Drawing.Size(75, 23);
  781. this.button1.TabIndex = 23;
  782. this.button1.UseVisualStyleBackColor = true;
  783. this.button1.Click += new System.EventHandler(this.button1_Click);
  784. //
  785. // numericUpDown1_0
  786. //
  787. this.numericUpDown1_0.Location = new System.Drawing.Point(63, 184);
  788. this.numericUpDown1_0.Maximum = new decimal(new int[] {
  789. 10,
  790. 0,
  791. 0,
  792. 0});
  793. this.numericUpDown1_0.Name = "numericUpDown1_0";
  794. this.numericUpDown1_0.Size = new System.Drawing.Size(56, 21);
  795. this.numericUpDown1_0.TabIndex = 22;
  796. this.numericUpDown1_0.Value = new decimal(new int[] {
  797. 2,
  798. 0,
  799. 0,
  800. 0});
  801. this.numericUpDown1_0.ValueChanged += new System.EventHandler(this.numericUpDown1_0_ValueChanged);
  802. //
  803. // label_resultPrecision
  804. //
  805. this.label_resultPrecision.AutoSize = true;
  806. this.label_resultPrecision.Location = new System.Drawing.Point(26, 188);
  807. this.label_resultPrecision.Name = "label_resultPrecision";
  808. this.label_resultPrecision.Size = new System.Drawing.Size(0, 12);
  809. this.label_resultPrecision.TabIndex = 3;
  810. //
  811. // button_exportResults
  812. //
  813. this.button_exportResults.Location = new System.Drawing.Point(29, 73);
  814. this.button_exportResults.Name = "button_exportResults";
  815. this.button_exportResults.Size = new System.Drawing.Size(75, 23);
  816. this.button_exportResults.TabIndex = 1;
  817. this.button_exportResults.UseVisualStyleBackColor = true;
  818. this.button_exportResults.Click += new System.EventHandler(this.button_exportResults_Click);
  819. //
  820. // button_generateReport
  821. //
  822. this.button_generateReport.Location = new System.Drawing.Point(29, 34);
  823. this.button_generateReport.Name = "button_generateReport";
  824. this.button_generateReport.Size = new System.Drawing.Size(75, 23);
  825. this.button_generateReport.TabIndex = 0;
  826. this.button_generateReport.UseVisualStyleBackColor = true;
  827. this.button_generateReport.Click += new System.EventHandler(this.button_generateReport_Click);
  828. //
  829. // groupBox6groupBox_analysisResult2
  830. //
  831. this.groupBox6groupBox_analysisResult2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
  832. | System.Windows.Forms.AnchorStyles.Right)));
  833. this.groupBox6groupBox_analysisResult2.Controls.Add(this.dataGridView_Total);
  834. this.groupBox6groupBox_analysisResult2.Controls.Add(this.dataGridView2);
  835. this.groupBox6groupBox_analysisResult2.Location = new System.Drawing.Point(242, 580);
  836. this.groupBox6groupBox_analysisResult2.Name = "groupBox6groupBox_analysisResult2";
  837. this.groupBox6groupBox_analysisResult2.Size = new System.Drawing.Size(719, 218);
  838. this.groupBox6groupBox_analysisResult2.TabIndex = 32;
  839. this.groupBox6groupBox_analysisResult2.TabStop = false;
  840. //
  841. // dataGridView_Total
  842. //
  843. this.dataGridView_Total.AllowUserToAddRows = false;
  844. this.dataGridView_Total.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
  845. | System.Windows.Forms.AnchorStyles.Right)));
  846. this.dataGridView_Total.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill;
  847. this.dataGridView_Total.BackgroundColor = System.Drawing.SystemColors.ControlLightLight;
  848. dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
  849. dataGridViewCellStyle1.BackColor = System.Drawing.SystemColors.Control;
  850. dataGridViewCellStyle1.Font = new System.Drawing.Font("宋体", 9F);
  851. dataGridViewCellStyle1.ForeColor = System.Drawing.SystemColors.WindowText;
  852. dataGridViewCellStyle1.SelectionBackColor = System.Drawing.SystemColors.Highlight;
  853. dataGridViewCellStyle1.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
  854. dataGridViewCellStyle1.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
  855. this.dataGridView_Total.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle1;
  856. this.dataGridView_Total.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
  857. this.dataGridView_Total.Location = new System.Drawing.Point(13, 144);
  858. this.dataGridView_Total.Name = "dataGridView_Total";
  859. this.dataGridView_Total.ReadOnly = true;
  860. this.dataGridView_Total.RowHeadersVisible = false;
  861. this.dataGridView_Total.RowTemplate.Height = 23;
  862. this.dataGridView_Total.Size = new System.Drawing.Size(693, 68);
  863. this.dataGridView_Total.TabIndex = 17;
  864. //
  865. // dataGridView2
  866. //
  867. this.dataGridView2.AllowUserToAddRows = false;
  868. this.dataGridView2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
  869. | System.Windows.Forms.AnchorStyles.Right)));
  870. this.dataGridView2.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill;
  871. this.dataGridView2.BackgroundColor = System.Drawing.SystemColors.ControlLightLight;
  872. dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
  873. dataGridViewCellStyle2.BackColor = System.Drawing.SystemColors.Control;
  874. dataGridViewCellStyle2.Font = new System.Drawing.Font("宋体", 9F);
  875. dataGridViewCellStyle2.ForeColor = System.Drawing.SystemColors.WindowText;
  876. dataGridViewCellStyle2.SelectionBackColor = System.Drawing.SystemColors.Highlight;
  877. dataGridViewCellStyle2.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
  878. dataGridViewCellStyle2.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
  879. this.dataGridView2.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle2;
  880. this.dataGridView2.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
  881. this.dataGridView2.Location = new System.Drawing.Point(13, 12);
  882. this.dataGridView2.Name = "dataGridView2";
  883. this.dataGridView2.ReadOnly = true;
  884. this.dataGridView2.RowHeadersVisible = false;
  885. this.dataGridView2.RowTemplate.Height = 23;
  886. this.dataGridView2.Size = new System.Drawing.Size(693, 128);
  887. this.dataGridView2.TabIndex = 16;
  888. //
  889. // groupBox_analysisResult1
  890. //
  891. this.groupBox_analysisResult1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
  892. this.groupBox_analysisResult1.Controls.Add(this.button11);
  893. this.groupBox_analysisResult1.Controls.Add(this.listView2);
  894. this.groupBox_analysisResult1.Controls.Add(this.button16);
  895. this.groupBox_analysisResult1.Controls.Add(this.button12);
  896. this.groupBox_analysisResult1.Location = new System.Drawing.Point(12, 580);
  897. this.groupBox_analysisResult1.Name = "groupBox_analysisResult1";
  898. this.groupBox_analysisResult1.Size = new System.Drawing.Size(224, 218);
  899. this.groupBox_analysisResult1.TabIndex = 31;
  900. this.groupBox_analysisResult1.TabStop = false;
  901. //
  902. // button11
  903. //
  904. this.button11.BackColor = System.Drawing.SystemColors.Control;
  905. this.button11.Location = new System.Drawing.Point(19, 22);
  906. this.button11.Name = "button11";
  907. this.button11.Size = new System.Drawing.Size(63, 26);
  908. this.button11.TabIndex = 27;
  909. this.button11.UseVisualStyleBackColor = false;
  910. this.button11.Click += new System.EventHandler(this.button11_Click);
  911. //
  912. // listView2
  913. //
  914. this.listView2.FullRowSelect = true;
  915. this.listView2.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.None;
  916. this.listView2.HideSelection = false;
  917. this.listView2.Location = new System.Drawing.Point(19, 58);
  918. this.listView2.Name = "listView2";
  919. this.listView2.Size = new System.Drawing.Size(182, 149);
  920. this.listView2.TabIndex = 26;
  921. this.listView2.UseCompatibleStateImageBehavior = false;
  922. this.listView2.SelectedIndexChanged += new System.EventHandler(this.listview2_SelectedIndexChanged);
  923. //
  924. // button16
  925. //
  926. this.button16.BackColor = System.Drawing.SystemColors.Control;
  927. this.button16.Location = new System.Drawing.Point(19, 21);
  928. this.button16.Name = "button16";
  929. this.button16.Size = new System.Drawing.Size(93, 26);
  930. this.button16.TabIndex = 25;
  931. this.button16.UseVisualStyleBackColor = false;
  932. this.button16.Click += new System.EventHandler(this.button16_Click);
  933. //
  934. // button12
  935. //
  936. this.button12.BackColor = System.Drawing.SystemColors.Control;
  937. this.button12.Location = new System.Drawing.Point(149, 21);
  938. this.button12.Name = "button12";
  939. this.button12.Size = new System.Drawing.Size(52, 26);
  940. this.button12.TabIndex = 24;
  941. this.button12.UseVisualStyleBackColor = false;
  942. this.button12.Click += new System.EventHandler(this.button12_Click);
  943. //
  944. // groupBox3
  945. //
  946. this.groupBox3.Controls.Add(this.button9);
  947. this.groupBox3.Controls.Add(this.comboBox1);
  948. this.groupBox3.Location = new System.Drawing.Point(179, 320);
  949. this.groupBox3.Name = "groupBox3";
  950. this.groupBox3.Size = new System.Drawing.Size(355, 48);
  951. this.groupBox3.TabIndex = 34;
  952. this.groupBox3.TabStop = false;
  953. //
  954. // button9
  955. //
  956. this.button9.BackColor = System.Drawing.SystemColors.Control;
  957. this.button9.Location = new System.Drawing.Point(241, 15);
  958. this.button9.Name = "button9";
  959. this.button9.Size = new System.Drawing.Size(92, 26);
  960. this.button9.TabIndex = 10;
  961. this.button9.UseVisualStyleBackColor = false;
  962. this.button9.Click += new System.EventHandler(this.button9_Click);
  963. //
  964. // comboBox1
  965. //
  966. this.comboBox1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
  967. this.comboBox1.FormattingEnabled = true;
  968. this.comboBox1.Location = new System.Drawing.Point(15, 18);
  969. this.comboBox1.Name = "comboBox1";
  970. this.comboBox1.Size = new System.Drawing.Size(220, 20);
  971. this.comboBox1.TabIndex = 0;
  972. this.comboBox1.SelectedIndexChanged += new System.EventHandler(this.comboBox1_SelectedIndexChanged);
  973. //
  974. // GrainSizeStandardDialog
  975. //
  976. this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
  977. this.ClientSize = new System.Drawing.Size(1127, 810);
  978. this.Controls.Add(this.groupBox3);
  979. this.Controls.Add(this.groupBox_report);
  980. this.Controls.Add(this.groupBox6groupBox_analysisResult2);
  981. this.Controls.Add(this.groupBox_analysisResult1);
  982. this.Controls.Add(this.groupBox_review);
  983. this.Controls.Add(this.groupBox_img);
  984. this.Controls.Add(this.groupBox_operating);
  985. this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
  986. this.Name = "GrainSizeStandardDialog";
  987. this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.GrainSizeStandardDialog_FormClosing);
  988. this.Load += new System.EventHandler(this.GrainSizeStandardDialog_Load);
  989. this.Controls.SetChildIndex(this.groupBox_operating, 0);
  990. this.Controls.SetChildIndex(this.groupBox_img, 0);
  991. this.Controls.SetChildIndex(this.groupBox_review, 0);
  992. this.Controls.SetChildIndex(this.groupBox_analysisResult1, 0);
  993. this.Controls.SetChildIndex(this.groupBox6groupBox_analysisResult2, 0);
  994. this.Controls.SetChildIndex(this.groupBox_report, 0);
  995. this.Controls.SetChildIndex(this.groupBox3, 0);
  996. this.groupBox_operating.ResumeLayout(false);
  997. this.groupBox_operating.PerformLayout();
  998. this.groupBox_img.ResumeLayout(false);
  999. this.groupBox_report.ResumeLayout(false);
  1000. this.groupBox_report.PerformLayout();
  1001. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1_0)).EndInit();
  1002. this.groupBox6groupBox_analysisResult2.ResumeLayout(false);
  1003. ((System.ComponentModel.ISupportInitialize)(this.dataGridView_Total)).EndInit();
  1004. ((System.ComponentModel.ISupportInitialize)(this.dataGridView2)).EndInit();
  1005. this.groupBox_analysisResult1.ResumeLayout(false);
  1006. this.groupBox3.ResumeLayout(false);
  1007. this.ResumeLayout(false);
  1008. }
  1009. private void DataGridView2_SortCompare(object sender, DataGridViewSortCompareEventArgs e)
  1010. {
  1011. //DetailListNotDoubleIndex.Add(0); //DetailListNotDoubleIndex.Add(1);
  1012. // 如果是学号或成绩列,则按浮点数处理
  1013. if (DetailListNotDoubleIndex.Count > 0 && !DetailListNotDoubleIndex.Contains(e.Column.Index))
  1014. {
  1015. e.SortResult = (Convert.ToDouble(e.CellValue1) - Convert.ToDouble(e.CellValue2) > 0) ? 1 : (Convert.ToDouble(e.CellValue1) - Convert.ToDouble(e.CellValue2) < 0) ? -1 : 0;
  1016. }
  1017. //否则,按字符串比较
  1018. else
  1019. {
  1020. e.SortResult = System.String.Compare(Convert.ToString(e.CellValue1), Convert.ToString(e.CellValue2));
  1021. }
  1022. e.Handled = true;//不能省掉,不然没效果
  1023. }
  1024. /// <summary>
  1025. /// 选中的左侧list的下标
  1026. /// </summary>
  1027. protected int index = 0;
  1028. public void Initialize()
  1029. {
  1030. //初始化图片列表
  1031. for (int i = 0; i < this.appWorkspace.DocumentWorkspaces.Length; i++)
  1032. {
  1033. this.imageList_img.Images.Add("img" + i, this.appWorkspace.DocumentWorkspaces[i].BinarizationThumbnail);
  1034. this.lstView_img.Items.Add("", i);
  1035. this.lstView_img.Items[i].ImageIndex = i;
  1036. this.lstView_img.Items[i].Text = this.appWorkspace.DocumentWorkspaces[i].GetFriendlyName();
  1037. this.lstView_img.Items[i].Name = this.appWorkspace.DocumentWorkspaces[i].GetFriendlyName();
  1038. if (this.appWorkspace.DocumentWorkspaces[i].Equals(this.appWorkspace.ActiveDocumentWorkspace))
  1039. {
  1040. index = i;
  1041. }
  1042. }
  1043. //
  1044. // 初始化选中的数据
  1045. //
  1046. if (index >= 0 && index < this.lstView_img.Items.Count)
  1047. this.lstView_img.Items[index].Selected = true; //选中行 //##21319
  1048. //
  1049. //初始化图像控件
  1050. //
  1051. this.documentWorkspace = new DocumentWorkspaceWindow(this.appWorkspace);
  1052. this.documentWorkspace.Cursor = Cursors.Default;
  1053. this.documentWorkspace.Dock = DockStyle.Fill;
  1054. this.documentWorkspace.HookMouseEvents();
  1055. this.documentWorkspace.AuxiliaryLineEnabled = false;
  1056. this.documentWorkspace.Visible = true;
  1057. this.documentWorkspace.panel.MouseDown += OnMouseDown;
  1058. this.documentWorkspace.panel.Paint += Panel_Paint;
  1059. this.documentWorkspace.panel.MouseMove += onMouseMove;
  1060. this.documentWorkspace.panel.MouseUp += onMouseUp;
  1061. this.documentWorkspace.ActiveTool = Annotation.Enum.DrawToolType.InclusionNoEffect;//禁止视场移动
  1062. this.groupBox_review.Controls.Add(this.documentWorkspace);
  1063. //
  1064. //初始化操作按钮
  1065. //
  1066. this.commonControlButtons = new CommonControlButtons();
  1067. this.commonControlButtons.Dock = DockStyle.Top;
  1068. this.commonControlButtons.Height = 30;
  1069. this.commonControlButtons.HideZoomToWindowAndActualSize();
  1070. this.commonControlButtons.zoomInButton.Click += new EventHandler(zoomInButton_Click);
  1071. this.commonControlButtons.zoomOutButton.Click += new EventHandler(zoomOutButton_Click);
  1072. this.commonControlButtons.zoomToWindowButton.Click += new EventHandler(zoomToWindowButton_Click);
  1073. this.commonControlButtons.actualSizeButton.Click += new EventHandler(actualSizeButton_Click);
  1074. this.commonControlButtons.pointerButton.Click += new EventHandler(pointerButton_Click);
  1075. this.commonControlButtons.mobileModeButton.Click += new EventHandler(mobileModeButton_Click);
  1076. groupBox_review.Controls.Add(this.commonControlButtons);
  1077. ////
  1078. //// 初始化选中的数据
  1079. ////
  1080. //this.lstView_img.Items[index].Selected = true; //选中行
  1081. }
  1082. #endregion
  1083. #region 二值化相关方法
  1084. /// <summary>
  1085. /// 添加参数改变的监听
  1086. /// </summary>
  1087. /// <param name="sender"></param>
  1088. /// <param name="e"></param>
  1089. private void GrainSizeStandardDialog_Load(object sender, EventArgs e)
  1090. {
  1091. this.threeDButton.Enabled = false;
  1092. System.Windows.Forms.Control.CheckForIllegalCrossThreadCalls = false;
  1093. this.dataGridView2.SortCompare += DataGridView2_SortCompare;
  1094. if (grainMethodType == 0)
  1095. {
  1096. GSSClass.styleClass.styleModel.UpdateCupOffPointStyle();
  1097. AddRectangleToRectangleFCaps();
  1098. }
  1099. ////二值化集成3
  1100. //this.binaryClass.loadParams();
  1101. //this.binaryClass.guideClass = GSSClass.GuideClass;
  1102. //this.binaryClass.comboBox1 = this.comboBox1;
  1103. //object ShowGrainBoundry;//#21752
  1104. //if (GetParamValue1(ParamKey_CalculatorDecimalDigits, out ShowGrainBoundry))//小数点位数
  1105. // this.numericUpDown1_0.Value = (int)ShowGrainBoundry;
  1106. //if (GetParamValue1(ParamKey_OpenWhileExportReport, out ShowGrainBoundry))//生成报告时打开设置
  1107. // this.checkBox_generateReport_opensetting.Checked = (bool)ShowGrainBoundry;
  1108. this.finishedLoadAction++;
  1109. if (this.finishedLoadAction > 0 && this.initScriptValues && this.appWorkspace.ScriptAutomatic)
  1110. this.startScriptAutomaticAction();
  1111. }
  1112. private bool bcBinaryChecked()
  1113. {
  1114. return bc != null && bc.BinaryChecked;
  1115. }
  1116. protected bool bcOriginChecked()
  1117. {
  1118. return bc != null && bc.OriginChecked;
  1119. }
  1120. /// <summary>
  1121. /// 参数改变时,重新处理图像
  1122. /// </summary>
  1123. /// <param name="sender"></param>
  1124. /// <param name="e"></param>
  1125. private void bClassBinaryImplFinishAction(object sender, EventArgs e)
  1126. {
  1127. if (grainMethodType == 1 && GetClassNumberOfGrains() == 0)
  1128. this.documentWorkspace.Refresh();
  1129. else//###############################################################
  1130. AddRectangleToRectangleFCaps();
  1131. }
  1132. /// <summary>
  1133. /// 显示原图/原图+二值图
  1134. /// </summary>
  1135. /// <param name="sender"></param>
  1136. /// <param name="e"></param>
  1137. private void bcOriginCheckedChanged(object sender, EventArgs e)
  1138. {
  1139. if (!bcOriginChecked())
  1140. {
  1141. if (bcBinaryChecked())
  1142. this.documentWorkspace.PhaseModels[0].choise = true;
  1143. if (getGrainBoundryChecked() && ShowGrainBoundryChecked())
  1144. this.documentWorkspace.PhaseModels[1].choise = true;
  1145. if (grainMethodType == 1 && ShowGrainColorChecked())
  1146. this.documentWorkspace.PhaseModels[2].choise = true;
  1147. }
  1148. else
  1149. {
  1150. this.documentWorkspace.PhaseModels[0].choise = false;
  1151. this.documentWorkspace.PhaseModels[1].choise = false;
  1152. this.documentWorkspace.PhaseModels[2].choise = false;
  1153. }
  1154. this.documentWorkspace.Refresh();
  1155. }
  1156. #endregion
  1157. #region 内部方法
  1158. /// <summary>
  1159. /// 设置按钮
  1160. /// </summary>
  1161. /// <param name="sender"></param>
  1162. /// <param name="e"></param>
  1163. private void button_setting_Click(object sender, EventArgs e)
  1164. {
  1165. string templateName;
  1166. try
  1167. {
  1168. templateName = getTemplateName();
  1169. }
  1170. catch (Exception)
  1171. {
  1172. templateName = GSSClass.methodOfAssessment.resourcesName;
  1173. }
  1174. AnalyzeSettingDialog metallographicMethodSetDialog = new AnalyzeSettingDialog(this, templateName);
  1175. if (metallographicMethodSetDialog.hasModule)
  1176. {
  1177. metallographicMethodSetDialog.StartPosition = FormStartPosition.CenterScreen;
  1178. metallographicMethodSetDialog.ShowDialog();
  1179. }
  1180. else
  1181. {
  1182. metallographicMethodSetDialog = null;
  1183. }
  1184. }
  1185. /// <summary>
  1186. /// 保存结果
  1187. /// </summary>
  1188. /// <param name="sender"></param>
  1189. /// <param name="e"></param>
  1190. private void btn_saveresult_Click(object sender, EventArgs e)
  1191. {
  1192. GSSClass.GuideClass.guideModel.oldSelectItem = (string)this.comboBox1.SelectedItem;
  1193. buildListBox_analysisResult(getCurrentWorkTag(), this.selectPicture);
  1194. }
  1195. /// <summary>
  1196. /// 相1的图片,处理多视场使用
  1197. /// </summary>
  1198. protected Mat PhaseModels1Mat;
  1199. protected Color PhaseModels1Color;
  1200. /// <summary>
  1201. /// 晶界重现
  1202. /// </summary>
  1203. /// <param name="sender"></param>
  1204. /// <param name="e"></param>
  1205. private void btn_Grainboundarytoreproduce_Click(object sender, EventArgs e)
  1206. {
  1207. //if (this.documentWorkspace.PhaseModels.Count < 2 || /*this.documentWorkspace.PhaseModels[1].choise == true && */this.documentWorkspace.PhaseModels[1].mat == null)
  1208. //{
  1209. // MessageBox.Show(PdnResources.GetString("Menu.Pleaseperformuctionfirst.text"));
  1210. // return;
  1211. //}
  1212. if (this.bitmap == null)
  1213. {
  1214. MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectapicture.text") + "!");
  1215. return;
  1216. }
  1217. //1013###19326 晶粒度的晶界编辑页面,需要把辅助线带过去(客户编辑只处理辅助线位置的晶界)
  1218. GrainBoundaryEditingDialog boundaryEditingDialog = new GrainBoundaryEditingDialog(this.appWorkspace, this.menuId, this.lstView_img.FocusedItem != null ? this.lstView_img.FocusedItem.Index : this.lstView_img.SelectedItems[0].Index, this.documentWorkspace.PhaseModels[1].mat == null ? Color.Red : PhaseModels1Color/*this.panel1.BackColor*/
  1219. , this.documentWorkspace.PhaseModels[1].mat == null ? null : this.documentWorkspace.PhaseModels[1].mat.Clone(), ShowDrawClassView());
  1220. boundaryEditingDialog.GuideClass = GSSClass.GuideClass;
  1221. boundaryEditingDialog.SelectedItem = this.comboBox1.SelectedItem;
  1222. if (boundaryEditingDialog.ShowDialog() == DialogResult.OK && boundaryEditingDialog.PhaseMat != null)
  1223. {
  1224. string xmlFilePath = Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\GrainSizeAnalyze\\GrainBoundryDectModel_" + this.menuId + ".xml";
  1225. if (System.IO.File.Exists(xmlFilePath))
  1226. {
  1227. Base.SettingModel.GrainBoundryDectModel grainBoundryDectModel = Base.CommTool.XmlSerializeHelper.DESerializer<Base.SettingModel.GrainBoundryDectModel>(Base.CommTool.FileOperationHelper.ReadStringFromFile(xmlFilePath, System.IO.FileMode.Open));
  1228. //sigma = grainBoundryDectModel.sigma;
  1229. if (!this.grainBoundaryDict.ContainsKey(getCurrentWorkTag()))
  1230. this.grainBoundaryDict.Add(getCurrentWorkTag(), grainBoundryDectModel.cloneModel());
  1231. else
  1232. this.grainBoundaryDict[getCurrentWorkTag()] = grainBoundryDectModel.cloneModel();
  1233. }
  1234. if (this.grainBoundaryDict[getCurrentWorkTag()].grainApplygrainboundaries != 1)
  1235. {//没有选择应用选项
  1236. if (this.grainBoundaryMatDict.ContainsKey(getCurrentWorkTag()))
  1237. {
  1238. this.grainBoundaryMatDict.Remove(getCurrentWorkTag());
  1239. this.documentWorkspace.PhaseModels[1].mat = null;
  1240. if (PhaseModels1Mat != null)
  1241. {
  1242. PhaseModels1Mat.Dispose();
  1243. PhaseModels1Mat = null;
  1244. }
  1245. if (grainMethodType == 1)
  1246. if (GetClassNumberOfGrains() == 0)
  1247. this.documentWorkspace.Refresh();
  1248. else
  1249. AddRectangleToRectangleFCaps();
  1250. this.documentWorkspace.PhaseModels[1].choise = (!bcOriginChecked() && getGrainBoundryChecked() && ShowGrainBoundryChecked());
  1251. //this.documentWorkspace.Refresh();
  1252. if (grainMethodType == 1 && GetClassNumberOfGrains() == 0)
  1253. this.documentWorkspace.Refresh();
  1254. else//###############################################################//#20991
  1255. AddRectangleToRectangleFCaps();
  1256. }
  1257. return;
  1258. }
  1259. PhaseModels1Color = boundaryEditingDialog.PhaseColor;
  1260. if (PhaseModels1Mat != null)
  1261. {
  1262. PhaseModels1Mat.Dispose();
  1263. PhaseModels1Mat = null;
  1264. }
  1265. if (getCurrentWorkspace().GraphicsList.IsExsitView())
  1266. PhaseModels1Mat = boundaryEditingDialog.PhaseMat.Clone();
  1267. this.documentWorkspace.PhaseModels[1].mat = boundaryEditingDialog.PhaseMat.Clone();
  1268. if (!this.grainBoundaryMatDict.ContainsKey(getCurrentWorkTag()))
  1269. this.grainBoundaryMatDict.Add(getCurrentWorkTag(), boundaryEditingDialog.PhaseMat.Clone());
  1270. else
  1271. this.grainBoundaryMatDict[getCurrentWorkTag()] = boundaryEditingDialog.PhaseMat.Clone();
  1272. //if (grainMethodType == 1)
  1273. // if (GetClassNumberOfGrains() == 0)
  1274. // this.documentWorkspace.Refresh();
  1275. // else
  1276. // AddRectangleToRectangleFCaps();
  1277. this.documentWorkspace.PhaseModels[1].choise = (!bcOriginChecked() && getGrainBoundryChecked() && ShowGrainBoundryChecked());
  1278. if (grainMethodType == 1 && GetClassNumberOfGrains() == 0)
  1279. this.documentWorkspace.Refresh();
  1280. else//###############################################################//#20991
  1281. AddRectangleToRectangleFCaps();
  1282. this.documentWorkspace.Refresh();
  1283. }
  1284. }
  1285. private void lstView_img_SelectedIndexChanged(object sender, EventArgs e)
  1286. {
  1287. if (this.lstView_img.FocusedItem != null && this.lstView_img.FocusedItem.Selected)
  1288. {
  1289. if (this.selectPicture == this.lstView_img.FocusedItem.Index)
  1290. return;
  1291. this.refreshActionWhileImg_SelectedIndexChanged(false);
  1292. }
  1293. }
  1294. /// <summary>
  1295. /// 导出项目
  1296. /// </summary>
  1297. /// <param name="sender"></param>
  1298. /// <param name="e"></param>
  1299. private void button1_Click(object sender, EventArgs e)
  1300. {
  1301. if (this.listView2.Items.Count == 0)
  1302. {
  1303. MessageBox.Show(PdnResources.GetString("Menu.Noresults.text"));
  1304. return;
  1305. }
  1306. if (this.checkBox_generateReport_opensetting.Checked)
  1307. this.button_setting.PerformClick();
  1308. if (this.analyzeSettingModel != null && !string.IsNullOrEmpty(this.analyzeSettingModel.analyzeClassify))
  1309. {
  1310. //获取项目工程内的文件夹路径
  1311. ProjectEngineering.NodeItem nodeItem = this.appWorkspace.GetInsertProjectPath(2, getProjectEngineeringName(), this.analyzeSettingModel.savePath);
  1312. if (nodeItem == null) return;
  1313. //获取word书签与excel单元格的关系,以字典方式存储
  1314. List<mic_module_infos> mic_module_infos = PaintDotNet.DbOpreate.DbBll.mic_module_infos_BLL.FindAll().FindAll(a => a.analyze_classify == this.analyzeSettingModel.analyzeClassify);
  1315. Dictionary<string, string> tagInfos = new Dictionary<string, string>();
  1316. if (mic_module_infos != null && mic_module_infos.Count > 0)
  1317. {
  1318. foreach (mic_module_infos info in mic_module_infos)
  1319. {
  1320. tagInfos.Add(info.tag_name, info.cell_position);
  1321. }
  1322. }
  1323. //分析结果
  1324. List<List<string>> analysisContent = new List<List<string>>();
  1325. List<string> contentHeaderText2 = new List<string>();
  1326. foreach (DataGridViewColumn c in this.dataGridView_Total.Columns)
  1327. {
  1328. contentHeaderText2.Add(c.HeaderText);
  1329. }
  1330. analysisContent.Add(contentHeaderText2);
  1331. foreach (DataGridViewRow item in this.dataGridView_Total.Rows)//##########################
  1332. {
  1333. List<string> content = new List<string>();
  1334. for (int i = 0; i < contentHeaderText2.Count; i++)
  1335. {
  1336. content.Add(item.Cells[i].Value.ToString());
  1337. }
  1338. analysisContent.Add(content);
  1339. }
  1340. List<string> contentHeaderText = new List<string>();
  1341. foreach (DataGridViewColumn c in this.dataGridView2.Columns)
  1342. {
  1343. contentHeaderText.Add(c.HeaderText);
  1344. }
  1345. analysisContent.Add(contentHeaderText);
  1346. foreach (DataGridViewRow item in this.dataGridView2.Rows)//################################
  1347. {
  1348. List<string> content = new List<string>();
  1349. for (int i = 0; i < contentHeaderText.Count; i++)
  1350. {
  1351. content.Add(item.Cells[i].Value.ToString());
  1352. }
  1353. analysisContent.Add(content);
  1354. }
  1355. //图片
  1356. bitList = new List<Bitmap>();
  1357. List<string> pNamesList = new List<string>();
  1358. //中间数据
  1359. List<ExportProjectModel> exportModel = new List<ExportProjectModel>();
  1360. if (this.allShow)
  1361. {
  1362. foreach (KeyValuePair<string, List<Bitmap>> kv in this.bitDic)
  1363. {
  1364. int cal_Index = int.Parse(kv.Key.Replace("img", ""));
  1365. string imgName = this.appWorkspace.DocumentWorkspaces[cal_Index].GetFriendlyName();
  1366. pNamesList.Add(imgName);
  1367. bitList.Add(kv.Value[0]);
  1368. bitList.Add(kv.Value[1]);
  1369. }
  1370. //中间数据
  1371. foreach (ExportProjectModel model in this.tempDataModel)
  1372. {
  1373. ExportProjectModel tempModel = new ExportProjectModel();
  1374. tempModel.tagName = model.tagName;
  1375. tempModel.picName = model.picName;
  1376. tempModel.dataList = model.dataList;
  1377. exportModel.Add(tempModel);
  1378. }
  1379. }
  1380. else
  1381. {
  1382. if (this.listView2.SelectedItems != null && this.listView2.SelectedItems.Count > 0)
  1383. {
  1384. foreach (ListViewItem item in this.listView2.SelectedItems)
  1385. {
  1386. if (bitDic.ContainsKey(item.Name))
  1387. {
  1388. int cal_Index = int.Parse(item.Name.Replace("img", ""));
  1389. string imgName = this.appWorkspace.DocumentWorkspaces[cal_Index].GetFriendlyName();
  1390. pNamesList.Add(imgName);
  1391. bitList.Add(bitDic[item.Name][0]);
  1392. bitList.Add(bitDic[item.Name][1]);
  1393. }
  1394. else if (bitDic.ContainsKey(item.Tag.ToString()))
  1395. {
  1396. int cal_Index = int.Parse(item.Tag.ToString().Replace("img", ""));
  1397. string imgName = this.appWorkspace.DocumentWorkspaces[cal_Index].GetFriendlyName();
  1398. pNamesList.Add(imgName);
  1399. bitList.Add(bitDic[item.Tag.ToString()][0]);
  1400. bitList.Add(bitDic[item.Tag.ToString()][1]);
  1401. }
  1402. }
  1403. //中间数据
  1404. foreach (ListViewItem rowItem in this.listView2.SelectedItems)
  1405. {
  1406. foreach (ExportProjectModel model in this.tempDataModel)
  1407. {
  1408. if (model.tagName.Equals(rowItem.Name))
  1409. {
  1410. ExportProjectModel tempModel = new ExportProjectModel();
  1411. tempModel.tagName = model.tagName;
  1412. tempModel.picName = model.picName;
  1413. tempModel.dataList = model.dataList;
  1414. exportModel.Add(tempModel);
  1415. break;
  1416. }
  1417. else if (model.tagName.Equals(rowItem.Tag.ToString()))
  1418. {
  1419. ExportProjectModel tempModel = new ExportProjectModel();
  1420. tempModel.tagName = model.tagName;
  1421. tempModel.picName = model.picName;
  1422. tempModel.dataList = model.dataList;
  1423. exportModel.Add(tempModel);
  1424. break;
  1425. }
  1426. }
  1427. }
  1428. }
  1429. else if (this.listView2.Items.Count > 0)
  1430. {
  1431. ListViewItem rowItem = this.listView2.Items[0];
  1432. if (bitDic.ContainsKey(rowItem.Name))
  1433. {
  1434. int cal_Index = int.Parse(rowItem.Name.Replace("img", ""));
  1435. string imgName = this.appWorkspace.DocumentWorkspaces[cal_Index].GetFriendlyName();
  1436. pNamesList.Add(imgName);
  1437. bitList.Add(bitDic[rowItem.Name][0]);
  1438. bitList.Add(bitDic[rowItem.Name][1]);
  1439. }
  1440. else if (bitDic.ContainsKey(rowItem.Tag.ToString()))
  1441. {
  1442. int cal_Index = int.Parse(rowItem.Tag.ToString().Replace("img", ""));
  1443. string imgName = this.appWorkspace.DocumentWorkspaces[cal_Index].GetFriendlyName();
  1444. pNamesList.Add(imgName);
  1445. bitList.Add(bitDic[rowItem.Tag.ToString()][0]);
  1446. bitList.Add(bitDic[rowItem.Tag.ToString()][1]);
  1447. }
  1448. //中间数据
  1449. foreach (ExportProjectModel model in this.tempDataModel)
  1450. {
  1451. if (model.tagName.Equals(rowItem.Name))
  1452. {
  1453. ExportProjectModel tempModel = new ExportProjectModel();
  1454. tempModel.tagName = model.tagName;
  1455. tempModel.picName = model.picName;
  1456. tempModel.dataList = model.dataList;
  1457. exportModel.Add(tempModel);
  1458. break;
  1459. }
  1460. else if (model.tagName.Equals(rowItem.Tag.ToString()))
  1461. {
  1462. ExportProjectModel tempModel = new ExportProjectModel();
  1463. tempModel.tagName = model.tagName;
  1464. tempModel.picName = model.picName;
  1465. tempModel.dataList = model.dataList;
  1466. exportModel.Add(tempModel);
  1467. break;
  1468. }
  1469. }
  1470. }
  1471. }
  1472. string dictPath = Application.StartupPath + "\\temp";
  1473. if (!System.IO.Directory.Exists(dictPath))
  1474. {
  1475. System.IO.Directory.CreateDirectory(dictPath);
  1476. }
  1477. DeleteFolder(dictPath);
  1478. pNames = new Dictionary<string, string>();
  1479. int insertIn = 0;
  1480. for (int k = 0; k < bitList.Count; k += 2)
  1481. {//保存处理后的图片
  1482. List<Bitmap> tempBit = new List<Bitmap>();
  1483. tempBit.Add((Bitmap)bitList[k].Clone());
  1484. tempBit.Add((Bitmap)bitList[k+1].Clone());
  1485. this.SaveAllImage(tempBit, dictPath, insertIn + 1, insertIn + 1, pNamesList[insertIn]);
  1486. insertIn++;
  1487. }
  1488. this.appWorkspace.CreateAnalysisReport(this.analyzeSettingModel, analysisContent, exportModel, bitList, tagInfos, nodeItem.path, nodeItem.code, dictPath, pNames);
  1489. //保存项目信息到数据库
  1490. this.appWorkspace.InsertIntoDB(this.analyzeSettingModel, nodeItem);
  1491. }
  1492. else
  1493. MessageBox.Show(PdnResources.GetString("Menu.Pleasesettheanalysisreportfirst.text")+"!");
  1494. }
  1495. Dictionary<string, string> pNames = new Dictionary<string, string>();
  1496. /// <summary>
  1497. /// 保存图片到本地
  1498. /// </summary>
  1499. /// <param name="bitList"></param>
  1500. private void SaveAllImage(List<Bitmap> bitList, string newPath, int originNum, int codeNum, string pName)
  1501. {
  1502. if (bitList != null && bitList.Count > 0)
  1503. {
  1504. for (int i = 0; i < bitList.Count; i++)
  1505. {
  1506. string bitPath = "";
  1507. //分别为原图和处理后的图命名
  1508. if (i % 2 == 0)
  1509. {
  1510. bitPath = newPath + "/" + "origin" + originNum + ".jpg";
  1511. pNames.Add("origin" + originNum, pName);
  1512. }
  1513. else
  1514. {
  1515. bitPath = newPath + "/" + codeNum + ".jpg";
  1516. pNames.Add(codeNum.ToString(), pName);
  1517. }
  1518. bitList[i].Save(bitPath);
  1519. }
  1520. }
  1521. }
  1522. public void DeleteFolder(string path)
  1523. {
  1524. foreach (string d in Directory.GetFileSystemEntries(path))
  1525. {
  1526. if (System.IO.File.Exists(d))
  1527. {
  1528. FileInfo fi = new FileInfo(d);
  1529. if (fi.Attributes.ToString().IndexOf("ReadOnly") != -1)
  1530. fi.Attributes = FileAttributes.Normal;
  1531. System.IO.File.Delete(d);//直接删除其中的文件
  1532. }
  1533. else
  1534. {
  1535. DirectoryInfo d1 = new DirectoryInfo(d);
  1536. if (d1.GetFiles().Length != 0)
  1537. {
  1538. DeleteFolder(d1.FullName);
  1539. }
  1540. Directory.Delete(d);
  1541. }
  1542. }
  1543. }
  1544. /// <summary>
  1545. /// 导出结果
  1546. /// </summary>
  1547. /// <param name="sender"></param>
  1548. /// <param name="e"></param>
  1549. private void button_exportResults_Click(object sender, EventArgs e)
  1550. {
  1551. if (this.listView2.Items.Count > 0)
  1552. {
  1553. List<System.Data.DataTable> list = new List<System.Data.DataTable>();
  1554. System.Data.DataTable table1 = new System.Data.DataTable();
  1555. table1.TableName = PdnResources.GetString("Menu.breakdown.text");
  1556. foreach (DataGridViewColumn c in this.dataGridView2.Columns)
  1557. {
  1558. table1.Columns.Add(HeaderTextUsable ? c.HeaderText : c.Name);
  1559. }
  1560. for (int r = 0; r < this.dataGridView2.Rows.Count; r++)
  1561. {
  1562. System.Data.DataRow dataRow = table1.NewRow();
  1563. if (r == 0)
  1564. {
  1565. for (int c = 0; c < this.dataGridView2.Rows[r].Cells.Count; c++)
  1566. {
  1567. dataRow[HeaderTextUsable ? this.dataGridView2.Columns[c].HeaderText : this.dataGridView2.Columns[c].Name] = this.dataGridView2.Columns[c].HeaderText;
  1568. }
  1569. table1.Rows.Add(dataRow);
  1570. }
  1571. dataRow = table1.NewRow();
  1572. for (int c = 0; c < this.dataGridView2.Rows[r].Cells.Count; c++)
  1573. {
  1574. dataRow[HeaderTextUsable ? this.dataGridView2.Columns[c].HeaderText : this.dataGridView2.Columns[c].Name] = this.dataGridView2.Rows[r].Cells[c].Value;
  1575. }
  1576. table1.Rows.Add(dataRow);
  1577. }
  1578. System.Data.DataTable table2 = new System.Data.DataTable();
  1579. table2.TableName = PdnResources.GetString("Menu.statisaatics.text");
  1580. foreach (DataGridViewColumn c in this.dataGridView_Total.Columns)
  1581. {
  1582. table2.Columns.Add(HeaderTextUsable ? c.HeaderText : c.Name);
  1583. }
  1584. for (int r = 0; r < this.dataGridView_Total.Rows.Count; r++)
  1585. {
  1586. System.Data.DataRow dataRow = table2.NewRow();
  1587. if (r == 0)
  1588. {
  1589. for (int c = 0; c < this.dataGridView_Total.Rows[r].Cells.Count; c++)
  1590. {
  1591. dataRow[HeaderTextUsable ? this.dataGridView_Total.Columns[c].HeaderText : this.dataGridView_Total.Columns[c].Name] = this.dataGridView_Total.Columns[c].HeaderText;
  1592. }
  1593. table2.Rows.Add(dataRow);
  1594. }
  1595. dataRow = table2.NewRow();
  1596. for (int c = 0; c < this.dataGridView_Total.Rows[r].Cells.Count; c++)
  1597. {
  1598. dataRow[HeaderTextUsable ? this.dataGridView_Total.Columns[c].HeaderText : this.dataGridView_Total.Columns[c].Name] = this.dataGridView_Total.Rows[r].Cells[c].Value;
  1599. }
  1600. table2.Rows.Add(dataRow);
  1601. }
  1602. if (table2.Rows.Count > 0) list.Add(table2);
  1603. if (table1.Rows.Count > 0) list.Add(table1);
  1604. if (list.Count == 0)
  1605. {
  1606. MessageBox.Show(PdnResources.GetString("Menu.Nonedata.Text") + "!");
  1607. return;
  1608. }
  1609. SaveFileDialog saveFileDialog = new SaveFileDialog();
  1610. saveFileDialog.DefaultExt = "xlsx";
  1611. saveFileDialog.Title = PdnResources.GetString("Menu.ExportdatatoEXECLtable.Text");
  1612. saveFileDialog.FileName = this.Text + PdnResources.GetString("Menu.Analysisresult.text") + DateTime.Now.ToString("yyyyMMddhhmmss");
  1613. saveFileDialog.Filter = "microsoft office execl files (*.xlsx)|*.xlsx";
  1614. saveFileDialog.RestoreDirectory = true;
  1615. if (saveFileDialog.ShowDialog() == DialogResult.OK)
  1616. this.appWorkspace.ExportDataToExcelWithProgress(list, saveFileDialog.FileName, HeaderTextUsable, false, true);
  1617. }
  1618. else
  1619. MessageBox.Show(PdnResources.GetString("Menu.Noanalysisresults.text")+"!");
  1620. }
  1621. /// <summary>
  1622. /// 画布绘制
  1623. /// </summary>
  1624. /// <param name="sender"></param>
  1625. /// <param name="e"></param>
  1626. private void Panel_Paint(object sender, PaintEventArgs e)
  1627. {
  1628. if (this.documentWorkspace.CompositionSurface != null)
  1629. {
  1630. //
  1631. // 以下是计算绘制图片的位置和大小并绘制图片
  1632. //
  1633. System.Drawing.Rectangle rc = this.documentWorkspace.panel.ClientRectangle;
  1634. int width = (int)(this.documentWorkspace.CompositionSurface.Width * this.documentWorkspace.ScaleFactor.Ratio);
  1635. int height = (int)(this.documentWorkspace.CompositionSurface.Height * this.documentWorkspace.ScaleFactor.Ratio);
  1636. int x = (rc.Width < width) ? this.documentWorkspace.panel.AutoScrollPosition.X : (rc.Width - width) / 2;
  1637. int y = (rc.Height < height) ? this.documentWorkspace.panel.AutoScrollPosition.Y : (rc.Height - height) / 2;
  1638. //
  1639. // 以下是绘制网格、标注、测量、视场等开始
  1640. //
  1641. e.Graphics.TranslateTransform(x, y);
  1642. e.Graphics.ScaleTransform((float)this.documentWorkspace.ScaleFactor.Ratio, (float)this.documentWorkspace.ScaleFactor.Ratio);
  1643. Draw(e.Graphics);
  1644. e.Graphics.ScaleTransform(1 / (float)this.documentWorkspace.ScaleFactor.Ratio, 1 / (float)this.documentWorkspace.ScaleFactor.Ratio);
  1645. e.Graphics.TranslateTransform(-x, -y);
  1646. }
  1647. }
  1648. /// <summary>
  1649. /// 绘制
  1650. /// </summary>
  1651. private void Draw(Graphics graphics)
  1652. {
  1653. // 抗锯齿
  1654. graphics.SmoothingMode = SmoothingMode.AntiAlias;
  1655. drawSubclass(graphics);
  1656. }
  1657. /// <summary>
  1658. /// 计算汇总列表的平均晶粒度级别
  1659. /// </summary>
  1660. /// <returns></returns>
  1661. protected virtual string getGradeTotalCal(DataGridViewRow dgvr, int digits = -1)
  1662. {
  1663. return "00A";
  1664. }
  1665. /// <summary>
  1666. /// 取消全部显示
  1667. /// </summary>
  1668. /// <param name="sender"></param>
  1669. /// <param name="e"></param>
  1670. private void button16_Click(object sender, EventArgs e)
  1671. {
  1672. this.button11.Visible = true;
  1673. this.button16.Visible = false;
  1674. this.button11.Focus();
  1675. this.allShow = false;
  1676. this.dataGridView2.Rows.Clear();
  1677. if (this.listView2.SelectedItems.Count <= 0)
  1678. {
  1679. if (this.listView2.Items.Count > 0)
  1680. {
  1681. this.listView2.Items[this.listView2.Items.Count - 1].Selected = true;
  1682. }
  1683. else
  1684. {
  1685. return;
  1686. }
  1687. }
  1688. List<List<double>> valueList = new List<List<double>>();
  1689. double value_1 = 0;
  1690. double small_l = 0;
  1691. this.dataGridView2.Rows.Clear();
  1692. for (int i = 0; i < this.listView2.SelectedItems.Count; i++)
  1693. {
  1694. System.Data.DataTable dataTable1 = new System.Data.DataTable();
  1695. foreach (var dataTable in this.dataTables)
  1696. {
  1697. if (this.listView2.SelectedItems.Count > 0)
  1698. {
  1699. if (this.listView2.SelectedItems[i].Tag.Equals(dataTable.TableName))
  1700. {
  1701. dataTable1 = dataTable;
  1702. for (int rIndex = 0; rIndex < dataTable1.Rows.Count; rIndex++)
  1703. {
  1704. DataGridViewRow dgvr = new DataGridViewRow();
  1705. foreach (DataGridViewColumn Column in this.dataGridView2.Columns)
  1706. {
  1707. dgvr.Cells.Add(Column.CellTemplate.Clone() as DataGridViewCell);
  1708. }
  1709. List<double> valueL = new List<double>();
  1710. for (int c = 0; c < dataTable1.Columns.Count; c++)
  1711. {
  1712. dgvr.Cells[c].Value = dataTable1.Rows[rIndex][c].ToString();
  1713. if (IndexChangedFromIndex.Count > 0)
  1714. {
  1715. if (IndexChangedFromIndex.Contains(c))
  1716. valueL.Add(double.Parse(dataTable1.Rows[rIndex][c].ToString()));
  1717. continue;
  1718. }
  1719. if (c == 3)
  1720. value_1 += double.Parse(dataTable1.Rows[rIndex][c].ToString());
  1721. if (grainMethodType == 1 && c == 4 || grainMethodType == 0 && c == 2)
  1722. small_l += double.Parse(dataTable1.Rows[rIndex][c].ToString());
  1723. }
  1724. if (IndexChangedFromIndex.Count > 0)
  1725. valueList.Add(valueL);
  1726. this.dataGridView2.Rows.Add(dgvr);
  1727. }
  1728. }
  1729. }
  1730. else
  1731. {
  1732. if (this.listView2.Items[0].Tag.Equals(dataTable.TableName))
  1733. {
  1734. dataTable1 = dataTable;
  1735. for (int rIndex = 0; rIndex < dataTable1.Rows.Count; rIndex++)
  1736. {
  1737. DataGridViewRow dgvr = new DataGridViewRow();
  1738. foreach (DataGridViewColumn Column in this.dataGridView2.Columns)
  1739. {
  1740. dgvr.Cells.Add(Column.CellTemplate.Clone() as DataGridViewCell);
  1741. }
  1742. List<double> valueL = new List<double>();
  1743. for (int c = 0; c < dataTable1.Columns.Count; c++)
  1744. {
  1745. dgvr.Cells[c].Value = dataTable1.Rows[rIndex][c].ToString();
  1746. if (IndexChangedFromIndex.Count > 0)
  1747. {
  1748. if (IndexChangedFromIndex.Contains(c))
  1749. valueL.Add(double.Parse(dataTable1.Rows[rIndex][c].ToString()));
  1750. continue;
  1751. }
  1752. if (c == 3)
  1753. value_1 += double.Parse(dataTable1.Rows[rIndex][c].ToString());
  1754. if (grainMethodType == 1 && c == 4 || grainMethodType == 0 && c == 2)
  1755. small_l += double.Parse(dataTable1.Rows[rIndex][c].ToString());
  1756. }
  1757. if (IndexChangedFromIndex.Count > 0)
  1758. valueList.Add(valueL);
  1759. this.dataGridView2.Rows.Add(dgvr);
  1760. }
  1761. }
  1762. }
  1763. }
  1764. }
  1765. this.dataGridView_Total.Rows.Clear();
  1766. if (IndexChangedFromIndex.Count > 0 && IndexChangedToIndex.Count > 0 && valueList.Count > 0)
  1767. {
  1768. DataGridViewRow dgvr = new DataGridViewRow();
  1769. foreach (DataGridViewColumn Column in this.dataGridView_Total.Columns)
  1770. {
  1771. dgvr.Cells.Add(Column.CellTemplate.Clone() as DataGridViewCell);
  1772. }
  1773. foreach (int itemkey in IndexChangedToIndex.Keys)
  1774. {
  1775. int[] itemValue = IndexChangedToIndex[itemkey];
  1776. List<double> valueL = new List<double>();//级别时会多算一遍,应该不影响什么
  1777. if (itemValue[1] >= 0)
  1778. foreach (List<double> itemL in valueList)
  1779. {
  1780. valueL.Add(itemL[itemValue[1]]);
  1781. }
  1782. if (itemValue[0] == 1)//求和
  1783. dgvr.Cells[itemkey].Value = valueL.Sum().ToString();
  1784. else if (itemValue[0] == 2)//平均
  1785. dgvr.Cells[itemkey].Value = valueL.Average().ToString();
  1786. else if (itemValue[0] == 3)//级别
  1787. if (itemValue[1] < 0)
  1788. {
  1789. dgvr.Cells[itemkey].Value = getGradeTotalCal(dgvr, Convert.ToInt32(this.numericUpDown1_0.Value));//############
  1790. }
  1791. else
  1792. dgvr.Cells[itemkey].Value = getGradeValue(double.Parse(dgvr.Cells[itemValue[1]].Value.ToString()));
  1793. }
  1794. this.dataGridView_Total.Rows.Add(dgvr);
  1795. this.RefreshDataGridView4();
  1796. return;
  1797. }
  1798. double grainNumber = 0;
  1799. if (getGbtType() == 3)
  1800. value_1 = 0;
  1801. for (int i = 0; i < this.listView2.SelectedItems.Count; i++)
  1802. {
  1803. System.Data.DataTable dataTable1 = new System.Data.DataTable();
  1804. foreach (var dataTable in this.dataTable_Totals)
  1805. {
  1806. if (this.listView2.SelectedItems.Count > 0)
  1807. {
  1808. if (this.listView2.SelectedItems[i].Tag.Equals(dataTable.TableName))
  1809. dataTable1 = dataTable;
  1810. }
  1811. else
  1812. {
  1813. if (this.listView2.Items[0].Tag.Equals(dataTable.TableName))
  1814. dataTable1 = dataTable;
  1815. }
  1816. }
  1817. grainNumber += double.Parse(dataTable1.Rows[0][grainMethodType == 1 ? 0 : 1].ToString());
  1818. if (this.dict_Totals.ContainsKey(this.listView2.SelectedItems[i].Tag.ToString()))
  1819. {
  1820. Dictionary<string, object> valuePairs = this.dict_Totals[this.listView2.SelectedItems[i].Tag.ToString()];
  1821. if (valuePairs.ContainsKey("RectArea"))
  1822. value_1 += (double)valuePairs["RectArea"];
  1823. }
  1824. }
  1825. {
  1826. DataGridViewRow dgvr = new DataGridViewRow();
  1827. foreach (DataGridViewColumn Column in this.dataGridView_Total.Columns)
  1828. {
  1829. dgvr.Cells.Add(Column.CellTemplate.Clone() as DataGridViewCell);
  1830. }
  1831. dgvr.Cells[0].Value = (grainMethodType == 1 ? grainNumber : small_l).ToString();
  1832. if (getGbtType() == 3)
  1833. {
  1834. if (grainNumber > 0)
  1835. value_1 = value_1 / grainNumber;
  1836. value_1 = value_1 * 0.001 * 0.001;
  1837. dgvr.Cells[1].Value = (3.321928 * Math.Log10(1.0 / value_1) - 2.954).ToString();
  1838. }
  1839. else
  1840. {
  1841. dgvr.Cells[1].Value = (grainMethodType == 1 ? small_l : value_1).ToString();
  1842. if (grainMethodType == 1 && grainNumber > 0)
  1843. small_l = small_l / grainNumber;
  1844. else if (grainMethodType == 0 && value_1 > 0)
  1845. small_l = small_l / value_1;
  1846. dgvr.Cells[2].Value = small_l.ToString();
  1847. if (getGbtType() == 4)
  1848. dgvr.Cells[3].Value = (-6.6439 * Math.Log10(small_l * 0.001) - 3.2877).ToString();
  1849. else
  1850. dgvr.Cells[3].Value = (-6.643856 * Math.Log10(small_l * 0.001) - 3.288).ToString();
  1851. if (grainMethodType == 1)
  1852. {
  1853. if (dgvr.Cells.Count > 4)
  1854. {
  1855. if (grainNumber > 0)
  1856. value_1 = value_1 / grainNumber;
  1857. dgvr.Cells[4].Value = value_1.ToString();
  1858. value_1 = value_1 * 0.001 * 0.001;
  1859. }
  1860. if (dgvr.Cells.Count > 5)
  1861. {
  1862. if (getGbtType() == 4)
  1863. dgvr.Cells[5].Value = (3.32 * Math.Log10(1.0 / value_1) - 2.9542).ToString();
  1864. else
  1865. dgvr.Cells[5].Value = (3.321928 * Math.Log10(1.0 / value_1) - 2.954).ToString();
  1866. }
  1867. }
  1868. }
  1869. this.dataGridView_Total.Rows.Add(dgvr);
  1870. }
  1871. //##
  1872. this.RefreshDataGridView4();
  1873. }
  1874. /// <summary>
  1875. /// 切换分析结果
  1876. /// </summary>
  1877. /// <param name="sender"></param>
  1878. /// <param name="e"></param>
  1879. private void listview2_SelectedIndexChanged(object sender, EventArgs e)
  1880. {
  1881. if (!this.allShow)
  1882. {
  1883. if (this.listView2.SelectedItems.Count <= 0)
  1884. return;
  1885. List<List<double>> valueList = new List<List<double>>();
  1886. double value_1 = 0;
  1887. double small_l = 0;
  1888. this.dataGridView2.Rows.Clear();
  1889. for (int i = 0; i < this.listView2.SelectedItems.Count; i++)
  1890. {
  1891. System.Data.DataTable dataTable1 = new System.Data.DataTable();
  1892. foreach (var dataTable in this.dataTables)
  1893. {
  1894. if (this.listView2.SelectedItems[i].Tag.Equals(dataTable.TableName))
  1895. {
  1896. dataTable1 = dataTable;
  1897. for (int rIndex = 0; rIndex < dataTable1.Rows.Count; rIndex++)
  1898. {
  1899. DataGridViewRow dgvr = new DataGridViewRow();
  1900. foreach (DataGridViewColumn Column in this.dataGridView2.Columns)
  1901. {
  1902. dgvr.Cells.Add(Column.CellTemplate.Clone() as DataGridViewCell);
  1903. }
  1904. List<double> valueL = new List<double>();
  1905. for (int c = 0; c < dataTable1.Columns.Count; c++)
  1906. {
  1907. dgvr.Cells[c].Value = dataTable1.Rows[rIndex][c].ToString();
  1908. if (IndexChangedFromIndex.Count > 0)
  1909. {
  1910. if (IndexChangedFromIndex.Contains(c))
  1911. valueL.Add(double.Parse(dataTable1.Rows[rIndex][c].ToString()));
  1912. continue;
  1913. }
  1914. if (c == 3)
  1915. value_1 += double.Parse(dataTable1.Rows[rIndex][c].ToString());
  1916. if (grainMethodType == 1 && c == 4 || grainMethodType == 0 && c == 2)
  1917. small_l += double.Parse(dataTable1.Rows[rIndex][c].ToString());
  1918. }
  1919. if (IndexChangedFromIndex.Count > 0)
  1920. valueList.Add(valueL);
  1921. this.dataGridView2.Rows.Add(dgvr);
  1922. }
  1923. }
  1924. }
  1925. }
  1926. this.dataGridView_Total.Rows.Clear();
  1927. if (IndexChangedFromIndex.Count > 0 && IndexChangedToIndex.Count > 0 && valueList.Count > 0)
  1928. {
  1929. DataGridViewRow dgvr = new DataGridViewRow();
  1930. foreach (DataGridViewColumn Column in this.dataGridView_Total.Columns)
  1931. {
  1932. dgvr.Cells.Add(Column.CellTemplate.Clone() as DataGridViewCell);
  1933. }
  1934. foreach (int itemkey in IndexChangedToIndex.Keys)
  1935. {
  1936. int[] itemValue = IndexChangedToIndex[itemkey];
  1937. List<double> valueL = new List<double>();//级别时会多算一遍,应该不影响什么
  1938. if (itemValue[1] >= 0)
  1939. foreach (List<double> itemL in valueList)
  1940. {
  1941. valueL.Add(itemL[itemValue[1]]);
  1942. }
  1943. if (itemValue[0] == 1)//求和
  1944. dgvr.Cells[itemkey].Value = valueL.Sum().ToString();
  1945. else if (itemValue[0] == 2)//平均
  1946. dgvr.Cells[itemkey].Value = valueL.Average().ToString();
  1947. else if (itemValue[0] == 3)//级别
  1948. if (itemValue[1] < 0)
  1949. {
  1950. dgvr.Cells[itemkey].Value = getGradeTotalCal(dgvr, Convert.ToInt32(this.numericUpDown1_0.Value));
  1951. }
  1952. else
  1953. dgvr.Cells[itemkey].Value = getGradeValue(double.Parse(dgvr.Cells[itemValue[1]].Value.ToString()));
  1954. }
  1955. this.dataGridView_Total.Rows.Add(dgvr);
  1956. this.RefreshDataGridView4();
  1957. return;
  1958. }
  1959. double grainNumber = 0;
  1960. if (getGbtType() == 3)
  1961. value_1 = 0;
  1962. for (int i = 0; i < this.listView2.SelectedItems.Count; i++)
  1963. {
  1964. System.Data.DataTable dataTable1 = new System.Data.DataTable();
  1965. foreach (var dataTable in this.dataTable_Totals)
  1966. {
  1967. if (this.listView2.SelectedItems[i].Tag.Equals(dataTable.TableName))
  1968. dataTable1 = dataTable;
  1969. }
  1970. if (this.dict_Totals.ContainsKey(this.listView2.SelectedItems[i].Tag.ToString()))
  1971. {
  1972. Dictionary<string, object> valuePairs = this.dict_Totals[this.listView2.SelectedItems[i].Tag.ToString()];
  1973. if (valuePairs.ContainsKey("RectArea"))
  1974. value_1 += (double)valuePairs["RectArea"];
  1975. }
  1976. grainNumber += double.Parse(dataTable1.Rows[0][grainMethodType == 1 ? 0 : 1].ToString());//###21939
  1977. }
  1978. {
  1979. DataGridViewRow dgvr = new DataGridViewRow();
  1980. foreach (DataGridViewColumn Column in this.dataGridView_Total.Columns)
  1981. {
  1982. dgvr.Cells.Add(Column.CellTemplate.Clone() as DataGridViewCell);
  1983. }
  1984. dgvr.Cells[0].Value = (grainMethodType == 1 ? grainNumber : small_l).ToString();
  1985. if (getGbtType() == 3)
  1986. {
  1987. if (grainNumber > 0)
  1988. value_1 = value_1 / grainNumber;
  1989. value_1 = value_1 * 0.001 * 0.001;
  1990. dgvr.Cells[1].Value = (3.321928 * Math.Log10(1.0 / value_1) - 2.954).ToString();
  1991. }
  1992. else
  1993. {
  1994. dgvr.Cells[1].Value = (grainMethodType == 1 ? small_l : value_1).ToString();
  1995. if (grainMethodType == 1 && grainNumber > 0)
  1996. small_l = small_l / grainNumber;
  1997. else if (grainMethodType == 0 && value_1 > 0)
  1998. small_l = small_l / value_1;
  1999. dgvr.Cells[2].Value = small_l.ToString();
  2000. if (getGbtType() == 4)
  2001. dgvr.Cells[3].Value = (-6.6439 * Math.Log10(small_l * 0.001) - 3.2877).ToString();
  2002. else
  2003. dgvr.Cells[3].Value = (-6.643856 * Math.Log10(small_l * 0.001) - 3.288).ToString();
  2004. if (grainMethodType == 1)
  2005. {
  2006. if (grainNumber > 0)
  2007. value_1 = value_1 / grainNumber;
  2008. if (dgvr.Cells.Count > 4)
  2009. {
  2010. dgvr.Cells[4].Value = value_1.ToString();
  2011. value_1 = value_1 * 0.001 * 0.001;
  2012. }
  2013. if (dgvr.Cells.Count > 5)
  2014. {
  2015. if (getGbtType() == 4)
  2016. dgvr.Cells[5].Value = (3.32 * Math.Log10(1.0 / value_1) - 2.9542).ToString();
  2017. else
  2018. dgvr.Cells[5].Value = (3.321928 * Math.Log10(1.0 / value_1) - 2.954).ToString();
  2019. }
  2020. }
  2021. }
  2022. this.dataGridView_Total.Rows.Add(dgvr);
  2023. }
  2024. //##
  2025. this.RefreshDataGridView4();
  2026. }
  2027. }
  2028. /// <summary>
  2029. /// 全部显示
  2030. /// </summary>
  2031. /// <param name="sender"></param>
  2032. /// <param name="e"></param>
  2033. private void button11_Click(object sender, EventArgs e)
  2034. {
  2035. if (this.listView2.Items.Count > 0)
  2036. {
  2037. this.button11.Visible = false;
  2038. this.button16.Visible = true;
  2039. this.button16.Focus();
  2040. this.allShow = true;
  2041. List<List<double>> valueList = new List<List<double>>();
  2042. double value_1 = 0;
  2043. double small_l = 0;
  2044. this.dataGridView2.Rows.Clear();
  2045. for (int i = 0; i < this.dataTables.Count; i++)
  2046. {
  2047. for (int rIndex = 0; rIndex < this.dataTables[i].Rows.Count; rIndex++)
  2048. {
  2049. DataGridViewRow dgvr = new DataGridViewRow();
  2050. foreach (DataGridViewColumn Column in this.dataGridView2.Columns)
  2051. {
  2052. dgvr.Cells.Add(Column.CellTemplate.Clone() as DataGridViewCell);
  2053. }
  2054. List<double> valueL = new List<double>();
  2055. for (int c = 0; c < this.dataTables[i].Columns.Count; c++)
  2056. {
  2057. dgvr.Cells[c].Value = this.dataTables[i].Rows[rIndex][c].ToString();
  2058. if (IndexChangedFromIndex.Count > 0)
  2059. {
  2060. if (IndexChangedFromIndex.Contains(c))
  2061. valueL.Add(double.Parse(this.dataTables[i].Rows[rIndex][c].ToString()));
  2062. continue;
  2063. }
  2064. if (c == 3)
  2065. value_1 += double.Parse(this.dataTables[i].Rows[rIndex][c].ToString());
  2066. if (grainMethodType == 1 && c == 4 || grainMethodType == 0 && c == 2)
  2067. small_l += double.Parse(this.dataTables[i].Rows[rIndex][c].ToString());
  2068. }
  2069. if (IndexChangedFromIndex.Count > 0)
  2070. valueList.Add(valueL);
  2071. this.dataGridView2.Rows.Add(dgvr);
  2072. }
  2073. }
  2074. this.dataGridView_Total.Rows.Clear();
  2075. if (IndexChangedFromIndex.Count > 0 && IndexChangedToIndex.Count > 0 && valueList.Count > 0)
  2076. {
  2077. DataGridViewRow dgvr = new DataGridViewRow();
  2078. foreach (DataGridViewColumn Column in this.dataGridView_Total.Columns)
  2079. {
  2080. dgvr.Cells.Add(Column.CellTemplate.Clone() as DataGridViewCell);
  2081. }
  2082. foreach (int itemkey in IndexChangedToIndex.Keys)
  2083. {
  2084. int[] itemValue = IndexChangedToIndex[itemkey];
  2085. List<double> valueL = new List<double>();//级别时会多算一遍,应该不影响什么
  2086. if (itemValue[1] >= 0)
  2087. foreach (List<double> itemL in valueList)
  2088. {
  2089. valueL.Add(itemL[itemValue[1]]);
  2090. }
  2091. if (itemValue[0] == 1)//求和
  2092. dgvr.Cells[itemkey].Value = valueL.Sum().ToString();
  2093. else if (itemValue[0] == 2)//平均
  2094. dgvr.Cells[itemkey].Value = valueL.Average().ToString();
  2095. else if (itemValue[0] == 3)//级别
  2096. if (itemValue[1] < 0)
  2097. {
  2098. dgvr.Cells[itemkey].Value = getGradeTotalCal(dgvr, Convert.ToInt32(this.numericUpDown1_0.Value));
  2099. }
  2100. else
  2101. dgvr.Cells[itemkey].Value = getGradeValue(double.Parse(dgvr.Cells[itemValue[1]].Value.ToString()));
  2102. }
  2103. this.dataGridView_Total.Rows.Add(dgvr);
  2104. this.RefreshDataGridView4();
  2105. return;
  2106. }
  2107. double grainNumber = 0;
  2108. for (int i = 0; i < this.dataTable_Totals.Count; i++)
  2109. {
  2110. grainNumber += double.Parse(this.dataTable_Totals[i].Rows[0][grainMethodType == 1 ? 0 : 1].ToString());
  2111. }
  2112. if (getGbtType() == 3)
  2113. value_1 = 0;
  2114. for (int j = 0; j < this.listView2.Items.Count; j++)
  2115. {
  2116. if (this.dict_Totals.ContainsKey(this.listView2.Items[j].Tag.ToString()))
  2117. {
  2118. Dictionary<string, object> valuePairs = this.dict_Totals[this.listView2.Items[j].Tag.ToString()];
  2119. if (valuePairs.ContainsKey("RectArea"))
  2120. value_1 += (double)valuePairs["RectArea"];
  2121. }
  2122. }
  2123. {
  2124. DataGridViewRow dgvr = new DataGridViewRow();
  2125. foreach (DataGridViewColumn Column in this.dataGridView_Total.Columns)
  2126. {
  2127. dgvr.Cells.Add(Column.CellTemplate.Clone() as DataGridViewCell);
  2128. }
  2129. dgvr.Cells[0].Value = (grainMethodType == 1 ? grainNumber : small_l).ToString();
  2130. if (getGbtType() == 3)
  2131. {
  2132. if (grainNumber > 0)
  2133. value_1 = value_1 / grainNumber;
  2134. value_1 = value_1 * 0.001 * 0.001;
  2135. dgvr.Cells[1].Value = (3.321928 * Math.Log10(1.0 / value_1) - 2.954).ToString();
  2136. }
  2137. else
  2138. {
  2139. dgvr.Cells[1].Value = (grainMethodType == 1 ? small_l : value_1).ToString();
  2140. if (grainMethodType == 1 && grainNumber > 0)
  2141. small_l = small_l / grainNumber;
  2142. else if (grainMethodType == 0 && value_1 > 0)
  2143. small_l = small_l / value_1;
  2144. dgvr.Cells[2].Value = small_l.ToString();
  2145. if (getGbtType() == 4)
  2146. dgvr.Cells[3].Value = (-6.6439 * Math.Log10(small_l * 0.001) - 3.2877).ToString();
  2147. else
  2148. dgvr.Cells[3].Value = (-6.643856 * Math.Log10(small_l * 0.001) - 3.288).ToString();
  2149. if (grainMethodType == 1)
  2150. {
  2151. if (grainNumber > 0)
  2152. value_1 = value_1 / grainNumber;
  2153. if (dgvr.Cells.Count >= 5)
  2154. {
  2155. dgvr.Cells[4].Value = value_1.ToString();
  2156. value_1 = value_1 * 0.001 * 0.001;
  2157. }
  2158. if (dgvr.Cells.Count >= 6)
  2159. {
  2160. if (getGbtType() == 4)
  2161. dgvr.Cells[5].Value = (3.32 * Math.Log10(1.0 / value_1) - 2.9542).ToString();
  2162. else
  2163. dgvr.Cells[5].Value = (3.321928 * Math.Log10(1.0 / value_1) - 2.954).ToString();
  2164. }
  2165. }
  2166. }
  2167. this.dataGridView_Total.Rows.Add(dgvr);
  2168. }
  2169. this.RefreshDataGridView4();
  2170. }
  2171. else
  2172. {
  2173. MessageBox.Show(PdnResources.GetString("Menu.nodata.text")+"!");
  2174. }
  2175. }
  2176. /// <summary>
  2177. /// 分析结果删除
  2178. /// </summary>
  2179. /// <param name="sender"></param>
  2180. /// <param name="e"></param>
  2181. private void button12_Click(object sender, EventArgs e)
  2182. {
  2183. if (this.listView2.Items.Count > 0)
  2184. {
  2185. if (this.listView2.SelectedItems.Count > 0)
  2186. {
  2187. DialogResult dr = MessageBox.Show(PdnResources.GetString("Menu.Areyousuretcteddata.text")+"?", PdnResources.GetString("Menu.hint.text"), MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
  2188. if (dr == DialogResult.OK)
  2189. {
  2190. if (this.listView2.SelectedItems.Count <= 0)
  2191. return;
  2192. for (int i = this.listView2.SelectedItems.Count - 1; i >= 0; i--)
  2193. {
  2194. int selectIndex = this.listView2.SelectedItems[i].Index;
  2195. foreach (var dataTable in this.dataTable_Totals)
  2196. {
  2197. if (dataTable.TableName.Equals(this.listView2.SelectedItems[i].Tag))
  2198. {
  2199. this.dataTable_Totals.Remove(dataTable);
  2200. break;
  2201. }
  2202. }
  2203. if (this.dict_Totals.ContainsKey(this.listView2.SelectedItems[i].Tag.ToString()))
  2204. this.dict_Totals.Remove(this.listView2.SelectedItems[i].Tag.ToString());
  2205. for (int dataTableI = dataTables.Count - 1; dataTableI >= 0; dataTableI--)
  2206. {
  2207. System.Data.DataTable dataTable1 = dataTables[dataTableI];
  2208. if (dataTable1.TableName.Equals(this.listView2.SelectedItems[i].Tag/*tag*/))
  2209. dataTables.RemoveAt(dataTableI);
  2210. }
  2211. if (bitDic.ContainsKey((string)this.listView2.SelectedItems[i].Tag))
  2212. bitDic.Remove((string)this.listView2.SelectedItems[i].Tag);
  2213. foreach (ExportProjectModel model in this.tempDataModel)
  2214. {
  2215. if (model.tagName.Equals((string)this.listView2.SelectedItems[i].Tag))
  2216. {
  2217. this.tempDataModel.Remove(model);
  2218. break;
  2219. }
  2220. }
  2221. this.listView2.Items.RemoveAt(selectIndex);
  2222. }
  2223. if (this.listView2.Items.Count == 0)
  2224. {
  2225. this.dataGridView_Total.Rows.Clear();
  2226. this.dataGridView2.Rows.Clear();
  2227. this.threeDButton.Enabled = false;
  2228. }
  2229. else
  2230. RefreshDataGridView4();
  2231. }
  2232. }
  2233. else
  2234. {
  2235. MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectthedatatobedeleted.text")+"!");
  2236. }
  2237. }
  2238. else
  2239. {
  2240. MessageBox.Show(PdnResources.GetString("Menu.nodata.text")+"!");
  2241. }
  2242. }
  2243. /// <summary>
  2244. /// 小数位数
  2245. /// </summary>
  2246. /// <param name="sender"></param>
  2247. /// <param name="e"></param>
  2248. private void numericUpDown1_0_ValueChanged(object sender, EventArgs e)
  2249. {
  2250. this.RefreshDataGridView4();
  2251. this.RefreshWhileUpDown1_0ValueChanged();
  2252. }
  2253. /// <summary>
  2254. /// 生成报告
  2255. /// </summary>
  2256. /// <param name="sender"></param>
  2257. /// <param name="e"></param>
  2258. private void button_generateReport_Click(object sender, EventArgs e)
  2259. {
  2260. if (this.listView2.Items.Count == 0)
  2261. {
  2262. MessageBox.Show(PdnResources.GetString("Menu.Noresults.text"));
  2263. return;
  2264. }
  2265. if (this.checkBox_generateReport_opensetting.Checked)
  2266. this.button_setting.PerformClick();
  2267. if (this.analyzeSettingModel != null && !string.IsNullOrEmpty(this.analyzeSettingModel.analyzeClassify))
  2268. {
  2269. //获取word书签与excel单元格的关系,以字典方式存储
  2270. List<mic_module_infos> mic_module_infos = PaintDotNet.DbOpreate.DbBll.mic_module_infos_BLL.FindAll().FindAll(a => a.analyze_classify == this.analyzeSettingModel.analyzeClassify);
  2271. Dictionary<string, string> tagInfos = new Dictionary<string, string>();
  2272. if (mic_module_infos != null && mic_module_infos.Count > 0)
  2273. {
  2274. foreach (mic_module_infos info in mic_module_infos)
  2275. {
  2276. tagInfos.Add(info.tag_name, info.cell_position);
  2277. }
  2278. }
  2279. // 中间数据
  2280. List<ExportProjectModel> exportModel = new List<ExportProjectModel>();
  2281. if (this.allShow)
  2282. {
  2283. //中间数据
  2284. foreach (ExportProjectModel model in this.tempDataModel)
  2285. {
  2286. ExportProjectModel tempModel = new ExportProjectModel();
  2287. tempModel.tagName = model.tagName;
  2288. tempModel.picName = model.picName;
  2289. tempModel.dataList = model.dataList;
  2290. exportModel.Add(tempModel);
  2291. }
  2292. }
  2293. else
  2294. {
  2295. if (this.listView2.SelectedItems != null && this.listView2.SelectedItems.Count > 0)
  2296. {
  2297. //中间数据
  2298. foreach (ListViewItem rowItem in this.listView2.SelectedItems)
  2299. {
  2300. foreach (ExportProjectModel model in this.tempDataModel)
  2301. {
  2302. if (model.tagName.Equals(rowItem.Name))
  2303. {
  2304. ExportProjectModel tempModel = new ExportProjectModel();
  2305. tempModel.tagName = model.tagName;
  2306. tempModel.picName = model.picName;
  2307. tempModel.dataList = model.dataList;
  2308. exportModel.Add(tempModel);
  2309. break;
  2310. }
  2311. else if (model.tagName.Equals(rowItem.Tag.ToString()))
  2312. {
  2313. ExportProjectModel tempModel = new ExportProjectModel();
  2314. tempModel.tagName = model.tagName;
  2315. tempModel.picName = model.picName;
  2316. tempModel.dataList = model.dataList;
  2317. exportModel.Add(tempModel);
  2318. break;
  2319. }
  2320. }
  2321. }
  2322. }
  2323. else if (this.listView2.Items.Count > 0)
  2324. {
  2325. ListViewItem rowItem = this.listView2.Items[0];
  2326. //中间数据
  2327. foreach (ExportProjectModel model in this.tempDataModel)
  2328. {
  2329. if (model.tagName.Equals(rowItem.Name))
  2330. {
  2331. ExportProjectModel tempModel = new ExportProjectModel();
  2332. tempModel.tagName = model.tagName;
  2333. tempModel.picName = model.picName;
  2334. tempModel.dataList = model.dataList;
  2335. exportModel.Add(tempModel);
  2336. break;
  2337. }
  2338. else if (model.tagName.Equals(rowItem.Tag.ToString()))
  2339. {
  2340. ExportProjectModel tempModel = new ExportProjectModel();
  2341. tempModel.tagName = model.tagName;
  2342. tempModel.picName = model.picName;
  2343. tempModel.dataList = model.dataList;
  2344. exportModel.Add(tempModel);
  2345. break;
  2346. }
  2347. }
  2348. }
  2349. }
  2350. int exportModelIndex = 0;
  2351. //详细数据
  2352. List<List<string>> analysisContent2;
  2353. if (grainMethodType == 1 || tempDataModel == null || tempDataModel.Count == 0)
  2354. analysisContent2 = null;
  2355. else
  2356. {
  2357. analysisContent2 = new List<List<string>>();
  2358. List<string> columnName2 = new List<string>();
  2359. columnName2.Add(PdnResources.GetString("Menu.picture.Text"));
  2360. columnName2.AddRange(exportModel[0].dataList[0]);
  2361. analysisContent2.Add(columnName2);
  2362. foreach (var tempData in exportModel)
  2363. {
  2364. List<List<string>> dataList = tempData.dataList;
  2365. for (int k = 1; k < dataList.Count; k++)
  2366. {
  2367. List<string> strList = new List<string>();
  2368. strList.Add(tempData.picName);
  2369. strList.AddRange(dataList[k]);
  2370. strList[1] = (++exportModelIndex).ToString();
  2371. analysisContent2.Add(strList);
  2372. }
  2373. }
  2374. }
  2375. //分析结果
  2376. List<List<string>> analysisContent = new List<List<string>>();
  2377. List<string> contentHeaderText2 = new List<string>();
  2378. foreach (DataGridViewColumn c in this.dataGridView_Total.Columns)
  2379. {
  2380. contentHeaderText2.Add(c.HeaderText);
  2381. }
  2382. analysisContent.Add(contentHeaderText2);
  2383. foreach (DataGridViewRow item in this.dataGridView_Total.Rows)//##########################
  2384. {
  2385. List<string> content = new List<string>();
  2386. for (int i = 0; i < contentHeaderText2.Count; i++)
  2387. {
  2388. content.Add(item.Cells[i].Value.ToString());
  2389. }
  2390. analysisContent.Add(content);
  2391. }
  2392. List<string> contentHeaderText = new List<string>();
  2393. foreach (DataGridViewColumn c in this.dataGridView2.Columns)
  2394. {
  2395. contentHeaderText.Add(c.HeaderText);
  2396. }
  2397. analysisContent.Add(contentHeaderText);
  2398. foreach (DataGridViewRow item in this.dataGridView2.Rows)//##########################
  2399. {
  2400. List<string> content = new List<string>();
  2401. for (int i = 0; i < contentHeaderText.Count; i++)
  2402. {
  2403. content.Add(item.Cells[i].Value.ToString());
  2404. }
  2405. analysisContent.Add(content);
  2406. }
  2407. //图片
  2408. bitList = new List<Bitmap>();
  2409. List<string> pNamesList = new List<string>();
  2410. if (this.allShow)
  2411. {
  2412. foreach (KeyValuePair<string, List<Bitmap>> kv in this.bitDic)
  2413. {
  2414. int cal_Index = int.Parse(kv.Key.Replace("img", ""));
  2415. string imgName = this.appWorkspace.DocumentWorkspaces[cal_Index].GetFriendlyName();
  2416. pNamesList.Add(imgName);
  2417. bitList.Add(kv.Value[0]);
  2418. bitList.Add(kv.Value[1]);
  2419. }
  2420. }
  2421. else
  2422. {
  2423. if (this.listView2.SelectedItems != null && this.listView2.SelectedItems.Count > 0)
  2424. {
  2425. foreach (ListViewItem item in this.listView2.SelectedItems)
  2426. {
  2427. if (bitDic.ContainsKey(item.Name))
  2428. {
  2429. int cal_Index = int.Parse(item.Name.Replace("img", ""));
  2430. string imgName = this.appWorkspace.DocumentWorkspaces[cal_Index].GetFriendlyName();
  2431. pNamesList.Add(imgName);
  2432. bitList.Add(bitDic[item.Name][0]);
  2433. bitList.Add(bitDic[item.Name][1]);
  2434. }
  2435. else if (bitDic.ContainsKey(item.Tag.ToString()))
  2436. {
  2437. int cal_Index = int.Parse(item.Tag.ToString().Replace("img", ""));
  2438. string imgName = this.appWorkspace.DocumentWorkspaces[cal_Index].GetFriendlyName();
  2439. pNamesList.Add(imgName);
  2440. bitList.Add(bitDic[item.Tag.ToString()][0]);
  2441. bitList.Add(bitDic[item.Tag.ToString()][1]);
  2442. }
  2443. }
  2444. }
  2445. else if (this.listView2.Items.Count > 0)
  2446. {
  2447. ListViewItem item = this.listView2.Items[0];
  2448. if (bitDic.ContainsKey(item.Name))
  2449. {
  2450. int cal_Index = int.Parse(item.Name.Replace("img", ""));
  2451. string imgName = this.appWorkspace.DocumentWorkspaces[cal_Index].GetFriendlyName();
  2452. pNamesList.Add(imgName);
  2453. bitList.Add(bitDic[item.Name][0]);
  2454. bitList.Add(bitDic[item.Name][1]);
  2455. }
  2456. else if (bitDic.ContainsKey(item.Tag.ToString()))
  2457. {
  2458. int cal_Index = int.Parse(item.Tag.ToString().Replace("img", ""));
  2459. string imgName = this.appWorkspace.DocumentWorkspaces[cal_Index].GetFriendlyName();
  2460. pNamesList.Add(imgName);
  2461. bitList.Add(bitDic[item.Tag.ToString()][0]);
  2462. bitList.Add(bitDic[item.Tag.ToString()][1]);
  2463. }
  2464. }
  2465. }
  2466. string dictPath = Application.StartupPath + "\\temp";
  2467. if (!System.IO.Directory.Exists(dictPath))
  2468. {
  2469. System.IO.Directory.CreateDirectory(dictPath);
  2470. }
  2471. DeleteFolder(dictPath);
  2472. pNames = new Dictionary<string, string>();
  2473. int insertIn = 0;
  2474. for (int k = 0; k < bitList.Count; k += 2)
  2475. {//保存处理后的图片
  2476. List<Bitmap> tempBit = new List<Bitmap>();
  2477. tempBit.Add((Bitmap)bitList[k].Clone());
  2478. tempBit.Add((Bitmap)bitList[k + 1].Clone());
  2479. this.SaveAllImage(tempBit, dictPath, insertIn + 1, insertIn + 1, pNamesList[insertIn]);
  2480. insertIn++;
  2481. }
  2482. this.appWorkspace.CreateAnalysisReport(this.analyzeSettingModel, analysisContent, bitList, tagInfos, dictPath, pNames, analysisContent2);
  2483. }
  2484. else
  2485. MessageBox.Show(PdnResources.GetString("Menu.Pleasesettheanalysisreportfirst.text")+"!");
  2486. }
  2487. /// <summary>
  2488. /// 切换辅助线
  2489. /// </summary>
  2490. /// <param name="sender"></param>
  2491. /// <param name="e"></param>
  2492. private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
  2493. {
  2494. comboBox1SelectedItem = comboBox1.SelectedItem;
  2495. if (GSSClass.GuideClass.guideModel != null)
  2496. GSSClass.GuideClass.guideModel.oldSelectItem = (string)this.comboBox1.SelectedItem;
  2497. if (this.comboBox1.DataSource != null && this.comboBox1.SelectedIndex >= 0)
  2498. {
  2499. if (this.bitmap == null)
  2500. {
  2501. int oldSelectIndex = -1;
  2502. for (int i = 0; i < this.comboBox1.Items.Count; i++)
  2503. {
  2504. if (GSSClass.GuideClass.guideModel.oldSelectItem != null && GSSClass.GuideClass.guideModel.oldSelectItem.Equals(this.comboBox1.Items[i]))
  2505. {
  2506. oldSelectIndex = i;
  2507. }
  2508. }
  2509. if (this.comboBox1.SelectedIndex > 0)
  2510. MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectapicture.text")+"!");
  2511. if (oldSelectIndex > -1)
  2512. {
  2513. if (this.comboBox1.SelectedIndex != oldSelectIndex)
  2514. this.comboBox1.SelectedIndex = oldSelectIndex;
  2515. }
  2516. else if (this.comboBox1.Items.Count > 0)
  2517. this.comboBox1.SelectedIndex = 0;
  2518. return;
  2519. }
  2520. UpdateGuideStyle(true && !(this.initScriptValues && this.appWorkspace.ScriptAutomatic));
  2521. if (this.bitmap != null)
  2522. {
  2523. if (this.comboboxChange)
  2524. {
  2525. GSSClass.GuideClass.guideModel.loctation = new PointF(this.documentWorkspace.CompositionSurface.Width / 2, this.documentWorkspace.CompositionSurface.Height / 2);
  2526. }
  2527. InitRectangleF(true);
  2528. this.comboboxChange = true;
  2529. }
  2530. this.documentWorkspace.Refresh();
  2531. }
  2532. }
  2533. /// <summary>
  2534. /// 辅助线设置
  2535. /// </summary>
  2536. /// <param name="sender"></param>
  2537. /// <param name="e"></param>
  2538. private void button9_Click(object sender, EventArgs e)
  2539. {
  2540. if (this.bitmap == null)
  2541. {
  2542. MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectapicture.text")+"!");
  2543. return;
  2544. }
  2545. GSSClass.GuideClass.guideModel.oldSelectItem = (string)this.comboBox1.SelectedItem;
  2546. GrainGuideSettingsDialog grainGuideStyleSettingsDialog = new GrainGuideSettingsDialog(grainMethodType == 1 ? 1 : 0, GSSClass.methodOfAssessment != null ? GSSClass.methodOfAssessment.guideXmlName : getModelName(), getTypeNames(), this.bitmap, this.appWorkspace.DocumentWorkspaces[this.lstView_img.FocusedItem != null ? this.lstView_img.FocusedItem.Index : this.lstView_img.SelectedItems[0].Index
  2547. ].GetRuler(MeasurementUnit.Micron));
  2548. grainGuideStyleSettingsDialog.StartPosition = FormStartPosition.CenterScreen;
  2549. grainGuideStyleSettingsDialog.ShowDialog(this);
  2550. }
  2551. /// <summary>
  2552. /// 返回小数点位数的数值
  2553. /// </summary>
  2554. /// <returns></returns>
  2555. protected int getNumericUpDown1Value()
  2556. {
  2557. return Convert.ToInt32(this.numericUpDown1_0.Value);
  2558. }
  2559. /// <summary>
  2560. /// 刷新晶粒编号/刷新晶粒颜色?//############
  2561. /// </summary>
  2562. /// <param name="pointFs"></param>
  2563. /// <param name="rectangleF"></param>
  2564. /// <returns>返回晶粒个数</returns>
  2565. protected virtual double GetClassNumberOfGrains()
  2566. {
  2567. return 0.0;
  2568. }
  2569. /// <summary>
  2570. /// 颜色点击事件
  2571. /// </summary>
  2572. /// <param name="sender"></param>
  2573. /// <param name="e"></param>
  2574. protected void panel1_1_Click(object sender, EventArgs e)
  2575. {
  2576. this.panelC = (Panel)sender;
  2577. this.colorsFormGrid.UserPrimaryColor = ColorBgra.FromColor(((Panel)sender).BackColor);
  2578. this.colorsFormGrid.ShowDialog();
  2579. }
  2580. /// <summary>
  2581. /// PanelC的调色板颜色改变
  2582. /// </summary>
  2583. /// <param name="sender"></param>
  2584. /// <param name="e"></param>
  2585. private void gridColorChanged(object sender, EventArgs e)
  2586. {
  2587. Color color = this.colorsFormGrid.UserPrimaryColor.ToColor();
  2588. //更改背景色,触发事件
  2589. if (this.panelC != null)
  2590. {
  2591. this.panelC.BackColor = color;
  2592. this.ColorPanelChanged(this.panelC);
  2593. this.panelC = null;
  2594. }
  2595. //关闭色板
  2596. this.colorsFormGrid.Close();
  2597. }
  2598. #region 公共按钮
  2599. private void zoomInButton_Click(object sender, EventArgs e)
  2600. {
  2601. this.documentWorkspace.ZoomIn();
  2602. }
  2603. private void zoomOutButton_Click(object sender, EventArgs e)
  2604. {
  2605. this.documentWorkspace.ZoomOut();
  2606. }
  2607. private void zoomToWindowButton_Click(object sender, EventArgs e)
  2608. {
  2609. this.documentWorkspace.ZoomBasis = ZoomBasis.FitToWindow;
  2610. }
  2611. private void actualSizeButton_Click(object sender, EventArgs e)
  2612. {
  2613. this.documentWorkspace.ZoomBasis = ZoomBasis.ScaleFactor;
  2614. this.documentWorkspace.ScaleFactor = ScaleFactor.OneToOne;
  2615. }
  2616. private void pointerButton_Click(object sender, EventArgs e)
  2617. {
  2618. this.documentWorkspace.ActiveTool = Annotation.Enum.DrawToolType.InclusionNoEffect;
  2619. }
  2620. private void mobileModeButton_Click(object sender, EventArgs e)
  2621. {
  2622. this.documentWorkspace.ActiveTool = Annotation.Enum.DrawToolType.MoveMode;
  2623. }
  2624. #endregion
  2625. #region 辅助线拖动
  2626. /// <summary>
  2627. /// 鼠标按下
  2628. /// </summary>
  2629. /// <param name="drawArea"></param>
  2630. /// <param name="e"></param>
  2631. protected virtual void OnMouseDown(object sender, MouseEventArgs e)
  2632. {
  2633. if (grainMethodType == 1)
  2634. {
  2635. if (this.documentWorkspace.CompositionSurface == null)
  2636. return;
  2637. // 换算后的点
  2638. PointF pointArea = documentWorkspace.GetScalePoint(e.Location);
  2639. //辅助线缩放
  2640. GSSClass.GuideClass.OnMouseDown(pointArea, sender, e);
  2641. //辅助线移动
  2642. if (e.Button == MouseButtons.Left && e.Clicks == 1)
  2643. {
  2644. if (GSSClass.GuideClass.guideModel.RectangleFLine.Contains(pointArea))
  2645. {
  2646. GSSClass.GuideClass.m_canMove = true;
  2647. GSSClass.GuideClass.m_StartPoint = pointArea;
  2648. }
  2649. }
  2650. return;
  2651. }
  2652. // 换算后的点
  2653. PointF point1 = documentWorkspace.GetScalePoint(e.Location);
  2654. if (e.Button == MouseButtons.Left && e.Clicks == 1)
  2655. {
  2656. if (GSSClass.GuideClass.guideModel.RectangleFLine.Contains(point1))
  2657. {
  2658. GSSClass.GuideClass.m_canMove = true;
  2659. GSSClass.GuideClass.m_StartPoint = point1;
  2660. }
  2661. }
  2662. }
  2663. /// <summary>
  2664. /// 移动
  2665. /// </summary>
  2666. /// <param name="sender"></param>
  2667. /// <param name="e"></param>
  2668. protected virtual void onMouseMove(object sender, MouseEventArgs e)
  2669. {
  2670. this.documentWorkspace.Refresh();
  2671. // 换算后的点
  2672. PointF point1 = documentWorkspace.GetScalePoint(e.Location);
  2673. //晶粒度不想让辅助线拖到图像外面
  2674. if (grainMethodType == 0 && this.documentWorkspace.CompositionSurface != null && GSSClass.GuideClass.onMouseMove(point1, this.comboBox1.SelectedItem, e, this.documentWorkspace.CompositionSurface.Width, this.documentWorkspace.CompositionSurface.Height, getCurrentWorkspace().GetRuler(MeasurementUnit.Micron))
  2675. || grainMethodType == 1 && this.documentWorkspace.CompositionSurface != null && GSSClass.GuideClass.onMouseAreaMove(point1, this.comboBox1.SelectedItem, e, this.documentWorkspace.CompositionSurface.Width, this.documentWorkspace.CompositionSurface.Height, getCurrentWorkspace().GetRuler(MeasurementUnit.Micron)))// 矩形缩放
  2676. {//缩放
  2677. GSSClass.GuideClass.guideModel.loctation = new PointF(GSSClass.GuideClass.guideModel.RectangleFLine.X + GSSClass.GuideClass.guideModel.RectangleFLine.Width / 2, GSSClass.GuideClass.guideModel.RectangleFLine.Y + GSSClass.GuideClass.guideModel.RectangleFLine.Height / 2);
  2678. this.AddRectangleToRectangleFCaps();
  2679. this.documentWorkspace.Refresh();
  2680. }
  2681. else if (e.Button == MouseButtons.Left && GSSClass.GuideClass.m_canMove)
  2682. {//移动
  2683. //限制辅助线移动不能拖到图像外面
  2684. PointF m222_StartPoint = new PointF(point1.X, point1.Y);
  2685. double minX = GSSClass.GuideClass.m_StartPoint.X - GSSClass.GuideClass.guideModel.rectangleFLine.X;
  2686. if (point1.X < minX)
  2687. point1.X = (float)minX;
  2688. double maxX = GSSClass.GuideClass.m_StartPoint.X + this.documentWorkspace.CompositionSurface.Width - GSSClass.GuideClass.guideModel.RectangleFLine.Right;
  2689. if (point1.X > maxX)
  2690. point1.X = (float)maxX;
  2691. double minY = GSSClass.GuideClass.m_StartPoint.Y - GSSClass.GuideClass.guideModel.rectangleFLine.Y;
  2692. if (point1.Y < minY)
  2693. point1.Y = (float)minY;
  2694. double maxY = GSSClass.GuideClass.m_StartPoint.Y + this.documentWorkspace.CompositionSurface.Height - GSSClass.GuideClass.guideModel.RectangleFLine.Bottom;
  2695. if (point1.Y > maxY)
  2696. point1.Y = (float)maxY;
  2697. float offsetX = point1.X - GSSClass.GuideClass.m_StartPoint.X;
  2698. float offsetY = point1.Y - GSSClass.GuideClass.m_StartPoint.Y;
  2699. // 矩形偏移
  2700. GSSClass.GuideClass.guideModel.rectangleFLine.Offset(offsetX, offsetY);
  2701. GSSClass.GuideClass.guideModel.loctation = new PointF(GSSClass.GuideClass.guideModel.RectangleFLine.X + GSSClass.GuideClass.guideModel.RectangleFLine.Width / 2, GSSClass.GuideClass.guideModel.RectangleFLine.Y + GSSClass.GuideClass.guideModel.RectangleFLine.Height / 2);
  2702. GSSClass.GuideClass.m_StartPoint = m222_StartPoint;
  2703. if (grainMethodType == 0 && !(!getGrainBoundryChecked() && !getBinaryChecked()))
  2704. //##21247
  2705. this.AddRectangleToRectangleFCaps();
  2706. else if (grainMethodType == 0)
  2707. {
  2708. //##21247
  2709. this.MoveOriginCutOffPoints(offsetX, offsetY);
  2710. }
  2711. this.documentWorkspace.Refresh();
  2712. }
  2713. }
  2714. /// <summary>
  2715. /// 鼠标抬起
  2716. /// </summary>
  2717. /// <param name="sender"></param>
  2718. /// <param name="e"></param>
  2719. protected virtual void onMouseUp(object sender, MouseEventArgs e)
  2720. {
  2721. GSSClass.GuideClass.m_canMove = false;
  2722. GSSClass.GuideClass.onMouseUp(sender, e);
  2723. }
  2724. #endregion
  2725. #endregion
  2726. #region 可调用方法
  2727. /// <summary>
  2728. /// 是否显示原图
  2729. /// </summary>
  2730. /// <returns></returns>
  2731. protected Boolean showOrimat()
  2732. {
  2733. return bcOriginChecked();
  2734. }
  2735. /// <summary>
  2736. /// 获取小数点保留位数的显示字符串
  2737. /// </summary>
  2738. /// <param name="doubleValue"></param>
  2739. /// <returns></returns>
  2740. protected string DecnumString(string doubleValue)
  2741. {
  2742. double outValue;
  2743. if (double.TryParse(string.IsNullOrEmpty(doubleValue) ? "0" : doubleValue, out outValue))
  2744. {
  2745. return Math.Round(outValue, Convert.ToInt32(this.numericUpDown1_0.Value)) + "";
  2746. }
  2747. else
  2748. return doubleValue;
  2749. }
  2750. /// <summary>
  2751. /// 设置晶粒颜色
  2752. /// </summary>
  2753. protected void ShowGrainColorSettingDialog()
  2754. {
  2755. GrainColorSetting colorSettings = new GrainColorSetting(/*isAreaType ? 1 : 0, getModelName(), getTypeNames(), this.bitmap*/);
  2756. colorSettings.StartPosition = FormStartPosition.CenterScreen;
  2757. //colorSettings.ShowDialog(this)
  2758. if (colorSettings.ShowDialog() == DialogResult.OK)
  2759. {
  2760. //获取设置颜色的集合,按照等级从小到大排序
  2761. List<OpenCvSharp.Vec4b> colorOfGrades = colorSettings.getColorOfGrades();
  2762. GSSClass.setColorOfGrades.Clear();
  2763. GSSClass.setColorOfGrades.AddRange(colorOfGrades);
  2764. setMat2ColorOfLabelMat(-1);
  2765. };
  2766. }
  2767. /// <summary>
  2768. /// 设置截点样式
  2769. /// </summary>
  2770. protected void ShowGrainSurveyPointStyleSettingDialog()
  2771. {
  2772. GrainSurveyPointStyleSettingDialog grainSurveyPointStyleSettingDialog = new GrainSurveyPointStyleSettingDialog();//###
  2773. grainSurveyPointStyleSettingDialog.StartPosition = FormStartPosition.CenterScreen;
  2774. grainSurveyPointStyleSettingDialog.ShowDialog(this);
  2775. }
  2776. /// <summary>
  2777. /// 根据等级设置晶粒颜色
  2778. /// </summary>
  2779. /// <param name="nccomps">连通域数量</param>
  2780. private void setMat2ColorOfLabelMat(int nccomps)
  2781. {
  2782. Mat temp = GSSClass.getMat2ColorOfLabelMat(GSSClass.standardModel, nccomps, getCurrentWorkspace().GetRuler(MeasurementUnit.Micron));
  2783. if (temp != null)
  2784. {
  2785. if (grainMethodType == 1)
  2786. {
  2787. if (this.grainColorsMatDict.ContainsKey(getCurrentWorkTag()))
  2788. this.grainColorsMatDict[getCurrentWorkTag()] = temp.Clone();
  2789. else
  2790. this.grainColorsMatDict.Add(getCurrentWorkTag(), temp.Clone());
  2791. }
  2792. this.documentWorkspace.PhaseModels[2].mat = temp;
  2793. this.documentWorkspace.Refresh();
  2794. }
  2795. }
  2796. /// <summary>
  2797. /// 更新截点样式
  2798. /// </summary>
  2799. public void UpdateCupOffPointStyle()
  2800. {
  2801. GSSClass.styleClass.styleModel.UpdateCupOffPointStyle();
  2802. AddRectangleToRectangleFCaps();
  2803. }
  2804. /// <summary>
  2805. /// 刷新分析结果数据
  2806. /// </summary>
  2807. protected virtual void RefreshDataGridView4()
  2808. {
  2809. if (!this.allShow)
  2810. {
  2811. if (this.listView2.SelectedItems.Count > 0)
  2812. {
  2813. List<List<double>> valueList = new List<List<double>>();
  2814. double value_1 = 0;//面积法(汇总面积)、截点法(截点总数)
  2815. double small_l = 0;//面积法(汇总截距)、截点法(网格总长度)
  2816. this.dataGridView2.Rows.Clear();
  2817. for (int j = 0; j < this.listView2.SelectedItems.Count; j++)
  2818. {
  2819. for (int dataTableIndex = 0; dataTableIndex < this.dataTables.Count; dataTableIndex++)
  2820. {
  2821. if (this.dataTables[dataTableIndex].TableName.Equals(this.listView2.SelectedItems[j].Tag))
  2822. {
  2823. for (int r = 0; r < this.dataTables[dataTableIndex].Rows.Count; r++)
  2824. {
  2825. DataGridViewRow dgvr = new DataGridViewRow();
  2826. foreach (DataGridViewColumn Column in this.dataGridView2.Columns)
  2827. {
  2828. dgvr.Cells.Add(Column.CellTemplate.Clone() as DataGridViewCell);
  2829. }
  2830. List<double> valueL = new List<double>();
  2831. for (int c = 0; c < this.dataTables[dataTableIndex].Columns.Count; c++)
  2832. {
  2833. double outValue;
  2834. if (double.TryParse(string.IsNullOrEmpty(this.dataTables[dataTableIndex].Rows[r][c].ToString()) ? "0" :
  2835. this.dataTables[dataTableIndex].Rows[r][c].ToString(), out outValue) && !DetailListStringIndex.Contains(c))
  2836. {
  2837. dgvr.Cells[c].Value = Math.Round(outValue, Convert.ToInt32(this.numericUpDown1_0.Value)) + "";
  2838. }
  2839. else
  2840. dgvr.Cells[c].Value = this.dataTables[dataTableIndex].Rows[r][c].ToString();
  2841. if (IndexChangedFromIndex.Count > 0)
  2842. {
  2843. if (IndexChangedFromIndex.Contains(c))
  2844. valueL.Add(double.Parse(this.dataTables[dataTableIndex].Rows[r][c].ToString()));
  2845. continue;
  2846. }
  2847. if (c == 3/*isAreaType && c == 3 || !isAreaType && c == 3*/)
  2848. value_1 += outValue;
  2849. if (grainMethodType == 1 && c == 4 || grainMethodType == 0 && c == 2)
  2850. small_l += outValue;
  2851. }
  2852. if (IndexChangedFromIndex.Count > 0)
  2853. valueList.Add(valueL);
  2854. this.dataGridView2.Rows.Add(dgvr);
  2855. }
  2856. }
  2857. }
  2858. }
  2859. this.dataGridView_Total.Rows.Clear();
  2860. value_111 = -1;
  2861. if (IndexChangedFromIndex.Count > 0 && IndexChangedToIndex.Count > 0 && valueList.Count > 0)
  2862. {
  2863. DataGridViewRow dgvr = new DataGridViewRow();
  2864. foreach (DataGridViewColumn Column in this.dataGridView_Total.Columns)
  2865. {
  2866. dgvr.Cells.Add(Column.CellTemplate.Clone() as DataGridViewCell);
  2867. }
  2868. foreach (int itemkey in IndexChangedToIndex.Keys)
  2869. {
  2870. int[] itemValue = IndexChangedToIndex[itemkey];
  2871. List<double> valueL = new List<double>();//级别时会多算一遍,应该不影响什么
  2872. if (itemValue[1] >= 0)
  2873. foreach (List<double> itemL in valueList)
  2874. {
  2875. valueL.Add(itemL[itemValue[1]]);
  2876. }
  2877. if (itemValue[0] == 1)//求和
  2878. dgvr.Cells[itemkey].Value = "" + Math.Round(valueL.Sum(), Convert.ToInt32(this.numericUpDown1_0.Value));
  2879. else if (itemValue[0] == 2)//平均
  2880. dgvr.Cells[itemkey].Value = "" + Math.Round(valueL.Average(), Convert.ToInt32(this.numericUpDown1_0.Value));
  2881. else if (itemValue[0] == 3)//级别
  2882. if (itemValue[1] < 0)
  2883. {
  2884. dgvr.Cells[itemkey].Value = getGradeTotalCal(dgvr, Convert.ToInt32(this.numericUpDown1_0.Value));
  2885. }
  2886. else
  2887. dgvr.Cells[itemkey].Value = getGradeValue(double.Parse(dgvr.Cells[itemValue[1]].Value.ToString()));
  2888. }
  2889. this.dataGridView_Total.Rows.Add(dgvr);
  2890. return;
  2891. }
  2892. double grainNumber = 0;
  2893. if (getGbtType() == 3)
  2894. value_1 = 0;
  2895. for (int j = 0; j < this.listView2.SelectedItems.Count; j++)
  2896. {
  2897. int dataTableIndex = 0;
  2898. for (int i = 0; i < this.dataTable_Totals.Count; i++)
  2899. {
  2900. if (this.dataTable_Totals[i].TableName.Equals(this.listView2.SelectedItems[j].Tag))
  2901. dataTableIndex = i;
  2902. }
  2903. if (this.dataTable_Totals.Count > dataTableIndex && this.dataTable_Totals[dataTableIndex].Rows.Count > 0)
  2904. {
  2905. for (int r = 0; r < this.dataTable_Totals[dataTableIndex].Rows.Count; r++)
  2906. {
  2907. grainNumber += double.Parse(this.dataTable_Totals[dataTableIndex].Rows[r][grainMethodType == 1 ? 0 : 1].ToString());
  2908. }
  2909. }
  2910. if (this.dict_Totals.ContainsKey(this.listView2.SelectedItems[j].Tag.ToString()))
  2911. {
  2912. Dictionary<string, object> valuePairs = this.dict_Totals[this.listView2.SelectedItems[j].Tag.ToString()];
  2913. if (valuePairs.ContainsKey("RectArea"))
  2914. value_1 += (double)valuePairs["RectArea"];
  2915. }
  2916. }
  2917. {
  2918. DataGridViewRow dgvr = new DataGridViewRow();
  2919. foreach (DataGridViewColumn Column in this.dataGridView_Total.Columns)
  2920. {
  2921. dgvr.Cells.Add(Column.CellTemplate.Clone() as DataGridViewCell);
  2922. }
  2923. dgvr.Cells[0].Value = "" + Math.Round(grainMethodType == 1 ? grainNumber : small_l, Convert.ToInt32(this.numericUpDown1_0.Value));
  2924. if (getGbtType() == 3)
  2925. {
  2926. if (grainNumber > 0)
  2927. value_1 = value_1 / grainNumber;
  2928. value_1 = value_1 * 0.001 * 0.001;
  2929. dgvr.Cells[1].Value = "" + Math.Round(3.321928 * Math.Log10(1.0 / value_1) - 2.954, Convert.ToInt32(this.numericUpDown1_0.Value));
  2930. }
  2931. else
  2932. {
  2933. dgvr.Cells[1].Value = "" + Math.Round(grainMethodType == 1 ? small_l : value_1, Convert.ToInt32(this.numericUpDown1_0.Value));
  2934. if (grainMethodType == 1 && grainNumber > 0)
  2935. small_l = small_l / grainNumber;
  2936. else if (grainMethodType == 0 && value_1 > 0)
  2937. small_l = small_l / value_1;
  2938. dgvr.Cells[2].Value = "" + Math.Round(small_l, Convert.ToInt32(this.numericUpDown1_0.Value));
  2939. if (getGbtType() == 4)
  2940. dgvr.Cells[3].Value = "" + Math.Round(-6.6439 * Math.Log10(small_l * 0.001) - 3.2877, Convert.ToInt32(this.numericUpDown1_0.Value));
  2941. else
  2942. dgvr.Cells[3].Value = "" + Math.Round(-6.643856 * Math.Log10(small_l * 0.001) - 3.288, Convert.ToInt32(this.numericUpDown1_0.Value));
  2943. value_111 = Math.Max(1, Math.Min(15, 15 - double.Parse(dgvr.Cells[3].Value.ToString()))) * 9;
  2944. if (RegularTetrahedron3D.GetStatus() > 0 && value_111 > 1)
  2945. {
  2946. RegularTetrahedron3D.UpdateRun(Math.Min(value_111, 200));
  2947. //return;
  2948. }
  2949. if (grainMethodType == 1)
  2950. {
  2951. if (dgvr.Cells.Count > 4)
  2952. {
  2953. if (grainNumber > 0)
  2954. value_1 = value_1 / grainNumber;
  2955. dgvr.Cells[4].Value = "" + Math.Round(value_1, Convert.ToInt32(this.numericUpDown1_0.Value));
  2956. value_1 = value_1 * 0.001 * 0.001;
  2957. }
  2958. if (dgvr.Cells.Count > 5)
  2959. {
  2960. if (getGbtType() == 4)
  2961. dgvr.Cells[5].Value = "" + Math.Round(3.32 * Math.Log10(1.0 / value_1) - 2.9542, Convert.ToInt32(this.numericUpDown1_0.Value));
  2962. else
  2963. dgvr.Cells[5].Value = "" + Math.Round(3.321928 * Math.Log10(1.0 / value_1) - 2.954, Convert.ToInt32(this.numericUpDown1_0.Value));
  2964. }
  2965. }
  2966. }
  2967. this.dataGridView_Total.Rows.Add(dgvr);
  2968. }
  2969. }
  2970. else if (this.listView2.Items.Count > 0)
  2971. {
  2972. var firstTag = this.listView2.Items[0].Tag;
  2973. List<List<double>> valueList = new List<List<double>>();
  2974. double value_1 = 0;
  2975. double small_l = 0;
  2976. this.dataGridView2.Rows.Clear();
  2977. for (int dataTableIndex = 0; dataTableIndex < this.dataTables.Count; dataTableIndex++)
  2978. {
  2979. if (this.dataTables[dataTableIndex].TableName.Equals(firstTag))
  2980. {
  2981. for (int r = 0; r < this.dataTables[dataTableIndex].Rows.Count; r++)
  2982. {
  2983. DataGridViewRow dgvr = new DataGridViewRow();
  2984. foreach (DataGridViewColumn Column in this.dataGridView2.Columns)
  2985. {
  2986. dgvr.Cells.Add(Column.CellTemplate.Clone() as DataGridViewCell);
  2987. }
  2988. List<double> valueL = new List<double>();
  2989. for (int c = 0; c < this.dataTables[dataTableIndex].Columns.Count; c++)
  2990. {
  2991. double outValue;
  2992. if (double.TryParse(string.IsNullOrEmpty(this.dataTables[dataTableIndex].Rows[r][c].ToString()) ? "0" :
  2993. this.dataTables[dataTableIndex].Rows[r][c].ToString(), out outValue) && !DetailListStringIndex.Contains(c))
  2994. {
  2995. dgvr.Cells[c].Value = Math.Round(outValue, Convert.ToInt32(this.numericUpDown1_0.Value)) + "";
  2996. }
  2997. else
  2998. dgvr.Cells[c].Value = this.dataTables[dataTableIndex].Rows[r][c].ToString();
  2999. if (IndexChangedFromIndex.Count > 0)
  3000. {
  3001. if (IndexChangedFromIndex.Contains(c))
  3002. valueL.Add(double.Parse(this.dataTables[dataTableIndex].Rows[r][c].ToString()));
  3003. continue;
  3004. }
  3005. if (c == 3)
  3006. value_1 += outValue;
  3007. if (grainMethodType == 1 && c == 4 || grainMethodType == 0 && c == 2)
  3008. small_l += outValue;
  3009. }
  3010. if (IndexChangedFromIndex.Count > 0)
  3011. valueList.Add(valueL);
  3012. this.dataGridView2.Rows.Add(dgvr);
  3013. }
  3014. }
  3015. }
  3016. this.dataGridView_Total.Rows.Clear();
  3017. value_111 = -1;
  3018. if (IndexChangedFromIndex.Count > 0 && IndexChangedToIndex.Count > 0 && valueList.Count > 0)
  3019. {
  3020. DataGridViewRow dgvr = new DataGridViewRow();
  3021. foreach (DataGridViewColumn Column in this.dataGridView_Total.Columns)
  3022. {
  3023. dgvr.Cells.Add(Column.CellTemplate.Clone() as DataGridViewCell);
  3024. }
  3025. foreach (int itemkey in IndexChangedToIndex.Keys)
  3026. {
  3027. int[] itemValue = IndexChangedToIndex[itemkey];
  3028. List<double> valueL = new List<double>();//级别时会多算一遍,应该不影响什么
  3029. if (itemValue[1] >= 0)
  3030. foreach (List<double> itemL in valueList)
  3031. {
  3032. valueL.Add(itemL[itemValue[1]]);
  3033. }
  3034. if (itemValue[0] == 1)//求和
  3035. dgvr.Cells[itemkey].Value = "" + Math.Round(valueL.Sum(), Convert.ToInt32(this.numericUpDown1_0.Value));
  3036. else if (itemValue[0] == 2)//平均
  3037. dgvr.Cells[itemkey].Value = "" + Math.Round(valueL.Average(), Convert.ToInt32(this.numericUpDown1_0.Value));
  3038. else if (itemValue[0] == 3)//级别
  3039. {
  3040. if (itemValue[1] < 0)
  3041. {
  3042. dgvr.Cells[itemkey].Value = getGradeTotalCal(dgvr, Convert.ToInt32(this.numericUpDown1_0.Value));
  3043. }
  3044. else
  3045. dgvr.Cells[itemkey].Value = getGradeValue(double.Parse(dgvr.Cells[itemValue[1]].Value.ToString()));
  3046. }
  3047. }
  3048. this.dataGridView_Total.Rows.Add(dgvr);
  3049. return;
  3050. ////##
  3051. //this.RefreshDataGridView4();
  3052. }
  3053. double grainNumber = 0;
  3054. //for (int j = 0; j < this.listView2.SelectedItems.Count; j++)
  3055. {
  3056. int dataTableIndex = 0;
  3057. for (int i = 0; i < this.dataTable_Totals.Count; i++)
  3058. {
  3059. if (this.dataTable_Totals[i].TableName.Equals(firstTag/*this.listView2.SelectedItems[j].Tag*/))
  3060. dataTableIndex = i;
  3061. }
  3062. if (this.dataTable_Totals.Count > dataTableIndex && this.dataTable_Totals[dataTableIndex].Rows.Count > 0)
  3063. {
  3064. for (int r = 0; r < this.dataTable_Totals[dataTableIndex].Rows.Count; r++)
  3065. {
  3066. grainNumber += double.Parse(this.dataTable_Totals[dataTableIndex].Rows[r][grainMethodType == 1 ? 0 : 1].ToString());
  3067. }
  3068. }
  3069. }
  3070. {
  3071. DataGridViewRow dgvr = new DataGridViewRow();
  3072. foreach (DataGridViewColumn Column in this.dataGridView_Total.Columns)
  3073. {
  3074. dgvr.Cells.Add(Column.CellTemplate.Clone() as DataGridViewCell);
  3075. }
  3076. dgvr.Cells[0].Value = "" + Math.Round(grainMethodType == 1 ? grainNumber : small_l, Convert.ToInt32(this.numericUpDown1_0.Value));
  3077. if (getGbtType() == 3)
  3078. {
  3079. if (this.dict_Totals.ContainsKey(firstTag.ToString()))
  3080. {
  3081. Dictionary<string, object> valuePairs = this.dict_Totals[firstTag.ToString()];
  3082. if (valuePairs.ContainsKey("RectArea"))
  3083. value_1 = (double)valuePairs["RectArea"];
  3084. }
  3085. if (grainNumber > 0)
  3086. value_1 = value_1 / grainNumber;
  3087. value_1 = value_1 * 0.001 * 0.001;
  3088. dgvr.Cells[1].Value = "" + Math.Round(3.321928 * Math.Log10(1.0 / value_1) - 2.954, Convert.ToInt32(this.numericUpDown1_0.Value));
  3089. }
  3090. else
  3091. {
  3092. dgvr.Cells[1].Value = "" + Math.Round(grainMethodType == 1 ? small_l : value_1, Convert.ToInt32(this.numericUpDown1_0.Value));
  3093. if (grainMethodType == 1 && grainNumber > 0)
  3094. small_l = small_l / grainNumber;
  3095. else if (grainMethodType == 0 && value_1 > 0)
  3096. small_l = small_l / value_1;
  3097. //value_111 = small_l;
  3098. dgvr.Cells[2].Value = "" + Math.Round(small_l, Convert.ToInt32(this.numericUpDown1_0.Value));
  3099. if (getGbtType() == 4)
  3100. dgvr.Cells[3].Value = "" + Math.Round(-6.6439 * Math.Log10(small_l * 0.001) - 3.2877, Convert.ToInt32(this.numericUpDown1_0.Value));
  3101. else
  3102. dgvr.Cells[3].Value = "" + Math.Round(-6.643856 * Math.Log10(small_l * 0.001) - 3.288, Convert.ToInt32(this.numericUpDown1_0.Value));
  3103. value_111 = Math.Max(1, Math.Min(15, 15 - double.Parse(dgvr.Cells[3].Value.ToString()))) * 9;
  3104. if (RegularTetrahedron3D.GetStatus() > 0 && value_111 > 1)
  3105. {
  3106. RegularTetrahedron3D.UpdateRun(Math.Min(value_111, 200));
  3107. //return;
  3108. }
  3109. if (grainMethodType == 1)
  3110. {
  3111. if (dgvr.Cells.Count > 4)
  3112. {
  3113. if (grainNumber > 0)
  3114. value_1 = value_1 / grainNumber;
  3115. dgvr.Cells[4].Value = "" + Math.Round(value_1, Convert.ToInt32(this.numericUpDown1_0.Value));
  3116. value_1 = value_1 * 0.001 * 0.001;
  3117. }
  3118. if (dgvr.Cells.Count > 5)
  3119. {
  3120. if (getGbtType() == 4)
  3121. dgvr.Cells[5].Value = "" + Math.Round(3.32 * Math.Log10(1.0 / value_1) - 2.9542, Convert.ToInt32(this.numericUpDown1_0.Value));
  3122. else
  3123. dgvr.Cells[5].Value = "" + Math.Round(3.321928 * Math.Log10(1.0 / value_1) - 2.954, Convert.ToInt32(this.numericUpDown1_0.Value));
  3124. }
  3125. }
  3126. }
  3127. this.dataGridView_Total.Rows.Add(dgvr);
  3128. }
  3129. }
  3130. }
  3131. else
  3132. {
  3133. System.Data.DataTable dataTable;
  3134. List<List<double>> valueList = new List<List<double>>();
  3135. double value_1 = 0;
  3136. double small_l = 0;
  3137. this.dataGridView2.Rows.Clear();
  3138. for (int i = this.dataTables.Count - 1; i >= 0; i--)
  3139. {
  3140. dataTable = this.dataTables[i];
  3141. for (int r = 0; r < dataTable.Rows.Count; r++)
  3142. {
  3143. DataGridViewRow dgvr = new DataGridViewRow();
  3144. foreach (DataGridViewColumn Column in this.dataGridView2.Columns)
  3145. {
  3146. dgvr.Cells.Add(Column.CellTemplate.Clone() as DataGridViewCell);
  3147. }
  3148. List<double> valueL = new List<double>();
  3149. for (int c = 0; c < dataTable.Columns.Count; c++)
  3150. {
  3151. double outValue;
  3152. if (double.TryParse(string.IsNullOrEmpty(dataTable.Rows[r][c].ToString()) ? "0" :
  3153. dataTable.Rows[r][c].ToString(), out outValue) && !DetailListStringIndex.Contains(c))
  3154. {
  3155. dgvr.Cells[c].Value = Math.Round(outValue, Convert.ToInt32(this.numericUpDown1_0.Value)) + "";
  3156. }
  3157. else
  3158. dgvr.Cells[c].Value = dataTable.Rows[r][c].ToString();
  3159. if (IndexChangedFromIndex.Count > 0)
  3160. {
  3161. if (IndexChangedFromIndex.Contains(c))
  3162. valueL.Add(double.Parse(dataTable.Rows[r][c].ToString()));
  3163. continue;
  3164. }
  3165. if (c == 3)
  3166. value_1 += outValue;
  3167. if (grainMethodType == 1 && c == 4 || grainMethodType == 0 && c == 2)
  3168. small_l += outValue;
  3169. }
  3170. if (IndexChangedFromIndex.Count > 0)
  3171. valueList.Add(valueL);
  3172. this.dataGridView2.Rows.Add(dgvr);
  3173. }
  3174. }
  3175. this.dataGridView_Total.Rows.Clear();
  3176. if (IndexChangedFromIndex.Count > 0 && IndexChangedToIndex.Count > 0 && valueList.Count > 0)
  3177. {
  3178. DataGridViewRow dgvr = new DataGridViewRow();
  3179. foreach (DataGridViewColumn Column in this.dataGridView_Total.Columns)
  3180. {
  3181. dgvr.Cells.Add(Column.CellTemplate.Clone() as DataGridViewCell);
  3182. }
  3183. foreach (int itemkey in IndexChangedToIndex.Keys)
  3184. {
  3185. int[] itemValue = IndexChangedToIndex[itemkey];
  3186. List<double> valueL = new List<double>();//级别时会多算一遍,应该不影响什么
  3187. if (itemValue[1] >= 0)
  3188. foreach (List<double> itemL in valueList)
  3189. {
  3190. valueL.Add(itemL[itemValue[1]]);
  3191. }
  3192. if (itemValue[0] == 1)//求和
  3193. dgvr.Cells[itemkey].Value = "" + Math.Round(valueL.Sum(), Convert.ToInt32(this.numericUpDown1_0.Value));
  3194. else if (itemValue[0] == 2)//平均
  3195. dgvr.Cells[itemkey].Value = "" + Math.Round(valueL.Average(), Convert.ToInt32(this.numericUpDown1_0.Value));
  3196. else if (itemValue[0] == 3)//级别
  3197. if (itemValue[1] < 0)
  3198. {
  3199. dgvr.Cells[itemkey].Value = getGradeTotalCal(dgvr, Convert.ToInt32(this.numericUpDown1_0.Value));
  3200. }
  3201. else
  3202. dgvr.Cells[itemkey].Value = getGradeValue(double.Parse(dgvr.Cells[itemValue[1]].Value.ToString()));
  3203. }
  3204. this.dataGridView_Total.Rows.Add(dgvr);
  3205. return;
  3206. ////##
  3207. //this.RefreshDataGridView4();
  3208. }
  3209. double grainNumber = 0;
  3210. if (getGbtType() == 3)
  3211. value_1 = 0;
  3212. for (int j = 0; j < this.listView2.Items.Count; j++)
  3213. {
  3214. int dataTableIndex = 0;
  3215. for (int i = 0; i < this.dataTable_Totals.Count; i++)
  3216. {
  3217. if (this.dataTable_Totals[i].TableName.Equals(this.listView2.Items[j].Tag))
  3218. dataTableIndex = i;
  3219. }
  3220. if (this.dataTable_Totals.Count > dataTableIndex && this.dataTable_Totals[dataTableIndex].Rows.Count > 0)
  3221. {
  3222. for (int r = 0; r < this.dataTable_Totals[dataTableIndex].Rows.Count; r++)
  3223. {
  3224. grainNumber += double.Parse(this.dataTable_Totals[dataTableIndex].Rows[r][grainMethodType == 1 ? 0 : 1].ToString());
  3225. }
  3226. }
  3227. if (this.dict_Totals.ContainsKey(this.listView2.Items[j].Tag.ToString()))
  3228. {
  3229. Dictionary<string, object> valuePairs = this.dict_Totals[this.listView2.Items[j].Tag.ToString()];
  3230. if (valuePairs.ContainsKey("RectArea"))
  3231. value_1 += (double)valuePairs["RectArea"];
  3232. }
  3233. }
  3234. {
  3235. DataGridViewRow dgvr = new DataGridViewRow();
  3236. foreach (DataGridViewColumn Column in this.dataGridView_Total.Columns)
  3237. {
  3238. dgvr.Cells.Add(Column.CellTemplate.Clone() as DataGridViewCell);
  3239. }
  3240. dgvr.Cells[0].Value = "" + Math.Round(grainMethodType == 1 ? grainNumber : small_l, Convert.ToInt32(this.numericUpDown1_0.Value));
  3241. if (getGbtType() == 3)
  3242. {
  3243. if (grainNumber > 0)
  3244. value_1 = value_1 / grainNumber;
  3245. value_1 = value_1 * 0.001 * 0.001;
  3246. dgvr.Cells[1].Value = "" + Math.Round(3.321928 * Math.Log10(1.0 / value_1) - 2.954, Convert.ToInt32(this.numericUpDown1_0.Value));
  3247. }
  3248. else
  3249. {
  3250. dgvr.Cells[1].Value = "" + Math.Round(grainMethodType == 1 ? small_l : value_1, Convert.ToInt32(this.numericUpDown1_0.Value));
  3251. if (grainMethodType == 1 && grainNumber > 0)
  3252. small_l = small_l / grainNumber;
  3253. else if (grainMethodType == 0 && value_1 > 0)
  3254. small_l = small_l / value_1;
  3255. dgvr.Cells[2].Value = "" + Math.Round(small_l, Convert.ToInt32(this.numericUpDown1_0.Value));
  3256. if (getGbtType() == 4)
  3257. dgvr.Cells[3].Value = "" + Math.Round(-6.6439 * Math.Log10(small_l * 0.001) - 3.2877, Convert.ToInt32(this.numericUpDown1_0.Value));
  3258. else
  3259. dgvr.Cells[3].Value = "" + Math.Round(-6.643856 * Math.Log10(small_l * 0.001) - 3.288, Convert.ToInt32(this.numericUpDown1_0.Value));
  3260. if (grainMethodType == 1)
  3261. {
  3262. if (grainNumber > 0)
  3263. value_1 = value_1 / grainNumber;
  3264. dgvr.Cells[4].Value = "" + Math.Round(value_1, Convert.ToInt32(this.numericUpDown1_0.Value));
  3265. value_1 = value_1 * 0.001 * 0.001;
  3266. if (getGbtType() == 4)
  3267. dgvr.Cells[5].Value = "" + Math.Round(3.32 * Math.Log10(1.0 / value_1) - 2.9542, Convert.ToInt32(this.numericUpDown1_0.Value));
  3268. else
  3269. dgvr.Cells[5].Value = "" + Math.Round(3.321928 * Math.Log10(1.0 / value_1) - 2.954, Convert.ToInt32(this.numericUpDown1_0.Value));
  3270. }
  3271. }
  3272. this.dataGridView_Total.Rows.Add(dgvr);
  3273. }
  3274. }
  3275. }
  3276. /// <summary>
  3277. /// 是否能取到二值的结果
  3278. /// </summary>
  3279. /// <returns></returns>
  3280. protected Boolean getBinaryChecked()
  3281. {
  3282. return (bcBinaryChecked() && this.documentWorkspace.PhaseModels[0].mat != null);
  3283. }
  3284. /// <summary>
  3285. /// 是否能取到晶界重现的结果
  3286. /// </summary>
  3287. /// <returns></returns>
  3288. protected Boolean getGrainBoundryChecked()
  3289. {
  3290. if (this.documentWorkspace.PhaseModels.Count > 0)
  3291. {
  3292. return (/*this.checkBox1.Checked && */this.documentWorkspace.PhaseModels[1].mat != null);
  3293. }
  3294. return false;
  3295. }
  3296. //public void SetItemOrdinal(int itemOrdinal)
  3297. //{
  3298. // if (this.progressDialog.InvokeRequired)
  3299. // {
  3300. // this.progressDialog.BeginInvoke(new Procedure<int>(SetItemOrdinal), new object[] { itemOrdinal });
  3301. // }
  3302. // else
  3303. // {
  3304. // this.itemOrdinal = itemOrdinal;
  3305. // this.totalWork = 0;
  3306. // this.totalProgress = 0;
  3307. // UpdateUI();
  3308. // }
  3309. //}
  3310. protected object comboBox1SelectedItem = null;
  3311. /// <summary>
  3312. /// 返回当前选择的辅助线名称
  3313. /// </summary>
  3314. /// <returns></returns>
  3315. protected string getCurrentGuideName()
  3316. {
  3317. return comboBox1SelectedItem/*this.comboBox1.SelectedItem*/ != null ? comboBox1SelectedItem/*this.comboBox1.SelectedItem*/.ToString() : "";
  3318. }
  3319. /// <summary>
  3320. /// 返回当前选择的图片内容
  3321. /// </summary>
  3322. /// <returns></returns>
  3323. protected DocumentWorkspace getCurrentWorkspace()
  3324. {
  3325. if (this.lstView_img.FocusedItem == null && this.lstView_img.SelectedItems.Count == 0)
  3326. return null;
  3327. return this.appWorkspace.DocumentWorkspaces[this.lstView_img.FocusedItem != null ? this.lstView_img.FocusedItem.Index : this.lstView_img.SelectedItems[0].Index];
  3328. }
  3329. /// <summary>
  3330. /// 返回当前选择的图片tag
  3331. /// </summary>
  3332. /// <returns></returns>
  3333. protected string getCurrentWorkTag()
  3334. {
  3335. return this.imageList_img.Images.Keys[this.lstView_img.FocusedItem != null ? this.lstView_img.FocusedItem.Index : this.lstView_img.SelectedItems[0].Index];
  3336. }
  3337. /// <summary>
  3338. /// 获取面积法显示编号的颜色
  3339. /// </summary>
  3340. /// <returns></returns>
  3341. protected Color getGrainBoundryColor()
  3342. {
  3343. return Color.Red;//#########################1 this.documentWorkspace.PhaseModels[1].color;// this.panel1.BackColor;
  3344. }
  3345. private double cal_gNum = 0;
  3346. private Mat cal_temp = null;
  3347. GrainSizeStandardModel cal1_StandardModel;
  3348. GrainSizeGuideModel cal1_GuideModel;
  3349. Mat cal1_Picture;
  3350. Mat cal_analyzeMat;
  3351. bool cal_BinaryChecked;
  3352. string cal1_Tag;
  3353. int cal1_Index;
  3354. bool cal1_RectFlag = false;
  3355. ProgressThreadProcClass procClass;
  3356. /// <summary>
  3357. /// 刷新晶粒编号
  3358. /// </summary>
  3359. /// <returns>返回晶粒个数</returns>
  3360. protected double GetNumberOfGrains(GrainSizeStandardModel cal_StandardModel = null, GrainSizeGuideModel cal_GuideModel = null,
  3361. string cal_Tag = null, int cal_Index = -1, bool isRectFlag = false)
  3362. {
  3363. bool isCurrentTag = false;
  3364. if (cal_StandardModel == null)
  3365. cal_StandardModel = GSSClass.standardModel;
  3366. if (cal_GuideModel == null)
  3367. cal_GuideModel = GSSClass.GuideClass.guideModel;
  3368. if (cal_Tag == null || cal_Tag.Equals(getCurrentWorkTag()))
  3369. {
  3370. isCurrentTag = true;
  3371. cal_Tag = getCurrentWorkTag();
  3372. }
  3373. if (cal_Index == -1)
  3374. cal_Index = this.selectPicture;
  3375. if (cal_StandardModel.linePointList.Count <= 0)
  3376. return 0.0;//should never go here !
  3377. Mat cal_Picture;
  3378. Mat analyzeMat = new Mat();
  3379. //######################
  3380. Bitmap cal_Bitmap = this.bitmap;
  3381. if (cal_Tag != null && cal_Index >= 0 && cal_Index < this.appWorkspace.DocumentWorkspaces.Length)
  3382. cal_Bitmap = this.appWorkspace.DocumentWorkspaces[cal_Index].CompositionSurface.CreateAliasedBitmap();
  3383. bool BinaryChecked;
  3384. if (cal_Tag != null && !isCurrentTag)
  3385. BinaryChecked = (binaryClass.getModelMat(cal_Tag) != null);
  3386. else
  3387. BinaryChecked = getBinaryChecked();
  3388. if (getGrainBoundryChecked())
  3389. {//######################
  3390. cal_Picture = new Mat(/*cal_*/matOrg.Size(), MatType.CV_8UC4, new Scalar(255, 255, 255, 255));
  3391. Mat /*cal_*/oldMat = this.documentWorkspace.PhaseModels[1].mat;
  3392. int Rows = oldMat.Rows;
  3393. int Cols = oldMat.Cols;
  3394. int[] point = new int[2];
  3395. //多通道图像的格式化
  3396. for (point[0] = 0; point[0] < Rows; point[0]++)
  3397. {
  3398. for (point[1] = 0; point[1] < Cols; point[1]++)
  3399. {
  3400. if (oldMat.At<Vec4b>(point[0], point[1]).Item3 > 0)
  3401. {
  3402. cal_Picture.Set<Vec4b>(point, new Vec4b(0, 0, 0, 255));
  3403. }
  3404. }
  3405. }
  3406. Cv2.Erode(cal_Picture, cal_Picture, null, null, 1);
  3407. /*cal_*/oldMat.CopyTo(analyzeMat);
  3408. }
  3409. else if (BinaryChecked)
  3410. {
  3411. Mat cal_Mat = (cal_Tag != null && !isCurrentTag) ? binaryClass.getModelMat(cal_Tag) : this.PhaseModel0Mat;
  3412. cal_Picture = new Mat(cal_Mat.Size(), MatType.CV_8UC4, new Scalar(255, 255, 255, 255));
  3413. int Rows = cal_Mat.Rows;
  3414. int Cols = cal_Mat.Cols;
  3415. int[] point = new int[2];
  3416. //多通道图像的格式化
  3417. for (point[0] = 0; point[0] < Rows; point[0]++)
  3418. {
  3419. for (point[1] = 0; point[1] < Cols; point[1]++)
  3420. {
  3421. if (cal_Mat.At<Vec4b>(point[0], point[1]).Item3 > 0)
  3422. {
  3423. cal_Picture.Set<Vec4b>(point, new Vec4b(0, 0, 0, 255));
  3424. }
  3425. }
  3426. }
  3427. cal_Mat.CopyTo(analyzeMat);
  3428. }
  3429. else
  3430. {
  3431. Mat cal_Mat = OpenCvSharp.Extensions.BitmapConverter.ToMat(cal_Bitmap);
  3432. cal_Picture = new Mat(cal_Mat/*matOrg*/.Size(), MatType.CV_8UC4, new Scalar(255, 255, 255, 255));
  3433. cal_Mat.CopyTo(cal_Picture);
  3434. cal_Mat.CopyTo(analyzeMat);
  3435. }
  3436. if (cal_temp != null)
  3437. {
  3438. cal_temp.Dispose();
  3439. cal_temp = null;
  3440. }
  3441. cal_gNum = 0;
  3442. cal1_StandardModel = cal_StandardModel;
  3443. cal1_GuideModel = cal_GuideModel;
  3444. cal1_Picture = cal_Picture;
  3445. cal_analyzeMat = analyzeMat;
  3446. cal1_Tag = cal_Tag;
  3447. cal_BinaryChecked = BinaryChecked;
  3448. cal1_Index = cal_Index;
  3449. cal1_RectFlag = isRectFlag;
  3450. //this.progressDialog = new TransferProgressDialog();
  3451. //this.progressDialog.Text = PdnResources.GetString("DocumentWorkspace.ShowFileDialog.TransferProgress.Title");
  3452. //this.progressDialog.Icon = Utility.ImageToIcon(PdnResources.GetImageResource("Icons.MenuFileOpenIcon.png").Reference);
  3453. //this.progressDialog.Title = PdnResources.GetString("DocumentWorkspace.ShowFileDialog.ItemText.Initializing");
  3454. //this.progressDialog.ProgressBar.Style = ProgressBarStyle.Marquee;
  3455. //this.progressDialog.ProgressBar.Maximum = maxPBValue;
  3456. //DoVerbHandler Delegate_do = new DoVerbHandler(ShowProcessWindow);
  3457. //////Thread.Sleep(30000);//隔30秒后判断一下是否完成
  3458. //////IAsyncResult result = Delegate_do.BeginInvoke(null, null);
  3459. //////while (!result.IsCompleted)
  3460. //////{
  3461. ////// Console.WriteLine("子线程未完成2");
  3462. ////// Thread.Sleep(10000);//每隔10秒判断一下是否完成
  3463. //////}
  3464. //////Console.WriteLine("-------子线程已完成-------");
  3465. ////DoVerbHandler invoker = new DoVerbHandler(ShowProcessWindow);
  3466. ////发起一个线程,异步执行打开一个新窗口
  3467. ////this.progressDialog.BeginInvoke(new Procedure<int>(SetItemCount), new object[] { itemCount });
  3468. //Delegate_do.BeginInvoke(null, null);
  3469. //////你需要在窗体遮罩的时候要做的事情
  3470. ////DoVerbMethod();
  3471. //cal_gNum = GSSClass.GetNumberOfGrains(cal1_StandardModel, cal1_GuideModel/*getCurrentGuideName()*/, cal1_Picture, cal_analyzeMat, getGrainBoundryChecked() || cal_BinaryChecked/*getBinaryChecked()*/,
  3472. // this.appWorkspace.DocumentWorkspaces[cal1_Index].GetRuler(MeasurementUnit.Micron), out cal_temp);
  3473. //yourForm.Close();
  3474. procClass = new ProgressThreadProcClass();
  3475. procClass.StartProgressAutoAction(this, new System.Threading.ThreadStart(cal_Action/*applyDectAction*/), "正在处理"/*PdnResources.GetString("Menu.Grainboundarytoreproduce.text")*/);
  3476. //ProgressThreadProcClass procClass = new ProgressThreadProcClass();
  3477. //int itemCount = 100;
  3478. //ProgressThreadProcClass.IFileTransferProgressEvents progressEvents = new ProgressThreadProcClass.IFileTransferProgressEvents();
  3479. //System.Threading.ThreadStart copyThreadProc =
  3480. // delegate ()
  3481. // {
  3482. // try
  3483. // {
  3484. // gNum = GSSClass.GetNumberOfGrains(cal_StandardModel, cal_GuideModel/*getCurrentGuideName()*/, cal_Picture, analyzeMat, getGrainBoundryChecked() || BinaryChecked/*getBinaryChecked()*/,
  3485. // this.appWorkspace.DocumentWorkspaces[cal_Index].GetRuler(MeasurementUnit.Micron), out temp);
  3486. // }
  3487. // catch (Exception ex)
  3488. // {
  3489. // }
  3490. // finally
  3491. // {
  3492. // progressEvents.EndOperation(OperationResult.Finished);
  3493. // }
  3494. // };
  3495. //procClass.StartProgressAction(this, itemCount, copyThreadProc, progressEvents, null);
  3496. //根据等级设置晶粒颜色
  3497. if (cal_temp != null)
  3498. {
  3499. if (grainMethodType == 1)
  3500. {
  3501. if (this.grainColorsMatDict.ContainsKey(cal_Tag))
  3502. this.grainColorsMatDict[cal_Tag] = cal_temp.Clone();
  3503. else
  3504. this.grainColorsMatDict.Add(cal_Tag, cal_temp.Clone());
  3505. }
  3506. if (cal_Index == this.selectPicture && cal_Tag == getCurrentWorkTag())
  3507. {
  3508. this.documentWorkspace.PhaseModels[2].mat = cal_temp;
  3509. this.documentWorkspace.Refresh();
  3510. }
  3511. }
  3512. return cal_gNum;
  3513. }
  3514. /// <summary>
  3515. /// 事件处理示例方法
  3516. /// </summary>
  3517. /// <param name="arg"></param>
  3518. private void DoVerbMethod()
  3519. {
  3520. for (int i = 0; i < 100; i++)
  3521. {
  3522. System.Threading.Thread.Sleep(100);
  3523. }
  3524. }
  3525. private void ShowProcessWindow()
  3526. {
  3527. yourForm.StartPosition = FormStartPosition.CenterParent;
  3528. yourForm.lblTitleBackColor = Color.Transparent;
  3529. yourForm.ShowDialog();
  3530. }
  3531. /// <summary>
  3532. /// 全局变量,yourForm为新窗口的名字
  3533. /// </summary>
  3534. TransferProgressDialog yourForm = new TransferProgressDialog();
  3535. /// <summary>
  3536. /// 你需要处理的事情的方法委托
  3537. /// </summary>
  3538. /// <param name="arg"></param>
  3539. public delegate void DoVerbHandler(/*object arg*/);
  3540. /// <summary>
  3541. /// 目标选择 1不包含边缘 2边缘只处理内部 3边缘处理内外部
  3542. /// </summary>
  3543. public int TargetSelection = 2;
  3544. private void cal_Action()
  3545. {
  3546. cal_gNum = GSSClass.GetNumberOfGrains(cal1_RectFlag, TargetSelection, cal1_StandardModel, cal1_GuideModel/*getCurrentGuideName()*/, cal1_Picture, cal_analyzeMat, getGrainBoundryChecked() || cal_BinaryChecked/*getBinaryChecked()*/,
  3547. this.appWorkspace.DocumentWorkspaces[cal1_Index].GetRuler(MeasurementUnit.Micron), out cal_temp);
  3548. if (procClass != null) procClass.DismissProgressAction(this);
  3549. }
  3550. /// <summary>
  3551. /// 面积法组织分项数据列表的内容,并返回汇总截距(μm)和汇总面积(μm²)
  3552. /// </summary>
  3553. private double[] addNewRowsToDatagridView2(GrainSizeStandardModel cal_StandardModel, GrainSizeGuideModel cal_GuideModel, string cal_Tag, int cal_Index)
  3554. {
  3555. double small_l = 0;
  3556. double area_sum = 0;
  3557. //显示编号
  3558. if (cal_StandardModel.massLabelPoints.Count > 0 && cal_StandardModel.currentStats != null)
  3559. {
  3560. this.dataGridView2.Rows.Clear();
  3561. string imgName = this.appWorkspace.DocumentWorkspaces[cal_Index].GetFriendlyName();
  3562. int index = 0;
  3563. int label;
  3564. //Dictionary<MeasurementUnit, double> measurementUnitDictionary = Startup.instance.rules;
  3565. //选择标尺的物理长度(1倍下的 微米/像素)
  3566. //this.physical_length = getCurrentWorkspace().GetRuler(MeasurementUnit.Micron);
  3567. double physical_area_length_Micron = this.appWorkspace.DocumentWorkspaces[cal_Index].GetRuler(MeasurementUnit.Micron);
  3568. //double physical_area_length_Micron = measurementUnitDictionary[MeasurementUnit.Micron];
  3569. double aec;
  3570. double grainNumber = 1.0;
  3571. decimal NA;
  3572. foreach (int kvLabel in cal_StandardModel.massLabelPoints.Keys)
  3573. {
  3574. DataGridViewRow dgvr = new DataGridViewRow();
  3575. foreach (DataGridViewColumn c in this.dataGridView2.Columns)
  3576. dgvr.Cells.Add(c.CellTemplate.Clone() as DataGridViewCell);
  3577. dgvr.Cells[0].Value = imgName;
  3578. dgvr.Cells[1].Value = cal_GuideModel.oldSelectItem.ToString();
  3579. dgvr.Cells[2].Value = (++index);//晶粒编号
  3580. label = kvLabel;
  3581. aec = cal_StandardModel.currentStats.At<int>(label/*hcomp*/, 4) * physical_area_length_Micron * physical_area_length_Micron;//晶粒面积
  3582. dgvr.Cells[3].Value = aec/*areaField1*/;
  3583. area_sum += aec;
  3584. aec = aec * 0.001 * 0.001;
  3585. NA = Convert.ToDecimal(grainNumber / aec);
  3586. ////1013###19377##面积法位置,使用晶粒的实际面积去标准中的表进行对应,获取截距后,再进行平均的计算
  3587. double[] lengths = {3.88, 7.75 , 10.96, 15.50, 21.92, 31.0, 43.84, 62.0,
  3588. 87.68, 124, 175.36, 248, 350.73, 496, 701.45, 992, 1402.9, 1984.0, 2805.8, 3968.0, 5611.6,
  3589. 7936.0, 11223.2, 15872.0, 22446.4, 31744.1, 44892.9, 63488.1, 89785.8, 126976.3};
  3590. // 差值
  3591. decimal differenceNew;
  3592. decimal differenceOld = Math.Abs(Convert.ToDecimal(Math.Max((double)NA - 2.88, (double)NA - 126977.3)));
  3593. int first = 0;
  3594. if ((double)NA > lengths[lengths.Length - 1])
  3595. first = lengths.Length - 1;
  3596. else
  3597. for (int firstI = 0; firstI < lengths.Length; firstI++)
  3598. {
  3599. double item = lengths[firstI];
  3600. differenceNew = Math.Abs(NA - Convert.ToDecimal(item));
  3601. if (differenceNew < differenceOld)
  3602. {
  3603. differenceOld = Math.Abs(NA - Convert.ToDecimal(item));
  3604. first = firstI;
  3605. }
  3606. }
  3607. string[] valueGrade = {"00", "0" , "0.5", "1.0", "1.5", "2.0", "2.5", "3.0",
  3608. "3.5", "4.0", "4.5", "5.0", "5.5", "6.0", "6.5", "7.0", "7.5", "8.0", "8.5", "9.0", "9.5",
  3609. "10.0", "10.5", "11.0", "11.5", "12.0", "12.5", "13.0", "13.5", "14.0"};//显微晶粒度级别数G
  3610. string[] valueG = {"452.5", "320.0" , "269.1", "226.3", "190.3", "160.0", "134.5", "113.1",
  3611. "95.1", "80.0", "67.3", "56.6", "47.6", "40.0", "33.6", "28.3", "23.8", "20.0", "16.8", "14.1", "11.9",
  3612. "10.0", "8.4", "7.1", "5.9", "5.0", "4.2", "3.5", "3.0", "2.5"};//微米##晶粒截距
  3613. dgvr.Cells[4].Value = valueG[first];
  3614. small_l += double.Parse(valueG[first]);
  3615. dgvr.Cells[5].Value = valueGrade[first];
  3616. this.dataGridView2.Rows.Add(dgvr);
  3617. }
  3618. for (int dataTableI = dataTables.Count - 1; dataTableI >= 0; dataTableI--)
  3619. {
  3620. System.Data.DataTable dataTable1 = dataTables[dataTableI];
  3621. if (dataTable1.TableName.Equals(cal_Tag))/*dataTable.TableName*/
  3622. dataTables.RemoveAt(dataTableI);
  3623. }
  3624. System.Data.DataTable dataTable = new System.Data.DataTable();
  3625. dataTable.TableName = cal_Tag;
  3626. foreach (DataGridViewColumn c in this.dataGridView2.Columns)
  3627. {
  3628. dataTable.Columns.Add(c.HeaderText);
  3629. }
  3630. for (int r = 0; r < this.dataGridView2.Rows.Count; r++)
  3631. {
  3632. System.Data.DataRow dataRow = dataTable.NewRow();
  3633. for (int c = 0; c < this.dataGridView2.Rows[r].Cells.Count; c++)
  3634. {
  3635. dataRow[this.dataGridView2.Columns[c].HeaderText] = this.dataGridView2.Rows[r].Cells[c].Value;
  3636. }
  3637. dataTable.Rows.Add(dataRow);
  3638. }
  3639. this.dataTables.Add(dataTable);
  3640. }
  3641. return new double[] { small_l, area_sum };
  3642. }
  3643. #endregion
  3644. #region 需继承方法
  3645. /// <summary>
  3646. /// 0,其他; 3,GBT6394的面积法; 4,ISO643
  3647. /// </summary>
  3648. /// <returns></returns>
  3649. protected virtual int getGbtType()
  3650. {
  3651. return 0;
  3652. }
  3653. /// <summary>
  3654. /// 返回保存的参数值-是否显示晶界,显示网格,显示截点
  3655. /// </summary>
  3656. /// <returns></returns>
  3657. protected bool GetParamValue1(string param_key, out object ShowGrainBoundry)
  3658. {
  3659. bool foundItem = false;
  3660. ShowGrainBoundry = true;
  3661. foreach (var item in this.analysisModel.ListParam)
  3662. {
  3663. if (item.param_key.Equals(param_key) && item.menuId == this.menuId)//显示晶界
  3664. {
  3665. ShowGrainBoundry = item.value;
  3666. foundItem = true;
  3667. break;
  3668. }
  3669. }
  3670. return foundItem;
  3671. }
  3672. /// <summary>
  3673. /// 是否显示晶界
  3674. /// </summary>
  3675. /// <returns></returns>
  3676. protected virtual Boolean ShowGrainBoundryChecked()
  3677. {
  3678. return true;
  3679. }
  3680. /// <summary>
  3681. /// 是否显示网格
  3682. /// </summary>
  3683. /// <returns></returns>
  3684. protected virtual Boolean drawDisplaySections()
  3685. {
  3686. return true;
  3687. }
  3688. /// <summary>
  3689. /// 是否用不同颜色显示晶粒
  3690. /// </summary>
  3691. /// <returns></returns>
  3692. protected virtual Boolean ShowGrainColorChecked()
  3693. {
  3694. return true;
  3695. }
  3696. /// <summary>
  3697. /// 是否显示视场
  3698. /// </summary>
  3699. /// <returns></returns>
  3700. protected virtual Boolean ShowDrawClassView()
  3701. {
  3702. return false;
  3703. }
  3704. /// <summary>
  3705. /// 小数点位数后调用的事件
  3706. /// </summary>
  3707. protected virtual void RefreshWhileUpDown1_0ValueChanged()
  3708. {
  3709. }
  3710. /// <summary>
  3711. /// 图片索引改变后调用的事件
  3712. /// </summary>
  3713. protected virtual void refreshWhileImgChanged()
  3714. {
  3715. }
  3716. /// <summary>
  3717. /// 获取对应级别的方法
  3718. /// </summary>
  3719. /// <param name="smalll_index"></param>
  3720. /// <returns></returns>
  3721. protected virtual string getGradeValue(double smalll_index)
  3722. {
  3723. //对应级别 根据(smalll_index;//平均晶粒直径)
  3724. //area_sum += aec;
  3725. //aec = aec * 0.001 * 0.001;
  3726. //NA = Convert.ToDecimal(grainNumber / aec);
  3727. //////1013###19377##面积法位置,使用晶粒的实际面积去标准中的表进行对应,获取截距后,再进行平均的计算
  3728. decimal NA = Convert.ToDecimal(smalll_index);
  3729. double[] lengths = {508.0, 359.2 , 302.1, 254.0, 213.6, 179.6, 151.0, 127.0,
  3730. 106.8, 89.8, 75.5, 63.5, 53.4, 44.9, 37.8, 31.8, 26.7, 22.5, 18.9, 15.9, 13.3,
  3731. 11.2, 9.4, 7.9, 6.7, 5.6, 4.7, 4.0, 3.3, 2.8};
  3732. // 差值
  3733. decimal differenceNew;
  3734. decimal differenceOld = Math.Abs(Convert.ToDecimal(Math.Max(smalll_index - 1.8, smalll_index - 509.0)));
  3735. int first = lengths.Length - 1;
  3736. for (int firstI = 0; firstI < lengths.Length; firstI++)
  3737. {
  3738. double item = lengths[firstI];
  3739. differenceNew = Math.Abs(NA - Convert.ToDecimal(item));
  3740. if (differenceNew < differenceOld)
  3741. {
  3742. differenceOld = Math.Abs(NA - Convert.ToDecimal(item));
  3743. first = firstI;
  3744. }
  3745. }
  3746. string[] valueGrade = {"00", "0" , "0.5", "1.0", "1.5", "2.0", "2.5", "3.0",
  3747. "3.5", "4.0", "4.5", "5.0", "5.5", "6.0", "6.5", "7.0", "7.5", "8.0", "8.5", "9.0", "9.5",
  3748. "10.0", "10.5", "11.0", "11.5", "12.0", "12.5", "13.0", "13.5", "14.0"};//显微晶粒度级别数G
  3749. return valueGrade[first];
  3750. }
  3751. /// <summary>
  3752. /// 保存结果
  3753. /// </summary>
  3754. /// <param name="imagesKey">当前选择图片的tag</param>
  3755. /// <param name="analysisPicture">当前选择图片的Index</param>
  3756. protected virtual void buildListBox_analysisResult(string imagesKey, int analysisPicture, bool saveAll = false)
  3757. {
  3758. bool replace = false;
  3759. int add = 0;
  3760. foreach (ListViewItem item in this.listView2.Items)
  3761. {
  3762. if (item.Tag.Equals(imagesKey))
  3763. {
  3764. add++;
  3765. if (saveAll)
  3766. {
  3767. replace = true;
  3768. break;
  3769. }
  3770. DialogResult dr = MessageBox.Show(PdnResources.GetString("Menu.Theresuethertoreplace.text")+"?", PdnResources.GetString("Menu.hint.text"), MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
  3771. if (dr == DialogResult.OK)
  3772. {
  3773. replace = true;
  3774. }
  3775. break;
  3776. }
  3777. }
  3778. if (!replace && this.listView2.Items.Count > 0 && add > 0)
  3779. return;
  3780. string imgName = this.appWorkspace.DocumentWorkspaces[analysisPicture].GetFriendlyName();
  3781. if (!replace)
  3782. {
  3783. ListViewItem listViewItem = new ListViewItem();
  3784. listViewItem.SubItems[0].Text = imgName;
  3785. listViewItem.Tag = "" + imagesKey;
  3786. if (this.listView2.Items.Count == 0)
  3787. this.listView2.Items.Add(listViewItem);
  3788. else
  3789. this.listView2.Items.Insert(0, listViewItem);
  3790. this.threeDButton.Enabled = true;
  3791. }
  3792. if (grainMethodType == 1)
  3793. buildListBoxArea_analysisResult(imagesKey, analysisPicture);
  3794. else
  3795. buildListBoxCutOff_analysisResult(imagesKey, analysisPicture);
  3796. }
  3797. /// <summary>
  3798. /// PanelC的调色板颜色改变
  3799. /// </summary>
  3800. protected virtual void ColorPanelChanged(Panel panel)
  3801. {
  3802. }
  3803. /// <summary>
  3804. /// 晶粒度辅助线: 计算当前不显示数据的过程
  3805. /// </summary>
  3806. /// <param name="imagesKey"></param>
  3807. /// <param name="analysisPicture"></param>
  3808. protected void calcOtherImgs(string imagesKey, int analysisPicture)
  3809. {
  3810. if (!this.GSSClass.GuideClass.guideDict.ContainsKey(imagesKey))
  3811. GSSClass.GuideClass.guideDict.Add(imagesKey, GSSClass.GuideClass.guideModel.cloneModel/*cloneListParamModel*/());
  3812. GrainSizeGuideModel guideModel = this.GSSClass.GuideClass.guideDict[imagesKey];
  3813. //if (this.comboBox1.DataSource != null && this.comboBox1.SelectedIndex >= 0)
  3814. {
  3815. float recWidth = (float)(Math.Max(1, guideModel.rectangleFLineWidth / this.appWorkspace.DocumentWorkspaces[analysisPicture].GetRuler(MeasurementUnit.Micron)));
  3816. float recHeight = (float)(Math.Max(1, guideModel.rectangleFLineHeight / this.appWorkspace.DocumentWorkspaces[analysisPicture].GetRuler(MeasurementUnit.Micron)));
  3817. double multiple = 1.0;
  3818. if (recWidth > this.appWorkspace.DocumentWorkspaces[analysisPicture].CompositionSurface.Width)
  3819. {
  3820. multiple = this.appWorkspace.DocumentWorkspaces[analysisPicture].CompositionSurface.Width / recWidth;
  3821. }
  3822. if (this.appWorkspace.DocumentWorkspaces[analysisPicture].CompositionSurface.Height < recHeight * multiple)//#21714
  3823. {
  3824. multiple = this.appWorkspace.DocumentWorkspaces[analysisPicture].CompositionSurface.Height / recHeight;
  3825. }
  3826. guideModel.rectangleFLineWidth = (float)(multiple * guideModel.rectangleFLineWidth);
  3827. guideModel.rectangleFLineHeight = (float)(multiple * guideModel.rectangleFLineHeight);
  3828. if (grainMethodType == 1)//#21714
  3829. GSSClass.GuideClass.UpdateScaleGuideAreaStyle(guideModel.oldSelectItem, guideModel, multiple);
  3830. else
  3831. GSSClass.GuideClass.UpdateScaleGuideStyle(guideModel.oldSelectItem, guideModel, recWidth, recHeight
  3832. , this.appWorkspace.DocumentWorkspaces[analysisPicture].GetRuler(MeasurementUnit.Micron), multiple);
  3833. }
  3834. guideModel.loctation = new PointF(this.appWorkspace.DocumentWorkspaces[analysisPicture].CompositionSurface.Width / 2, this.appWorkspace.DocumentWorkspaces[analysisPicture].CompositionSurface.Height / 2);
  3835. //if (this.comboBox1.DataSource != null && this.comboBox1.SelectedIndex >= 0)
  3836. {
  3837. float recWidth = (float)(Math.Max(1, guideModel.rectangleFLineWidth / this.appWorkspace.DocumentWorkspaces[analysisPicture].GetRuler(MeasurementUnit.Micron)));
  3838. float recHeight = (float)(Math.Max(1, guideModel.rectangleFLineHeight / this.appWorkspace.DocumentWorkspaces[analysisPicture].GetRuler(MeasurementUnit.Micron)));
  3839. guideModel.RectangleFLine = new RectangleF(guideModel.loctation.X - recWidth / 2
  3840. , guideModel.loctation.Y - recHeight / 2
  3841. , recWidth, recHeight);//########################################
  3842. bool foundItem = false;
  3843. if (grainMethodType == 1)
  3844. {
  3845. if (this.matOrg != null && guideModel.oldSelectItem != null)
  3846. GSSClass.GuideClass.updateGuideAreaRectLine(guideModel.oldSelectItem, guideModel, out foundItem, true/*guideTypeChanged*/, this.appWorkspace.DocumentWorkspaces[analysisPicture].GetRuler(MeasurementUnit.Micron));
  3847. }
  3848. else
  3849. if (this.matOrg != null && guideModel.oldSelectItem != null)
  3850. GSSClass.GuideClass.updateGuideRectLine(guideModel.oldSelectItem, guideModel, out foundItem, true/*guideTypeChanged*/, this.appWorkspace.DocumentWorkspaces[analysisPicture].GetRuler(MeasurementUnit.Micron));
  3851. /////*this.*/
  3852. ////GSSClass.GuideClass.updateRectangleSize(getCurrentWorkspace().GetRuler(MeasurementUnit.Micron)/*physical_Micron*/);
  3853. if (foundItem)
  3854. AddRectangleToRectangleFCaps(imagesKey, analysisPicture);
  3855. //this.documentWorkspace.Refresh();
  3856. }
  3857. }
  3858. /// <summary>
  3859. /// 截点法组织分项数据列表的内容,并返回网格总长度(μm)和截点总数
  3860. /// </summary>
  3861. private double[] addCutOffNewRowsToDatagridView2(string imagesKey, int analysisPicture)
  3862. {
  3863. string imgName = this.appWorkspace.DocumentWorkspaces[analysisPicture].GetFriendlyName();
  3864. //string tag = getCurrentWorkTag();//imagesKey
  3865. double small_l = 0;
  3866. double count_sum = 0;
  3867. this.dataGridView2.Rows.Clear();
  3868. DataGridViewRow dgvr = new DataGridViewRow();
  3869. foreach (DataGridViewColumn c in this.dataGridView2.Columns)
  3870. dgvr.Cells.Add(c.CellTemplate.Clone() as DataGridViewCell);
  3871. dgvr.Cells[0].Value = imgName;
  3872. if (analysisPicture != this.selectPicture)//更新二值图片
  3873. binaryClass.updateAnalysisData(imagesKey, analysisPicture);
  3874. GrainSizeGuideModel guideModel = this.GSSClass.GuideClass.guideModel;
  3875. if (this.GSSClass.GuideClass.guideDict.ContainsKey(imagesKey))
  3876. guideModel = this.GSSClass.GuideClass.guideDict[imagesKey];
  3877. //else if (analysisPicture != this.selectPicture)//计算对应图片的数据
  3878. //{
  3879. // this.calcOtherImgs(imagesKey, analysisPicture);
  3880. //}
  3881. GrainPointStyleModel styleModel = this.GSSClass.styleClass.styleModel;
  3882. if (this.GSSClass.styleClass.styleDict.ContainsKey(imagesKey))
  3883. styleModel = this.GSSClass.styleClass.styleDict[imagesKey];
  3884. else//计算对应图片的数据
  3885. {
  3886. }
  3887. if (this.GSSClass.GuideClass.guideModel.oldSelectItem == null)
  3888. this.GSSClass.GuideClass.guideModel.oldSelectItem = this.comboBox1SelectedItem.ToString();
  3889. if (guideModel.oldSelectItem == null)//#######################
  3890. guideModel.oldSelectItem = this.GSSClass.GuideClass.guideModel.oldSelectItem;
  3891. //if (analysisPicture != this.selectPicture)//计算对应图片的数据
  3892. //{
  3893. // this.calcOtherImgs(imagesKey, analysisPicture);
  3894. //}
  3895. dgvr.Cells[1].Value = guideModel.oldSelectItem;// this.comboBox1.SelectedItem;
  3896. double length = GSSClass.GuideClass.guideLength(guideModel/*this.comboBox1.SelectedItem*/);
  3897. small_l += length;
  3898. dgvr.Cells[2].Value = length;
  3899. double countPoints = styleModel.getCountPoints();
  3900. decimal M = 1;
  3901. double PL = (double)M * countPoints / length;
  3902. count_sum += countPoints;
  3903. dgvr.Cells[3].Value = countPoints;
  3904. dgvr.Cells[4].Value = 1.0 / PL;
  3905. if (getGbtType() == 4)
  3906. dgvr.Cells[5].Value = -6.6439 * Math.Log10(1.0 / PL * 0.001) - 3.2877;
  3907. else
  3908. dgvr.Cells[5].Value = -6.643856 * Math.Log10(1.0 / PL * 0.001) - 3.288;
  3909. this.dataGridView2.Rows.Add(dgvr);
  3910. for (int dataTableI = dataTables.Count - 1; dataTableI >= 0; dataTableI--)
  3911. {
  3912. System.Data.DataTable dataTable1 = dataTables[dataTableI];
  3913. if (dataTable1.TableName.Equals(imagesKey))
  3914. dataTables.RemoveAt(dataTableI);
  3915. }
  3916. System.Data.DataTable dataTable = new System.Data.DataTable();
  3917. dataTable.TableName = imagesKey;
  3918. foreach (DataGridViewColumn c in this.dataGridView2.Columns)
  3919. {
  3920. dataTable.Columns.Add(c.HeaderText);
  3921. }
  3922. for (int r = 0; r < this.dataGridView2.Rows.Count; r++)
  3923. {
  3924. System.Data.DataRow dataRow = dataTable.NewRow();
  3925. for (int c = 0; c < this.dataGridView2.Rows[r].Cells.Count; c++)
  3926. {
  3927. dataRow[this.dataGridView2.Columns[c].HeaderText] = this.dataGridView2.Rows[r].Cells[c].Value;
  3928. }
  3929. dataTable.Rows.Add(dataRow);
  3930. }
  3931. this.dataTables.Add(dataTable);
  3932. return new double[] { small_l, count_sum };
  3933. }
  3934. /// <summary>
  3935. /// 截点法-保存结果
  3936. /// </summary>
  3937. private void buildListBoxCutOff_analysisResult(string imagesKey, int analysisPicture)
  3938. {
  3939. //组织详细数据列表的内容,获取截距和截点数后,再进行平均的计算
  3940. double[] res_arr = addCutOffNewRowsToDatagridView2(imagesKey, analysisPicture);
  3941. double small_l = res_arr[0];
  3942. double grainNumber = res_arr[1];
  3943. this.dataGridView_Total.Rows.Clear();
  3944. DataGridViewRow dgvr = new DataGridViewRow();
  3945. foreach (DataGridViewColumn c in this.dataGridView_Total.Columns)
  3946. {
  3947. dgvr.Cells.Add(c.CellTemplate.Clone() as DataGridViewCell);
  3948. }
  3949. dgvr.Cells[0].Value = small_l;
  3950. dgvr.Cells[1].Value = grainNumber;
  3951. if (grainNumber > 0)
  3952. small_l = small_l / grainNumber;
  3953. dgvr.Cells[2].Value = small_l;
  3954. if (getGbtType() == 4)
  3955. dgvr.Cells[3].Value = -6.6439 * Math.Log10(small_l * 0.001) - 3.2877;
  3956. else
  3957. dgvr.Cells[3].Value = -6.643856 * Math.Log10(small_l * 0.001) - 3.288;
  3958. this.dataGridView_Total.Rows.Add(dgvr);
  3959. System.Data.DataTable dataTable = new System.Data.DataTable();
  3960. dataTable.TableName = imagesKey;
  3961. foreach (System.Data.DataTable dataTable1 in dataTable_Totals)
  3962. {
  3963. if (dataTable1.TableName.Equals(dataTable.TableName))
  3964. {
  3965. dataTable_Totals.Remove(dataTable1);
  3966. break;
  3967. }
  3968. }
  3969. if (this.dict_Totals.ContainsKey(dataTable.TableName))
  3970. this.dict_Totals.Remove(dataTable.TableName);
  3971. foreach (DataGridViewColumn c in this.dataGridView_Total.Columns)
  3972. dataTable.Columns.Add(c.HeaderText);
  3973. for (int r = 0; r < this.dataGridView_Total.Rows.Count; r++)
  3974. {
  3975. System.Data.DataRow dataRow = dataTable.NewRow();
  3976. for (int c = 0; c < this.dataGridView_Total.Rows[r].Cells.Count; c++)
  3977. dataRow[this.dataGridView_Total.Columns[c].HeaderText] = this.dataGridView_Total.Rows[r].Cells[c].Value;
  3978. dataTable.Rows.Add(dataRow);
  3979. }
  3980. this.dataTable_Totals.Add(dataTable);
  3981. this.RefreshDataGridView4();
  3982. //保存处理后的图片
  3983. double pantographRatio = this.appWorkspace.DocumentWorkspaces[analysisPicture].GetRulerMultiple(MeasurementUnit.Micron);//标尺*放大倍数
  3984. List<Bitmap> tempBit = new List<Bitmap>();
  3985. Bitmap originalBit = this.bitmap;// this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].CompositionSurface.CreateAliasedBitmap();
  3986. if (analysisPicture != this.selectPicture)//更新处理前的图片
  3987. originalBit = this.appWorkspace.DocumentWorkspaces[analysisPicture].CompositionSurface.CreateAliasedBitmap();
  3988. originalBit.Tag = pantographRatio;
  3989. tempBit.Add(originalBit);
  3990. Bitmap newBit = originalBit.Clone(new Rectangle(0, 0, originalBit.Width, originalBit.Height), originalBit.PixelFormat);
  3991. Graphics graphics = Graphics.FromImage(newBit);
  3992. if (binaryClass.getModelMat(imagesKey) != null/*this.documentWorkspace.PhaseModels[0].choise && this.documentWorkspace.PhaseModels[0].mat != null*/)
  3993. {//(imagesKey != null) ? binaryClass.getModelMat(imagesKey) : this.PhaseModel0Mat
  3994. Mat targetMat = binaryClass.getModelMat(imagesKey);// this.PhaseModel0Mat;
  3995. graphics.DrawImage(OpenCvSharp.Extensions.BitmapConverter.ToBitmap(targetMat), 0, 0, targetMat.Width, targetMat.Height);
  3996. }
  3997. else if (imagesKey.Equals(getCurrentWorkTag()) && this.documentWorkspace.PhaseModels[0].choise && this.documentWorkspace.PhaseModels[0].mat != null)
  3998. {
  3999. Mat targetMat = this.documentWorkspace.PhaseModels[0].mat;// this.PhaseModel0Mat;
  4000. graphics.DrawImage(OpenCvSharp.Extensions.BitmapConverter.ToBitmap(targetMat), 0, 0, targetMat.Width, targetMat.Height);
  4001. }
  4002. if (this.grainBoundaryMatDict.ContainsKey(imagesKey))
  4003. {
  4004. Mat targetMat = this.grainBoundaryMatDict[imagesKey];// this.documentWorkspace.PhaseModels[1].mat;
  4005. graphics.DrawImage(OpenCvSharp.Extensions.BitmapConverter.ToBitmap(targetMat), 0, 0, targetMat.Width, targetMat.Height);
  4006. }
  4007. if (this.grainColorsMatDict.ContainsKey(imagesKey) && !bcOriginChecked() && ShowGrainColorChecked())
  4008. {
  4009. Mat targetMat = this.grainColorsMatDict[imagesKey];// this.documentWorkspace.PhaseModels[1].mat;
  4010. graphics.DrawImage(OpenCvSharp.Extensions.BitmapConverter.ToBitmap(targetMat), 0, 0, targetMat.Width, targetMat.Height);
  4011. }
  4012. //if (this.documentWorkspace.PhaseModels[2].choise && this.documentWorkspace.PhaseModels[2].mat != null
  4013. // && !this.documentWorkspace.PhaseModels[2].mat.IsDisposed)
  4014. //{
  4015. // Mat targetMat = this.documentWorkspace.PhaseModels[2].mat;
  4016. // graphics.DrawImage(OpenCvSharp.Extensions.BitmapConverter.ToBitmap(targetMat), 0, 0, targetMat.Width, targetMat.Height);
  4017. //}
  4018. graphics.SmoothingMode = SmoothingMode.AntiAlias;
  4019. drawSubclass/*Draw*/(graphics, imagesKey, analysisPicture);
  4020. newBit.Tag = pantographRatio;
  4021. tempBit.Add(newBit);
  4022. if (bitDic.ContainsKey(imagesKey))
  4023. bitDic[imagesKey] = tempBit;
  4024. else
  4025. bitDic.Add(imagesKey, tempBit);
  4026. ////this.
  4027. //this.phy
  4028. ////拼接中间数据
  4029. //List<List<string>> dataList = new List<List<string>>();
  4030. //List<string> columnName = new List<string>();
  4031. //columnName.Add(PdnResources.GetString("Menu.Imagement.Measurementlist.ordernumber.text"));
  4032. //columnName.Add(PdnResources.GetString("Menu.Xoordinate.Text"));
  4033. //columnName.Add(PdnResources.GetString("Menu.Yoordinate.Text"));
  4034. //columnName.Add(PdnResources.GetString("Menu.Whethertheinternal.Text"));
  4035. //dataList.Add(columnName);
  4036. GrainPointStyleModel styleModel = this.GSSClass.styleClass.styleModel;
  4037. if (this.GSSClass.styleClass.styleDict.ContainsKey(imagesKey))
  4038. styleModel = this.GSSClass.styleClass.styleDict[imagesKey];
  4039. //拼接中间数据
  4040. List<List<string>> dataList = GSSClass.styleClass.getTableDataList(styleModel, this.appWorkspace.DocumentWorkspaces[analysisPicture].GetRuler(MeasurementUnit.Micron));
  4041. bool isExist = false;//是否已存在进行替换
  4042. int modelIndex = -1;//要替换的下标
  4043. for (int j = 0; j < tempDataModel.Count; j++)
  4044. {
  4045. if (tempDataModel[j].tagName.Equals(imagesKey))
  4046. {
  4047. isExist = true;
  4048. modelIndex = j;
  4049. break;
  4050. }
  4051. }
  4052. if (isExist && modelIndex > -1)
  4053. tempDataModel[modelIndex].dataList = dataList;
  4054. else
  4055. {
  4056. ExportProjectModel newModel = new ExportProjectModel();
  4057. newModel.tagName = imagesKey;
  4058. newModel.picName = this.appWorkspace.DocumentWorkspaces[analysisPicture].GetFriendlyName();//##################################
  4059. newModel.dataList = dataList;
  4060. tempDataModel.Add(newModel);
  4061. }
  4062. }
  4063. /// <summary>
  4064. /// 面积法-保存结果
  4065. /// </summary>
  4066. private void buildListBoxArea_analysisResult(string imagesKey, int analysisPicture)
  4067. {
  4068. if (analysisPicture != this.selectPicture)//更新二值图片
  4069. binaryClass.updateAnalysisData(imagesKey, analysisPicture);
  4070. GrainSizeGuideModel cal_GuideModel = this.GSSClass.GuideClass.guideModel;
  4071. if (this.GSSClass.GuideClass.guideDict.ContainsKey(imagesKey))
  4072. cal_GuideModel = this.GSSClass.GuideClass.guideDict[imagesKey];
  4073. //else if (analysisPicture != this.selectPicture)//根据选择的辅助线 计算对应图片的数据
  4074. //{
  4075. // this.calcOtherImgs(imagesKey, analysisPicture);
  4076. //}
  4077. if (this.GSSClass.GuideClass.guideModel.oldSelectItem == null)
  4078. this.GSSClass.GuideClass.guideModel.oldSelectItem = this.comboBox1SelectedItem.ToString();
  4079. if (cal_GuideModel.oldSelectItem == null)//##
  4080. cal_GuideModel.oldSelectItem = this.GSSClass.GuideClass.guideModel.oldSelectItem;
  4081. GrainSizeStandardModel cal_StandardModel = this.GSSClass.standardModel;
  4082. if (imagesKey != null)
  4083. {
  4084. if (!this.GSSClass.standardDict.ContainsKey(imagesKey))
  4085. this.GSSClass.standardDict.Add(imagesKey, this.GSSClass.standardModel.cloneListParamModel());
  4086. cal_StandardModel = this.GSSClass.standardDict[imagesKey];
  4087. if (analysisPicture == this.selectPicture && imagesKey.Equals(getCurrentWorkTag()))
  4088. this.GSSClass.standardModel = this.GSSClass.standardDict[imagesKey];
  4089. }
  4090. if (analysisPicture != this.selectPicture)//根据选择的辅助线 计算对应图片的数据
  4091. //if (cal_StandardModel.linePointList.Count == 0)
  4092. this.calcOtherImgs(imagesKey, analysisPicture);
  4093. // 是否矩形辅助线
  4094. int isRect;
  4095. double aec0 = GSSClass.GuideClass.guideArea(cal_GuideModel, cal_GuideModel.oldSelectItem/*this.comboBox1.SelectedItem*/, out isRect, getGbtType());
  4096. //aec = aec * 0.001 * 0.001;
  4097. double grainNumber = GetNumberOfGrains(cal_StandardModel, cal_GuideModel, imagesKey, analysisPicture
  4098. , isRect == 1) + isRect;
  4099. //组织详细数据列表的内容,获取截距和面积后,再进行平均的计算<=>GBT6394面积法计算级别
  4100. double[] res_arr = addNewRowsToDatagridView2(cal_StandardModel, cal_GuideModel, imagesKey, analysisPicture);
  4101. //grainNumber = 8;
  4102. double small_l = res_arr[0];
  4103. double area_l = aec0;// res_arr[1];
  4104. this.dataGridView_Total.Rows.Clear();
  4105. DataGridViewRow dgvr = new DataGridViewRow();
  4106. foreach (DataGridViewColumn c in this.dataGridView_Total.Columns)
  4107. {
  4108. dgvr.Cells.Add(c.CellTemplate.Clone() as DataGridViewCell);
  4109. }
  4110. dgvr.Cells[0].Value = grainNumber;
  4111. if (getGbtType() == 3)
  4112. {
  4113. if (grainNumber > 0)
  4114. area_l = area_l / grainNumber;
  4115. double aec = area_l * 0.001 * 0.001;
  4116. double NA = (double)1/*grainNumber*/ / aec;
  4117. dgvr.Cells[1].Value = 3.321928 * Math.Log10(NA) - 2.954;
  4118. }
  4119. else
  4120. {
  4121. dgvr.Cells[1].Value = small_l;
  4122. if (grainNumber > 0)
  4123. small_l = small_l / grainNumber;
  4124. dgvr.Cells[2].Value = small_l;
  4125. if (getGbtType() == 4)
  4126. dgvr.Cells[3].Value = -6.6439 * Math.Log10(small_l * 0.001) - 3.2877;
  4127. else
  4128. dgvr.Cells[3].Value = -6.643856 * Math.Log10(small_l * 0.001) - 3.288;
  4129. if (grainNumber > 0)
  4130. area_l = area_l / grainNumber;
  4131. dgvr.Cells[4].Value = area_l;
  4132. double aec = area_l * 0.001 * 0.001;
  4133. double NA = (double)1/*grainNumber*/ / aec;
  4134. if (getGbtType() == 4)
  4135. dgvr.Cells[5].Value = 3.32 * Math.Log10(NA) - 2.9542;
  4136. else
  4137. dgvr.Cells[5].Value = 3.321928 * Math.Log10(NA) - 2.954;//!!!!!!!!!!!!!................................
  4138. }
  4139. this.dataGridView_Total.Rows.Add(dgvr);
  4140. System.Data.DataTable dataTable = new System.Data.DataTable();
  4141. dataTable.TableName = imagesKey;
  4142. foreach (System.Data.DataTable dataTable1 in dataTable_Totals)
  4143. {
  4144. if (dataTable1.TableName.Equals(dataTable.TableName))
  4145. {
  4146. dataTable_Totals.Remove(dataTable1);
  4147. break;
  4148. }
  4149. }
  4150. if (this.dict_Totals.ContainsKey(dataTable.TableName))
  4151. this.dict_Totals.Remove(dataTable.TableName);
  4152. foreach (DataGridViewColumn c in this.dataGridView_Total.Columns)
  4153. {
  4154. dataTable.Columns.Add(c.HeaderText);
  4155. }
  4156. for (int r = 0; r < this.dataGridView_Total.Rows.Count; r++)
  4157. {
  4158. System.Data.DataRow dataRow = dataTable.NewRow();
  4159. for (int c = 0; c < this.dataGridView_Total.Rows[r].Cells.Count; c++)
  4160. {
  4161. dataRow[this.dataGridView_Total.Columns[c].HeaderText] = this.dataGridView_Total.Rows[r].Cells[c].Value;
  4162. }
  4163. dataTable.Rows.Add(dataRow);
  4164. }
  4165. this.dataTable_Totals.Add(dataTable);
  4166. if (getGbtType() == 3)
  4167. this.dict_Totals.Add(imagesKey, new Dictionary<string, object>() { { "RectArea", aec0 } });
  4168. this.RefreshDataGridView4();
  4169. //保存处理后的图片
  4170. double pantographRatio = this.appWorkspace.DocumentWorkspaces[analysisPicture].GetRulerMultiple(MeasurementUnit.Micron);//标尺*放大倍数
  4171. List<Bitmap> tempBit = new List<Bitmap>();
  4172. Bitmap originalBit = this.bitmap;
  4173. if (analysisPicture != this.selectPicture)//更新处理前的图片
  4174. originalBit = this.appWorkspace.DocumentWorkspaces[analysisPicture].CompositionSurface.CreateAliasedBitmap();
  4175. originalBit.Tag = pantographRatio;
  4176. tempBit.Add(originalBit);
  4177. Bitmap newBit = originalBit.Clone(new Rectangle(0, 0, originalBit.Width, originalBit.Height), originalBit.PixelFormat);
  4178. Graphics graphics = Graphics.FromImage(newBit);
  4179. if (binaryClass.getModelMat(imagesKey) != null)
  4180. {
  4181. Mat targetMat = binaryClass.getModelMat(imagesKey);
  4182. graphics.DrawImage(OpenCvSharp.Extensions.BitmapConverter.ToBitmap(targetMat), 0, 0, targetMat.Width, targetMat.Height);
  4183. }
  4184. if (this.grainBoundaryMatDict.ContainsKey(imagesKey))
  4185. {
  4186. Mat targetMat = this.grainBoundaryMatDict[imagesKey];
  4187. graphics.DrawImage(OpenCvSharp.Extensions.BitmapConverter.ToBitmap(targetMat), 0, 0, targetMat.Width, targetMat.Height);
  4188. }
  4189. if (this.grainColorsMatDict.ContainsKey(imagesKey) && !bcOriginChecked() && ShowGrainColorChecked())
  4190. {
  4191. Mat targetMat = this.grainColorsMatDict[imagesKey];
  4192. graphics.DrawImage(OpenCvSharp.Extensions.BitmapConverter.ToBitmap(targetMat), 0, 0, targetMat.Width, targetMat.Height);
  4193. }
  4194. graphics.SmoothingMode = SmoothingMode.AntiAlias;
  4195. drawSubclass(graphics, imagesKey, analysisPicture);
  4196. newBit.Tag = pantographRatio;
  4197. tempBit.Add(newBit);
  4198. if (bitDic.ContainsKey(imagesKey))
  4199. bitDic[imagesKey] = tempBit;
  4200. else
  4201. bitDic.Add(imagesKey, tempBit);
  4202. //拼接中间数据
  4203. List<List<string>> dataList = new List<List<string>>();
  4204. List<string> columnName = new List<string>();
  4205. columnName.Add(PdnResources.GetString("Menu.Imagement.Measurementlist.ordernumber.text"));
  4206. columnName.Add(PdnResources.GetString("Menu.Xoordinate.Text"));
  4207. columnName.Add(PdnResources.GetString("Menu.Yoordinate.Text"));
  4208. columnName.Add(PdnResources.GetString("Menu.Whethertheinternal.Text"));
  4209. //Dictionary<MeasurementUnit, double> measurementUnitDictionary = Startup.instance.rules;
  4210. //选择标尺的物理长度(1倍下的 微米/像素)
  4211. //double physical_area_length_Micron = measurementUnitDictionary[MeasurementUnit.Micron];
  4212. double physical_area_length_Micron = this.appWorkspace.DocumentWorkspaces[analysisPicture].GetRuler(MeasurementUnit.Micron);
  4213. if (cal_StandardModel.currentStats != null && physical_area_length_Micron > 0)//##20544
  4214. {
  4215. columnName.Add("晶粒面积"/*PdnResources.GetString("Menu.Whethertheinternal.Text")*/);
  4216. }
  4217. //aec = currentStats.At<int>(label/*hcomp*/, 4) * physical_area_length_Micron * physical_area_length_Micron;//晶粒面积
  4218. dataList.Add(columnName);
  4219. if (cal_StandardModel.massLabelPoints.Count > 0)
  4220. {
  4221. int index = 0;
  4222. int outMaxIndex = cal_StandardModel.massLabelPoints.Count - 0 - cal_StandardModel.within;
  4223. foreach (var label in cal_StandardModel.massLabelPoints.Keys)//####################
  4224. {
  4225. var item = cal_StandardModel.massLabelPoints[label];
  4226. List<string> strList = new List<string>();
  4227. strList.Add(("" + (++index)).ToString());
  4228. strList.Add(item[2].ToString());
  4229. strList.Add(item[3].ToString());
  4230. if (outMaxIndex < index)
  4231. strList.Add(PdnResources.GetString("Menu.Yes.text"));
  4232. else
  4233. strList.Add(PdnResources.GetString("Menu.no.text"));
  4234. strList.Add((cal_StandardModel.currentStats.At<int>(label/*hcomp*/, 4) * physical_area_length_Micron * physical_area_length_Micron).ToString());
  4235. dataList.Add(strList);
  4236. }
  4237. }
  4238. bool isExist = false;//是否已存在进行替换
  4239. int modelIndex = -1;//要替换的下标
  4240. for (int j = 0; j < tempDataModel.Count; j++)
  4241. {
  4242. if (tempDataModel[j].tagName.Equals(imagesKey))
  4243. {
  4244. isExist = true;
  4245. modelIndex = j;
  4246. break;
  4247. }
  4248. }
  4249. if (isExist && modelIndex > -1)
  4250. tempDataModel[modelIndex].dataList = dataList;
  4251. else
  4252. {
  4253. Base.Functionodel.ExportProjectModel newModel = new Base.Functionodel.ExportProjectModel();
  4254. newModel.tagName = imagesKey;
  4255. newModel.picName = this.appWorkspace.DocumentWorkspaces[analysisPicture].GetFriendlyName();
  4256. newModel.dataList = dataList;
  4257. tempDataModel.Add(newModel);
  4258. }
  4259. }
  4260. /// <summary>
  4261. /// 保存子窗体参数
  4262. /// </summary>
  4263. protected virtual void saveSonData()
  4264. {
  4265. }
  4266. /// <summary>
  4267. /// 获取子窗体参数
  4268. /// </summary>
  4269. protected virtual void getSonData()
  4270. {
  4271. }
  4272. /// <summary>
  4273. /// 保存子窗体录制参数
  4274. /// </summary>
  4275. protected virtual object saveRecordingData(string key)
  4276. {
  4277. return null;
  4278. }
  4279. protected virtual void SubclassInitialize()
  4280. {
  4281. throw new NotImplementedException();
  4282. }
  4283. /// <summary>
  4284. /// 辅助线类型
  4285. /// </summary>
  4286. /// <returns></returns>
  4287. protected virtual string[] getTypeNames()
  4288. {
  4289. return new string[] {
  4290. "",
  4291. ""};
  4292. }
  4293. /// <summary>
  4294. /// 辅助线配置文件名称
  4295. /// </summary>
  4296. /// <returns></returns>
  4297. protected virtual string getModelName()
  4298. {
  4299. throw new NotImplementedException();
  4300. }
  4301. /// <summary>
  4302. /// 报告模板命名
  4303. /// </summary>
  4304. /// <returns></returns>
  4305. protected virtual string getTemplateName()
  4306. {
  4307. throw new NotImplementedException();
  4308. }
  4309. /// <summary>
  4310. /// 项目工程内的文件夹路径名称
  4311. /// </summary>
  4312. /// <returns></returns>
  4313. protected virtual string getProjectEngineeringName()
  4314. {
  4315. throw new NotImplementedException();
  4316. }
  4317. /// <summary>
  4318. /// 是否绘制辅助线
  4319. /// </summary>
  4320. /// <param name="graphics"></param>
  4321. /// <returns></returns>
  4322. protected virtual bool showGridChecked()
  4323. {
  4324. return false;
  4325. }
  4326. /// <summary>
  4327. /// 是否绘制截点
  4328. /// </summary>
  4329. /// <param name="graphics"></param>
  4330. /// <returns></returns>
  4331. protected virtual bool drawGuidePoints()
  4332. {
  4333. return false;
  4334. }
  4335. /// <summary>
  4336. /// 是否绘制编号
  4337. /// </summary>
  4338. /// <param name="graphics"></param>
  4339. /// <returns></returns>
  4340. protected virtual bool showGrainNumberChecked()
  4341. {
  4342. return false;
  4343. }
  4344. protected virtual void drawSubclass(Graphics graphics, string imagesKey = null, int analysisPicture = -1)
  4345. {
  4346. GrainSizeGuideModel cal_GuideModel = GSSClass.GuideClass.guideModel;
  4347. if (imagesKey != null && GSSClass.GuideClass.guideDict.ContainsKey(imagesKey))
  4348. cal_GuideModel = GSSClass.GuideClass.guideDict[imagesKey];
  4349. GrainPointStyleModel cal_StyleModel = GSSClass.styleClass.styleModel;
  4350. if (imagesKey != null && GSSClass.styleClass.styleDict.ContainsKey(imagesKey))
  4351. cal_StyleModel = GSSClass.styleClass.styleDict[imagesKey];
  4352. GrainSizeStandardModel cal_StandardModel = GSSClass.standardModel;
  4353. if (imagesKey != null && GSSClass.standardDict.ContainsKey(imagesKey))
  4354. cal_StandardModel = GSSClass.standardDict[imagesKey];
  4355. //显示辅助线
  4356. if (showGridChecked())
  4357. if (grainMethodType == 1)
  4358. GSSClass.GuideClass.DrawAreaGuide(graphics, cal_GuideModel.oldSelectItem != null ? cal_GuideModel.oldSelectItem : this.comboBox1.SelectedItem, cal_GuideModel);
  4359. else
  4360. GSSClass.GuideClass.DrawGuideLines(graphics, cal_GuideModel.oldSelectItem != null ? cal_GuideModel.oldSelectItem : this.comboBox1.SelectedItem, cal_GuideModel);
  4361. //显示截点
  4362. if (drawGuidePoints())
  4363. cal_StyleModel.DrawGuidePoints(graphics);
  4364. //显示编号
  4365. if (showGrainNumberChecked() && cal_StandardModel.massLabelPoints.Count > 0)
  4366. {
  4367. int index = 0;
  4368. Font myFont = new Font("宋体", 12);
  4369. Brush bush = new SolidBrush(getGrainBoundryColor());//填充的颜色
  4370. foreach (var item in cal_StandardModel.massLabelPoints.Values)
  4371. {
  4372. graphics.DrawString("" + (++index), myFont, bush, (float)item[2] - 5, (float)item[3] - 5);
  4373. }
  4374. }
  4375. }
  4376. /// <summary>
  4377. /// 实现手动添加在原图情况下的截点位置跟随辅助线的移动而移动
  4378. /// </summary>
  4379. public void MoveOriginCutOffPoints(float offsetX, float offsetY)
  4380. {
  4381. Mat mat;
  4382. if (!getGrainBoundryChecked() && !getBinaryChecked())
  4383. {
  4384. mat = matOrg;
  4385. }
  4386. else
  4387. {
  4388. if (getGrainBoundryChecked())
  4389. {
  4390. if (this.documentWorkspace.PhaseModels[1].mat != null)
  4391. mat = this.documentWorkspace.PhaseModels[1].mat;
  4392. else
  4393. return;
  4394. }
  4395. else if (this.documentWorkspace.PhaseModels[0].mat != null)
  4396. {
  4397. mat = this.PhaseModel0Mat;
  4398. }
  4399. else
  4400. return;
  4401. }
  4402. if (mat == null)
  4403. return;
  4404. //##21247
  4405. GSSClass.MoveOriginCutOffPoints(offsetX, offsetY, this.getCurrentGuideName(), mat);
  4406. }
  4407. ///// <summary>
  4408. ///// 刷新图形边线点集合//#########################################
  4409. ///// </summary>
  4410. /// <param name="imagesKey">计算当前不显示数据的过程</param>
  4411. /// <param name="analysisPicture">计算当前不显示数据的过程</param>
  4412. private void AddRectangleToRectangleFCaps(string imagesKey = null, int analysisPicture = -1)
  4413. {
  4414. if (grainMethodType == 1 && this.bitmap == null)//####################
  4415. return;
  4416. if (grainMethodType == 1)
  4417. {//###############################################
  4418. Bitmap cal_Bitmap = this.bitmap;
  4419. if (imagesKey != null && analysisPicture != -1)
  4420. cal_Bitmap = this.appWorkspace.DocumentWorkspaces[analysisPicture].CompositionSurface.CreateAliasedBitmap();
  4421. string cal_GuideName = imagesKey != null ? GSSClass.GuideClass.guideDict[imagesKey].oldSelectItem : this.getCurrentGuideName();
  4422. GSSClass.AddRectangleToRectangleFCaps(imagesKey, grainMethodType, cal_Bitmap, cal_GuideName, 0, null, (analysisPicture != -1 ? this.appWorkspace.DocumentWorkspaces[analysisPicture] : getCurrentWorkspace()).GetRuler(MeasurementUnit.Micron));
  4423. this.documentWorkspace.Refresh();
  4424. return;
  4425. }
  4426. //this.analysisDict.
  4427. bool BinaryChecked;
  4428. if (imagesKey != null)
  4429. BinaryChecked = (binaryClass.getModelMat(imagesKey) != null);
  4430. else
  4431. BinaryChecked = getBinaryChecked();
  4432. Mat mat;
  4433. if (!getGrainBoundryChecked() && !BinaryChecked)//###########################
  4434. {
  4435. mat = matOrg;
  4436. }
  4437. else
  4438. {
  4439. if (getGrainBoundryChecked())
  4440. {
  4441. if (this.documentWorkspace.PhaseModels[1].mat != null)
  4442. mat = this.documentWorkspace.PhaseModels[1].mat;
  4443. else
  4444. return;
  4445. }
  4446. else if (BinaryChecked/*this.documentWorkspace.PhaseModels[0].mat != null*/)
  4447. {
  4448. mat = (imagesKey != null) ? binaryClass.getModelMat(imagesKey) : this.PhaseModel0Mat;
  4449. }
  4450. else
  4451. return;
  4452. }
  4453. if (mat == null)
  4454. return;
  4455. int matLevel = 0;
  4456. if (getGrainBoundryChecked())
  4457. matLevel = 2;
  4458. else if (BinaryChecked/*getBinaryChecked()*/)
  4459. matLevel = 1;
  4460. else if (!getGrainBoundryChecked() && !BinaryChecked/*getBinaryChecked()*/)
  4461. matLevel = 0;
  4462. Bitmap bitmap = this.bitmap;
  4463. if (imagesKey != null)
  4464. bitmap = this.appWorkspace.DocumentWorkspaces[analysisPicture].CompositionSurface.CreateAliasedBitmap();
  4465. GSSClass.AddRectangleToRectangleFCaps(imagesKey, grainMethodType, bitmap, (imagesKey != null ? GSSClass.GuideClass.guideDict[imagesKey].oldSelectItem : this.getCurrentGuideName()), matLevel, mat, (analysisPicture == -1 ? getCurrentWorkspace() : this.appWorkspace.DocumentWorkspaces[analysisPicture]).GetRuler(MeasurementUnit.Micron));
  4466. if (analysisPicture == -1 || analysisPicture == this.selectPicture)
  4467. this.documentWorkspace.Refresh();
  4468. }
  4469. /// <summary>
  4470. /// 初始化矩形
  4471. /// </summary>
  4472. private void InitRectangleF(bool guideTypeChanged)
  4473. {
  4474. if (this.matOrg != null && this.comboBox1.SelectedItem != null)
  4475. {
  4476. bool foundItem;
  4477. if (grainMethodType == 1)
  4478. GSSClass.GuideClass.guideModel.RectangleFLine = GSSClass.GuideClass.guideAreaRectLine(this.comboBox1.SelectedItem, out foundItem, guideTypeChanged, getCurrentWorkspace().GetRuler(MeasurementUnit.Micron));
  4479. else
  4480. GSSClass.GuideClass.guideModel.RectangleFLine = GSSClass.GuideClass.guideRectLine(this.comboBox1.SelectedItem, out foundItem, guideTypeChanged, getCurrentWorkspace().GetRuler(MeasurementUnit.Micron));
  4481. //if (foundItem)//#21756
  4482. this.AddRectangleToRectangleFCaps();
  4483. }
  4484. }
  4485. /// <summary>
  4486. /// 更新辅助线及其样式
  4487. /// </summary>
  4488. protected virtual void UpdateGuideStyle(bool showMessageAlert)
  4489. {
  4490. if (getCurrentWorkspace() == null)//#21319
  4491. return;
  4492. if (grainMethodType == 1)
  4493. GSSClass.GuideClass.UpdateGuideAreaStyle(this.bitmap, this.comboBox1.SelectedItem, showMessageAlert && this.comboBox1.SelectedIndex > 0, getCurrentWorkspace().GetRuler(MeasurementUnit.Micron));
  4494. else//##19846
  4495. GSSClass.GuideClass.UpdateGuideStyle(matOrg, this.comboBox1.SelectedItem, showMessageAlert && this.comboBox1.SelectedIndex > 0, getCurrentWorkspace().GetRuler(MeasurementUnit.Micron));
  4496. }
  4497. /// <summary>
  4498. /// 添加辅助线后更新下拉列表信息
  4499. /// </summary>
  4500. /// <param name="arrayList"></param>
  4501. public void AddComboboxValue(ArrayList arrayList)
  4502. {
  4503. if (!GSSClass.InitComboboxValue())
  4504. {
  4505. if (grainMethodType == 1)
  4506. GSSClass.GuideClass.createGuideAreaClassModelsNamed(getModelName());
  4507. else
  4508. GSSClass.GuideClass.createGuideClassModelsNamed(getModelName());
  4509. }
  4510. if (arrayList != null && arrayList.Count > 0)
  4511. {
  4512. this.comboBox1.SelectedIndexChanged -= new System.EventHandler(this.comboBox1_SelectedIndexChanged);
  4513. //this.comboBox1.SelectedItem = (string)ItemStringObject;
  4514. //comboBox1SelectedItem = comboBox1.SelectedItem;
  4515. ////this.comboboxChange = false;
  4516. arrayList.Insert(0, PdnResources.GetString("Menu.Pleaseselecttheauxiliarylineused.text"));
  4517. this.comboBox1.DataSource = arrayList;
  4518. //this.comboboxChange = false;
  4519. int oldSelectIndex = -1;
  4520. for (int i = 0; i < this.comboBox1.Items.Count; i++)
  4521. {
  4522. if (GSSClass.GuideClass.guideModel.oldSelectItem.Equals(this.comboBox1.Items[i]))
  4523. {
  4524. oldSelectIndex = i;
  4525. }
  4526. }
  4527. if (oldSelectIndex > -1)
  4528. this.comboBox1.SelectedIndex = oldSelectIndex;
  4529. else if (this.comboBox1.Items.Count > 0)
  4530. this.comboBox1.SelectedIndex = 0;
  4531. this.comboBox1.SelectedIndexChanged += new System.EventHandler(this.comboBox1_SelectedIndexChanged);
  4532. }
  4533. //this.comboBox1.DataSource =
  4534. }
  4535. /// <summary>
  4536. /// 辅助线维护
  4537. /// </summary>
  4538. public virtual void InitComboboxValue(ArrayList arrayList)
  4539. {
  4540. UpdateCupOffPointStyle();
  4541. if (!GSSClass.InitComboboxValue())
  4542. {
  4543. if (grainMethodType == 1)
  4544. GSSClass.GuideClass.createGuideAreaClassModelsNamed(getModelName());
  4545. else
  4546. GSSClass.GuideClass.createGuideClassModelsNamed(getModelName());
  4547. }
  4548. this.comboBox1.DataSource = null;
  4549. if (arrayList != null && arrayList.Count > 0)
  4550. {
  4551. this.comboboxChange = false;
  4552. arrayList.Insert(0, PdnResources.GetString("Menu.Pleaseselecttheauxiliarylineused.text"));
  4553. this.comboBox1.DataSource = arrayList;
  4554. this.comboboxChange = false;
  4555. int oldSelectIndex = -1;
  4556. for (int i = 0; i < this.comboBox1.Items.Count; i++)
  4557. {
  4558. if (GSSClass.GuideClass.guideModel.oldSelectItem.Equals(this.comboBox1.Items[i]))
  4559. {
  4560. oldSelectIndex = i;
  4561. }
  4562. }
  4563. if (oldSelectIndex > -1)
  4564. this.comboBox1.SelectedIndex = oldSelectIndex;
  4565. else if (this.comboBox1.Items.Count > 0)
  4566. this.comboBox1.SelectedIndex = 0;
  4567. }
  4568. else
  4569. {
  4570. ArrayList arrayList1;
  4571. if (grainMethodType == 1)
  4572. arrayList1 = GSSClass.GuideClass.getComboboxArrayAreaList1();
  4573. else
  4574. arrayList1 = GSSClass.GuideClass.getComboboxArrayList1();
  4575. if (arrayList1.Count > 0)
  4576. {
  4577. this.comboBox1.DataSource = arrayList1;
  4578. this.comboBox1.SelectedIndex = 0;
  4579. }
  4580. }
  4581. UpdateGuideStyle(false);
  4582. this.documentWorkspace.Refresh();
  4583. }
  4584. #endregion
  4585. /// <summary>
  4586. /// 保存参数的key,value和type
  4587. /// </summary>
  4588. /// <param name="param_key"></param>
  4589. /// <param name="param_value"></param>
  4590. /// <param name="param_type"></param>
  4591. protected void saveParamValue(string param_key, string param_value, int param_type)
  4592. {
  4593. bool foundItem = false;
  4594. foreach (var item in this.analysisModel.ListParam)
  4595. {
  4596. if (item.param_key.Equals(param_key) && item.menuId == this.menuId)
  4597. {
  4598. item.param_value = param_value;
  4599. item.setValue();
  4600. foundItem = true;
  4601. break;
  4602. }
  4603. }
  4604. if (!foundItem)
  4605. {
  4606. GrainSizeAnalysisModel analysisItem = new GrainSizeAnalysisModel();
  4607. analysisItem.menuId = this.menuId;
  4608. analysisItem.param_key = param_key;
  4609. analysisItem.param_type = param_type;
  4610. analysisItem.param_value = param_value;
  4611. analysisItem.setValue();
  4612. this.analysisModel.ListParam.Add(analysisItem);
  4613. }
  4614. }
  4615. /// <summary>
  4616. /// 保存界面中的参数到model
  4617. /// </summary>
  4618. private void saveDialogParamValues()
  4619. {
  4620. saveParamValue(ParamKey_ShowGrainNumber, showGrainNumberChecked() ? "0" : "1", (int)Base.Dtryt.Boolean);//显示晶粒编号
  4621. saveParamValue(ParamKey_ShowGrainColor, ShowGrainColorChecked() ? "0" : "1", (int)Base.Dtryt.Boolean);//用不同颜色显示晶粒
  4622. saveParamValue(ParamKey_displaygrainboundaries, ShowGrainBoundryChecked() ? "0" : "1", (int)Base.Dtryt.Boolean);//显示晶界
  4623. saveParamValue(ParamKey_displaygrid, showGridChecked() ? "0" : "1", (int)Base.Dtryt.Boolean);//显示网格
  4624. saveParamValue(ParamKey_displaysections, drawDisplaySections() ? "0" : "1", (int)Base.Dtryt.Boolean);//显示截点
  4625. saveParamValue(ParamKey_comboBox1SelectedItem, comboBox1SelectedItem != null ? comboBox1SelectedItem.ToString() : "", (int)Base.Dtryt.ItemString);//选择的辅助线
  4626. saveParamValue(ParamKey_CalculatorDecimalDigits, Convert.ToInt32(this.numericUpDown1_0.Value).ToString(), (int)Base.Dtryt.Interger);
  4627. saveParamValue(ParamKey_OpenWhileExportReport, this.checkBox_generateReport_opensetting.Checked ? "0" : "1", (int)Base.Dtryt.Boolean);//生成报告时打开设置
  4628. saveParamValue(ParamKey_TargetSelection, this.TargetSelection.ToString(), (int)Base.Dtryt.Interger);
  4629. saveSonData();
  4630. }
  4631. private void GrainSizeStandardDialog_FormClosing(object sender, FormClosingEventArgs e)
  4632. {
  4633. #region [开启脚本录制]
  4634. if (appWorkspace.startScriptRecording)
  4635. {
  4636. getScriptRecording();
  4637. }
  4638. #endregion
  4639. this.saveDialogParamValues();
  4640. binaryClass.saveParams();
  4641. //xml保存路径
  4642. string filePath = Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\GrainSizeAnalyze\\GrainSizeAnalysisModel.xml";
  4643. GrainSizeAnalysisModel analysisModelXml = XmlSerializeHelper.DESerializer<GrainSizeAnalysisModel>(FileOperationHelper.ReadStringFromFile(filePath, System.IO.FileMode.Open));
  4644. foreach (var analysisItem in this.analysisModel.ListParam)
  4645. {
  4646. bool foundItem = false;
  4647. foreach (var item in analysisModelXml.ListParam)
  4648. {
  4649. if (item.param_key.Equals(analysisItem.param_key) && item.menuId == this.menuId)
  4650. {
  4651. item.param_value = analysisItem.param_value;
  4652. foundItem = true;
  4653. break;
  4654. }
  4655. }
  4656. if (!foundItem)
  4657. {
  4658. GrainSizeAnalysisModel newMod = analysisItem.cloneModel();
  4659. newMod.value = null;//避免value为集合导致保存出错
  4660. analysisModelXml.ListParam.Add(newMod);
  4661. }
  4662. //analysisModelXml.ListParam.Add(analysisItem.cloneModel());
  4663. }
  4664. //按路径和名称保存xml文件
  4665. string userInfoXml = XmlSerializeHelper.XmlSerialize<GrainSizeAnalysisModel>(analysisModelXml);
  4666. //保存xml
  4667. FileOperationHelper.WriteStringToFile(userInfoXml, filePath, System.IO.FileMode.Create);
  4668. }
  4669. /// <summary>
  4670. /// 应用到全部
  4671. /// </summary>
  4672. /// <param name="sender"></param>
  4673. /// <param name="e"></param>
  4674. private void button_ApplyToAll_Click(object sender, EventArgs e)
  4675. {
  4676. if ((this.menuId != 11012101 && this.menuId != 11012102) && (this.comboBox1.SelectedItem == null || PdnResources.GetString("Menu.Pleaseselecttheauxiliarylineused.text").Equals(this.comboBox1.SelectedItem)))
  4677. {
  4678. MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectauxiliaryline.text") + "!");
  4679. return;
  4680. }
  4681. //清空晶界重现除了当前图片之外的缓存数据
  4682. foreach (var itemKey in this.imageList_img.Images.Keys)
  4683. {
  4684. if (itemKey.Equals(getCurrentWorkTag()))
  4685. continue;
  4686. if (this.grainBoundaryMatDict.ContainsKey(itemKey))
  4687. this.grainBoundaryMatDict.Remove(itemKey);
  4688. if (this.grainBoundaryDict.ContainsKey(itemKey))
  4689. this.grainBoundaryDict.Remove(itemKey);
  4690. }
  4691. binaryClass.applyToAll(this.imageList_img.Images.Keys, getCurrentWorkTag());
  4692. this.saveDialogParamValues();
  4693. this.lstView_img.SelectedIndexChanged -= new System.EventHandler(this.lstView_img_SelectedIndexChanged);
  4694. try
  4695. {
  4696. currentOldSelectIndex = this.selectPicture;
  4697. for (int kselectPicture = 0; kselectPicture <= this.appWorkspace.DocumentWorkspaces.Count(); kselectPicture++)
  4698. {
  4699. if (currentOldSelectIndex == kselectPicture || kselectPicture == this.appWorkspace.DocumentWorkspaces.Count())
  4700. {//跳过当前选择的窗口,并最后回到当前窗口数据
  4701. if (kselectPicture == this.appWorkspace.DocumentWorkspaces.Count())
  4702. {
  4703. kselectPicture = currentOldSelectIndex;
  4704. this.analysisModel = this.analysisDict[this.imageList_img.Images.Keys[kselectPicture]];
  4705. string imagesKeyCurrent = this.imageList_img.Images.Keys[kselectPicture];
  4706. GSSClass.standardModel = GSSClass.standardDict[imagesKeyCurrent];
  4707. GSSClass.GuideClass.guideModel = GSSClass.GuideClass.guideDict[imagesKeyCurrent];
  4708. GSSClass.styleClass.styleModel = GSSClass.styleClass.styleDict[imagesKeyCurrent];
  4709. this.lstView_img.EnsureVisible(kselectPicture);
  4710. this.lstView_img.Items[kselectPicture].Focused = true;
  4711. this.lstView_img.Items[kselectPicture].Selected = true;
  4712. this.refreshActionWhileImg_SelectedIndexChanged(true, kselectPicture/*this.selectPicture*/);
  4713. break;
  4714. }
  4715. continue;
  4716. }
  4717. if (this.analysisDict.ContainsKey(this.imageList_img.Images.Keys[kselectPicture]))
  4718. this.analysisDict[this.imageList_img.Images.Keys[kselectPicture]] = this.analysisModel.cloneListParamModel(this.menuId);
  4719. string imagesKey = this.imageList_img.Images.Keys[kselectPicture];
  4720. if (GSSClass.standardDict.ContainsKey(imagesKey))
  4721. GSSClass.standardDict[imagesKey] = new GrainSizeStandardModel();// GSSClass.standardModel.cloneListParamModel();
  4722. if (GSSClass.GuideClass.guideDict.ContainsKey(imagesKey))
  4723. GSSClass.GuideClass.guideDict[imagesKey] = GSSClass.GuideClass.guideModel.cloneModel/*cloneListParamModel*/();
  4724. if (GSSClass.styleClass.styleDict.ContainsKey(imagesKey))
  4725. GSSClass.styleClass.styleDict[imagesKey] = GSSClass.styleClass.styleModel.cloneListParamModel();
  4726. this.lstView_img.EnsureVisible(kselectPicture);
  4727. this.lstView_img.Items[kselectPicture].Focused = true;
  4728. this.lstView_img.Items[kselectPicture].Selected = true;
  4729. this.refreshActionWhileImg_SelectedIndexChanged(true, kselectPicture/*this.selectPicture*/);
  4730. }
  4731. }
  4732. catch (Exception ex)
  4733. {
  4734. }
  4735. finally
  4736. {
  4737. this.lstView_img.SelectedIndexChanged += new System.EventHandler(this.lstView_img_SelectedIndexChanged);
  4738. }
  4739. }
  4740. /// <summary>
  4741. /// 保存全部
  4742. /// </summary>
  4743. /// <param name="sender"></param>
  4744. /// <param name="e"></param>
  4745. private void button_SaveAll_Click(object sender, EventArgs e)
  4746. {
  4747. if (this.imageList_img.Images.Keys.Count <= 1)
  4748. {
  4749. this.btn_saveresult.PerformClick();
  4750. return;
  4751. }
  4752. for (int kselectPicture = 0; kselectPicture < this.appWorkspace.DocumentWorkspaces.Count(); kselectPicture++)
  4753. {
  4754. string imagesKey = /*toDeleteImageKeysList*/this.imageList_img.Images.Keys[kselectPicture];
  4755. //string imagesKey = kselectPicture.ToString();
  4756. if (!this.GSSClass.GuideClass.guideDict.ContainsKey(imagesKey))
  4757. {
  4758. MessageBox.Show("请先应用到全部图片后进行保存全部操作"/* “或者计算每个图片数据后”PdnResources.GetString("Menu.Pleaseselectauxiliaryline.text") + "!"*/);
  4759. return;
  4760. }
  4761. }
  4762. bool replace = false;
  4763. int add = 0;
  4764. //#22510 -> 确定则全部替换,点击取消则只更新没有的结果已存在的不更新
  4765. List<string> toDeleteImageKeysList = new List<string>();
  4766. for (int kselectPicture = 0; kselectPicture < this.imageList_img.Images.Keys.Count; kselectPicture++)
  4767. toDeleteImageKeysList.Add(this.imageList_img.Images.Keys[kselectPicture]);
  4768. for (int itemI = 0; itemI < this.listView2.Items.Count; itemI++)
  4769. {
  4770. ListViewItem item = this.listView2.Items[itemI];
  4771. //if (item.Tag.Equals(imagesKey))
  4772. if (this.imageList_img.Images.Keys.Contains(item.Tag.ToString()))
  4773. {
  4774. add++;
  4775. if (itemI == 0)
  4776. {
  4777. DialogResult dr = MessageBox.Show(PdnResources.GetString("Menu.Theresuethertoreplace.text") + "?" /*+ "\n确定则全部替换,取消则跳过已保存的结果"*/, PdnResources.GetString("Menu.hint.text"), MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
  4778. if (dr != DialogResult.OK)
  4779. {
  4780. //toDeleteImageKeysList.Clear();
  4781. replace = false;
  4782. }
  4783. else
  4784. {
  4785. replace = true;
  4786. break;
  4787. }
  4788. }
  4789. toDeleteImageKeysList.Remove(item.Tag.ToString());
  4790. }
  4791. }
  4792. if (toDeleteImageKeysList.Count == 0 && !replace && this.listView2.Items.Count > 0 && add > 0)
  4793. return;
  4794. for (int kselectPicture = 0; kselectPicture < toDeleteImageKeysList.Count; kselectPicture++)
  4795. {
  4796. //for (int kselectPicture = 0; kselectPicture < this.appWorkspace.DocumentWorkspaces.Count(); kselectPicture++)
  4797. //{
  4798. string imagesKey = toDeleteImageKeysList/*this.imageList_img.Images.Keys*/[kselectPicture];
  4799. if (!this.GSSClass.GuideClass.guideDict.ContainsKey(imagesKey))
  4800. {
  4801. MessageBox.Show("请先应用到全部图片后进行保存全部操作"/* “或者计算每个图片数据后”PdnResources.GetString("Menu.Pleaseselectauxiliaryline.text") + "!"*/);
  4802. return;
  4803. }
  4804. }
  4805. if (replace)
  4806. {
  4807. this.dataGridView_Total.Rows.Clear();
  4808. }
  4809. //#22510 -> 确定则全部替换,点击取消则只更新没有的结果已存在的不更新
  4810. for (int k = 0; k < toDeleteImageKeysList.Count; k++)
  4811. //for (int k = 0; k < this.appWorkspace.DocumentWorkspaces.Count(); k++)
  4812. buildListBox_analysisResult(toDeleteImageKeysList[k], this.imageList_img.Images.Keys.IndexOf(toDeleteImageKeysList[k]), true);
  4813. if (this.documentWorkspace.PhaseModels[2].mat != null && this.documentWorkspace.PhaseModels[2].mat.IsDisposed && this.grainColorsMatDict.ContainsKey(getCurrentWorkTag()))
  4814. {
  4815. this.documentWorkspace.PhaseModels[2].mat = this.grainColorsMatDict[getCurrentWorkTag()];
  4816. this.documentWorkspace.Refresh();
  4817. }
  4818. }
  4819. /// <summary>
  4820. /// 刷新图片效果和数据时调用该方法
  4821. /// </summary>
  4822. /// <param name="applyingToAll"></param>
  4823. private void refreshActionWhileImg_SelectedIndexChanged(bool applyingToAll, int toSelectIndex = -1)
  4824. {
  4825. GSSClass.styleClass.PointKb = 0;//##21997
  4826. this.saveDialogParamValues();
  4827. this.binaryClass.saveMat(this.imageList_img.Images.Keys[this.selectPicture]);
  4828. //备份第一个显示图片的数据信息到dict中
  4829. if (GSSClass.GuideClass.guideDict.Count == 0 && this.selectPicture >= 0 && this.selectPicture < this.imageList_img.Images.Keys.Count
  4830. && !GSSClass.GuideClass.guideDict.ContainsKey(this.imageList_img.Images.Keys[this.selectPicture]))
  4831. GSSClass.GuideClass.guideDict.Add(this.imageList_img.Images.Keys[this.selectPicture], GSSClass.GuideClass.guideModel);
  4832. if (GSSClass.styleClass.styleDict.Count == 0 && this.selectPicture >= 0 && this.selectPicture < this.imageList_img.Images.Keys.Count
  4833. && !GSSClass.styleClass.styleDict.ContainsKey(this.imageList_img.Images.Keys[this.selectPicture]))
  4834. GSSClass.styleClass.styleDict.Add(this.imageList_img.Images.Keys[this.selectPicture], GSSClass.styleClass.styleModel);
  4835. if (GSSClass.standardDict.Count == 0 && this.selectPicture >= 0 && this.selectPicture < this.imageList_img.Images.Keys.Count
  4836. && !GSSClass.standardDict.ContainsKey(this.imageList_img.Images.Keys[this.selectPicture]))
  4837. GSSClass.standardDict.Add(this.imageList_img.Images.Keys[this.selectPicture], GSSClass.standardModel);
  4838. if (toSelectIndex >= 0/*applyingToAll*/)
  4839. this.bitmap = this.appWorkspace.DocumentWorkspaces[toSelectIndex].CompositionSurface.CreateAliasedBitmap();
  4840. else
  4841. this.bitmap = this.appWorkspace.DocumentWorkspaces[this.lstView_img.FocusedItem.Index].CompositionSurface.CreateAliasedBitmap();
  4842. matOrg = OpenCvSharp.Extensions.BitmapConverter.ToMat(bitmap);
  4843. string toSelectImageKey = getCurrentWorkTag();
  4844. if (toSelectIndex >= 0)
  4845. toSelectImageKey = this.imageList_img.Images.Keys[toSelectIndex];
  4846. if (!this.analysisDict.ContainsKey(toSelectImageKey))
  4847. this.analysisDict.Add(toSelectImageKey, this.analysisModel.cloneListParamModel(this.menuId));
  4848. //else
  4849. // this.analysisDict[getCurrentWorkTag()] = this.analysisModel.cloneListParamModel(this.menuId);
  4850. this.analysisModel = this.analysisDict[toSelectImageKey];
  4851. bool existGuideModel = true;
  4852. if (!GSSClass.GuideClass.guideDict.ContainsKey(toSelectImageKey))
  4853. {
  4854. if (/*toSelectIndex >= 0 && */GSSClass.GuideClass.guideModel.oldSelectItem == null && this.comboBox1.SelectedItem != null)
  4855. GSSClass.GuideClass.guideModel.oldSelectItem = (string)this.comboBox1.SelectedItem;
  4856. GSSClass.GuideClass.guideDict.Add(toSelectImageKey, GSSClass.GuideClass.guideModel.cloneModel());
  4857. existGuideModel = false;
  4858. }
  4859. GSSClass.GuideClass.guideModel = GSSClass.GuideClass.guideDict[toSelectImageKey];
  4860. if (toSelectIndex >= 0 && this.comboBox1.SelectedItem != null)
  4861. GSSClass.GuideClass.guideModel.oldSelectItem = (string)this.comboBox1.SelectedItem;
  4862. if (!GSSClass.styleClass.styleDict.ContainsKey(toSelectImageKey))
  4863. GSSClass.styleClass.styleDict.Add(toSelectImageKey, GSSClass.styleClass.styleModel.cloneModel());
  4864. GSSClass.styleClass.styleModel = GSSClass.styleClass.styleDict[toSelectImageKey];
  4865. if (!GSSClass.standardDict.ContainsKey(toSelectImageKey))
  4866. GSSClass.standardDict.Add(toSelectImageKey, GSSClass.standardModel.cloneModel());
  4867. GSSClass.standardModel = GSSClass.standardDict[toSelectImageKey];
  4868. //二值化集成4
  4869. if (ShowDrawClassView())
  4870. binaryClass.listView1_SelectedIndexChanged(this.bitmap);
  4871. else
  4872. binaryClass.listView1_SelectedIndexChangedHideDrawClassView(this.bitmap, toSelectImageKey);//###21974
  4873. //晶界重现
  4874. if (this.selectPicture >= 0 && this.selectPicture < this.imageList_img.Images.Keys.Count
  4875. && this.grainBoundaryDict.ContainsKey(this.imageList_img.Images.Keys[this.selectPicture])
  4876. && !this.grainBoundaryDict.ContainsKey(toSelectImageKey))
  4877. {//如果首次切换到该图片,或者点击了应用到全部,则将参数赋值
  4878. this.grainBoundaryDict.Add(toSelectImageKey, this.grainBoundaryDict[this.imageList_img.Images.Keys[this.selectPicture]].cloneModel());
  4879. }
  4880. if (toSelectIndex >= 0/*applyingToAll*/)
  4881. this.selectPicture = toSelectIndex;
  4882. else
  4883. this.selectPicture = this.lstView_img.FocusedItem.Index;
  4884. //选择了应用晶界重现但是没有计算结果,则进行晶界重现的计算
  4885. if (this.grainBoundaryDict.ContainsKey(toSelectImageKey) && this.grainBoundaryDict[toSelectImageKey].grainApplygrainboundaries == 1
  4886. && !this.grainBoundaryMatDict.ContainsKey(toSelectImageKey))
  4887. {
  4888. procClass = new ProgressThreadProcClass();
  4889. procClass.StartProgressAutoAction(this, new System.Threading.ThreadStart(applyDectAction), PdnResources.GetString("Menu.Grainboundarytoreproduce.text"));
  4890. }
  4891. if (this.grainBoundaryMatDict.ContainsKey(toSelectImageKey))
  4892. {
  4893. this.documentWorkspace.PhaseModels[1].mat = this.grainBoundaryMatDict[toSelectImageKey].Clone();
  4894. this.documentWorkspace.PhaseModels[1].choise = (!bcOriginChecked() && getGrainBoundryChecked() && ShowGrainBoundryChecked());
  4895. }
  4896. else
  4897. this.documentWorkspace.PhaseModels[1].mat = null;
  4898. if (grainMethodType == 1)
  4899. {
  4900. if (this.grainColorsMatDict.ContainsKey(toSelectImageKey))
  4901. {
  4902. this.documentWorkspace.PhaseModels[2].mat = this.grainColorsMatDict[toSelectImageKey].Clone();
  4903. this.documentWorkspace.PhaseModels[2].choise = (!bcOriginChecked() && ShowGrainColorChecked());
  4904. }
  4905. else
  4906. this.documentWorkspace.PhaseModels[2].mat = null;
  4907. }
  4908. if (existGuideModel && !applyingToAll)//显示已经存在的数据即可,除非(还差应用到全部的信息没有处理),否则不必刷新
  4909. {
  4910. try
  4911. {
  4912. object ItemStringObject;
  4913. if (GetParamValue1(ParamKey_comboBox1SelectedItem, out ItemStringObject))//切换选择的辅助线类型,以及需要备份和读取数据
  4914. {
  4915. this.comboBox1.SelectedIndexChanged -= new System.EventHandler(this.comboBox1_SelectedIndexChanged);
  4916. this.comboBox1.SelectedItem = (string)ItemStringObject;
  4917. comboBox1SelectedItem = comboBox1.SelectedItem;
  4918. this.comboBox1.SelectedIndexChanged += new System.EventHandler(this.comboBox1_SelectedIndexChanged);
  4919. }
  4920. }
  4921. catch (Exception exc)
  4922. {
  4923. System.Console.WriteLine("this.comboBox1.SelectedItem: " + exc.ToString());
  4924. }
  4925. this.documentWorkspace.Refresh();
  4926. refreshWhileImgChanged();
  4927. return;
  4928. }
  4929. DocumentWorkspace toSelectDocumentWorkspace = toSelectIndex >= 0 ? this.appWorkspace.DocumentWorkspaces[toSelectIndex] : getCurrentWorkspace();
  4930. if (this.comboBox1.DataSource != null && this.comboBox1.SelectedIndex >= 0)
  4931. {
  4932. float recWidth = (float)(Math.Max(1, GSSClass.GuideClass.guideModel.rectangleFLineWidth / getCurrentWorkspace().GetRuler(MeasurementUnit.Micron)));
  4933. float recHeight = (float)(Math.Max(1, GSSClass.GuideClass.guideModel.rectangleFLineHeight / getCurrentWorkspace().GetRuler(MeasurementUnit.Micron)));
  4934. double multiple = 1.0;
  4935. if (recWidth > this.documentWorkspace.CompositionSurface.Width)
  4936. {
  4937. multiple = this.documentWorkspace.CompositionSurface.Width / recWidth;
  4938. }
  4939. if (this.documentWorkspace.CompositionSurface.Height < recHeight * multiple)//#21714
  4940. {
  4941. multiple = this.documentWorkspace.CompositionSurface.Height / recHeight;
  4942. }
  4943. GSSClass.GuideClass.guideModel.rectangleFLineWidth = (float)(multiple * GSSClass.GuideClass.guideModel.rectangleFLineWidth);
  4944. GSSClass.GuideClass.guideModel.rectangleFLineHeight = (float)(multiple * GSSClass.GuideClass.guideModel.rectangleFLineHeight);
  4945. if (grainMethodType == 1)//#21714
  4946. GSSClass.GuideClass.UpdateScaleGuideAreaStyle((this.comboBox1.DataSource != null && this.comboBox1.SelectedIndex >= 0 && this.comboBox1.SelectedItem != null) ? this.comboBox1.SelectedItem : "", GSSClass.GuideClass.guideModel
  4947. , multiple);
  4948. else
  4949. GSSClass.GuideClass.UpdateScaleGuideStyle((this.comboBox1.DataSource != null && this.comboBox1.SelectedIndex >= 0 && this.comboBox1.SelectedItem != null) ? this.comboBox1.SelectedItem : "", GSSClass.GuideClass.guideModel, recWidth, recHeight
  4950. , toSelectDocumentWorkspace.GetRuler(MeasurementUnit.Micron), multiple);
  4951. }
  4952. GSSClass.GuideClass.guideModel.loctation = new PointF(this.documentWorkspace.CompositionSurface.Width / 2, this.documentWorkspace.CompositionSurface.Height / 2);
  4953. if (this.comboBox1.DataSource != null && this.comboBox1.SelectedIndex >= 0)
  4954. {
  4955. //UpdateGuideStyle(false);
  4956. float recWidth = (float)(Math.Max(1, GSSClass.GuideClass.guideModel.rectangleFLineWidth / toSelectDocumentWorkspace.GetRuler(MeasurementUnit.Micron)));
  4957. float recHeight = (float)(Math.Max(1, GSSClass.GuideClass.guideModel.rectangleFLineHeight / toSelectDocumentWorkspace.GetRuler(MeasurementUnit.Micron)));
  4958. GSSClass.GuideClass.guideModel.RectangleFLine = new RectangleF(GSSClass.GuideClass.guideModel.loctation.X - recWidth/*GSSClass.GuideClass.RectangleFLine.Width*/ / 2
  4959. , GSSClass.GuideClass.guideModel.loctation.Y - recHeight/*GSSClass.GuideClass.RectangleFLine.Height*/ / 2
  4960. , recWidth/*GSSClass.GuideClass.RectangleFLine.Width*/, recHeight/*GSSClass.GuideClass.RectangleFLine.Height*/);
  4961. bool foundItem = false;
  4962. if (grainMethodType == 1)
  4963. {
  4964. if (this.matOrg != null && this.comboBox1.SelectedItem != null)
  4965. GSSClass.GuideClass.updateGuideAreaRectLine(this.comboBox1.SelectedItem, GSSClass.GuideClass.guideModel, out foundItem, true/*guideTypeChanged*/, toSelectDocumentWorkspace.GetRuler(MeasurementUnit.Micron));
  4966. }
  4967. else
  4968. if (this.matOrg != null && this.comboBox1.SelectedItem != null)
  4969. GSSClass.GuideClass.updateGuideRectLine(this.comboBox1.SelectedItem, GSSClass.GuideClass.guideModel, out foundItem, true/*guideTypeChanged*/, toSelectDocumentWorkspace.GetRuler(MeasurementUnit.Micron));
  4970. /////*this.*/
  4971. ////GSSClass.GuideClass.updateRectangleSize(getCurrentWorkspace().GetRuler(MeasurementUnit.Micron)/*physical_Micron*/);
  4972. if (foundItem)
  4973. AddRectangleToRectangleFCaps();
  4974. //this.documentWorkspace.Refresh();
  4975. }
  4976. else
  4977. InitRectangleF(false);
  4978. refreshWhileImgChanged();//#################################################应用到全部时候计算其他图片不需要刷新界面参数信息?
  4979. //InitComboboxValue(null);
  4980. try
  4981. {
  4982. object ItemStringObject;
  4983. if (GetParamValue1(ParamKey_comboBox1SelectedItem, out ItemStringObject))//切换选择的辅助线类型,以及需要备份和读取数据
  4984. this.comboBox1.SelectedItem = (string)ItemStringObject;
  4985. }
  4986. catch (Exception exc)
  4987. {
  4988. System.Console.WriteLine("this.comboBox1.SelectedItem: " + exc.ToString());
  4989. }
  4990. UpdateGuideStyle(!applyingToAll);
  4991. if (this.bitmap != null)
  4992. {
  4993. GSSClass.GuideClass.guideModel.loctation = new PointF(this.documentWorkspace.CompositionSurface.Width / 2, this.documentWorkspace.CompositionSurface.Height / 2);
  4994. InitRectangleF(true);
  4995. }
  4996. this.documentWorkspace.Refresh();
  4997. }
  4998. /// <summary>
  4999. /// 3D效果,正十四面体预览
  5000. /// </summary>
  5001. /// <param name="sender"></param>
  5002. /// <param name="e"></param>
  5003. private void threeDButton_Click(object sender, EventArgs e)
  5004. {
  5005. if (RegularTetrahedron3D.GetStatus() > 0 && value_111 > 1)
  5006. {
  5007. RegularTetrahedron3D.UpdateRun(Math.Min(value_111, 200));
  5008. return;
  5009. }
  5010. if (value_111 > 1)
  5011. RegularTetrahedron3D.Run(Math.Min(value_111, 200));
  5012. else
  5013. RegularTetrahedron3D.Run(50/*this.appWorkspace*/);
  5014. }
  5015. private void applyDectAction()
  5016. {
  5017. string toSelectImageKey = this.imageList_img.Images.Keys[this.selectPicture];
  5018. OrgImg0 = GrainBoundaryEditingDialog.runDect(grainBoundaryDict[toSelectImageKey].m_iStandardImage, grainBoundaryDict[toSelectImageKey].iConnect, Color.FromArgb(grainBoundaryDict[toSelectImageKey].grainColor) /*Color.Red*//*this.panel1.BackColor*/, OpenCvSharp.Extensions.BitmapConverter.ToMat(this.bitmap)/*matOrg*//*OrgImg*/, grainBoundaryDict[toSelectImageKey].dark, grainBoundaryDict[toSelectImageKey].smooth_type, grainBoundaryDict[toSelectImageKey].sigma, grainBoundaryDict[toSelectImageKey].enhance
  5019. , new double[] { grainBoundaryDict[toSelectImageKey].cell1_size, grainBoundaryDict[toSelectImageKey].cell2_size});
  5020. this.grainBoundaryMatDict.Add(toSelectImageKey, OrgImg0);
  5021. if (procClass != null) procClass.DismissProgressAction(this);
  5022. }
  5023. #region [脚本录制]
  5024. private void getScriptRecording()
  5025. {
  5026. string className = InvariantData.path_Action + ".Action" + menuId;
  5027. ParamObject param = (ParamObject)System.Reflection.Assembly.Load(InvariantData.assembly_Data).CreateInstance(className);
  5028. List<Args> args = param.Lists;
  5029. string xmlFilePath = Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\GrainSizeAnalyze\\GrainBoundryDectModel_" + this.menuId + ".xml";
  5030. if (System.IO.File.Exists(xmlFilePath))
  5031. {
  5032. GrainBoundryDectModel = Base.CommTool.XmlSerializeHelper.DESerializer<Base.SettingModel.GrainBoundryDectModel>(Base.CommTool.FileOperationHelper.ReadStringFromFile(xmlFilePath, System.IO.FileMode.Open));
  5033. }
  5034. foreach (var item in args)
  5035. {
  5036. item.value = setScriptRecording(item.key);
  5037. }
  5038. //找出二值相关参数 进行赋值
  5039. List<Args> isNullList = args.Where(m => m.value == null).ToList();
  5040. foreach (var item in isNullList)
  5041. {
  5042. item.value = binaryClass.setScriptRecording(item.key);
  5043. }
  5044. isNullList = args.Where(m => m.value == null).ToList();
  5045. foreach (var item in isNullList)
  5046. {
  5047. item.value = saveRecordingData(item.key);
  5048. }
  5049. appWorkspace.SetScriptStartRecording(this.menuId, menuName, args);
  5050. }
  5051. private object setScriptRecording(string key)
  5052. {
  5053. object value = null;
  5054. switch (key)
  5055. {
  5056. case "ShowGrainNumber":
  5057. value = showGrainNumberChecked();
  5058. break;
  5059. case "ShowGrainColor":
  5060. value = ShowGrainColorChecked();
  5061. break;
  5062. case "displaygrainboundaries":
  5063. value = ShowGrainBoundryChecked();
  5064. break;
  5065. case "displaygrid":
  5066. value = showGridChecked();
  5067. break;
  5068. case "displaysections":
  5069. value = drawDisplaySections();
  5070. break;
  5071. case "comboBox1SelectedItem":
  5072. value = comboBox1SelectedItem;
  5073. break;
  5074. case "CalculatorDecimalDigits":
  5075. value = Convert.ToInt32(this.numericUpDown1_0.Value);
  5076. break;
  5077. case "OpenWhileExportReport":
  5078. value = this.checkBox_generateReport_opensetting.Checked;
  5079. break;
  5080. case "TargetSelection":
  5081. value = this.TargetSelection;
  5082. break;
  5083. case "ExportResults":
  5084. value = false;
  5085. break;
  5086. case "ExportReports":
  5087. value = false;
  5088. break;
  5089. case "ExportProjects":
  5090. value = false;
  5091. break;
  5092. case "GrainApplygrainboundaries":
  5093. value = GrainBoundryDectModel == null ? 0 : GrainBoundryDectModel.grainApplygrainboundaries;
  5094. break;
  5095. case "lineColor":
  5096. value = GrainBoundryDectModel == null ? Color.Red.ToArgb() : GrainBoundryDectModel.grainColor;
  5097. break;
  5098. case "GrainIConnect":
  5099. value = GrainBoundryDectModel == null ? 0 : GrainBoundryDectModel.iConnect;
  5100. break;
  5101. case "GrainDisplaysections":
  5102. value = GrainBoundryDectModel == null ? false : GrainBoundryDectModel.enhance == 1 ? true : false;
  5103. break;
  5104. case "GrainSigma":
  5105. value = GrainBoundryDectModel == null ? 0 : GrainBoundryDectModel.sigma;
  5106. break;
  5107. case "GrainCell_size1":
  5108. value = GrainBoundryDectModel == null ? new List<double>() { 0, 0 } : new List<double>() { GrainBoundryDectModel.cell1_size, GrainBoundryDectModel.cell2_size };
  5109. break;
  5110. case "GrainDark":
  5111. value = GrainBoundryDectModel == null ? 0 : GrainBoundryDectModel.dark;
  5112. break;
  5113. case "GrainSmooth_type":
  5114. value = GrainBoundryDectModel == null ? 0 : GrainBoundryDectModel.smooth_type;
  5115. break;
  5116. case "GrainM_iStandardImage":
  5117. value = GrainBoundryDectModel == null ? 0 : GrainBoundryDectModel.m_iStandardImage;
  5118. break;
  5119. }
  5120. return value;
  5121. }
  5122. #endregion
  5123. }
  5124. }