GrainSizeStandardDialog.cs 273 KB

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