MicrostructureBandDialog.cs 265 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397
  1. using OpenCvSharp;
  2. using OpenCvSharp.Extensions;
  3. using PaintDotNet.Annotation.Enum;
  4. using PaintDotNet.Base;
  5. using PaintDotNet.Base.CommTool;
  6. using PaintDotNet.Base.Enum;
  7. using PaintDotNet.Base.Functionodel;
  8. using PaintDotNet.Base.SettingModel;
  9. using PaintDotNet.CustomControl;
  10. using PaintDotNet.Data.Param;
  11. using PaintDotNet.DbOpreate.DbBll;
  12. using PaintDotNet.DbOpreate.DbModel;
  13. using System;
  14. using System.Collections;
  15. using System.Collections.Generic;
  16. using System.ComponentModel;
  17. using System.Data;
  18. using System.Drawing;
  19. using System.IO;
  20. using System.Linq;
  21. using System.Text;
  22. using System.Threading.Tasks;
  23. using System.Windows.Forms;
  24. using Point = System.Drawing.Point;
  25. using static PaintDotNet.Base.DedicatedAnalysis.Inclusions.MethodOfAssessment;
  26. using PaintDotNet.Annotation;
  27. using Application = System.Windows.Forms.Application;
  28. using Button = System.Windows.Forms.Button;
  29. using CheckBox = System.Windows.Forms.CheckBox;
  30. using DataTable = System.Data.DataTable;
  31. using GroupBox = System.Windows.Forms.GroupBox;
  32. using Label = System.Windows.Forms.Label;
  33. using Rectangle = System.Drawing.Rectangle;
  34. using TextBox = System.Windows.Forms.TextBox;
  35. using Microsoft.Office.Interop.Excel;
  36. using PaintDotNet.Instrument;
  37. using Metis.ParameterSet;
  38. namespace PaintDotNet.DedicatedAnalysis.QuantitativeAnalysis
  39. {
  40. /// <summary>
  41. /// 显微结构带状物
  42. /// </summary>
  43. internal class MicrostructureBandDialog : PdnBaseForm
  44. {
  45. #region 控件
  46. private GroupBox groupBox1;
  47. private Button button2;
  48. private Label label1;
  49. private Button button6;
  50. private Button button5;
  51. private Button button4;
  52. private Button button3;
  53. private ComboBox comboBox1;
  54. private ListView listView1;
  55. private GroupBox groupBox2;
  56. private ImageList imageList1;
  57. private IContainer components;
  58. private GroupBox groupBox8;
  59. private ListView listView2;
  60. private NumericUpDown numericUpDown1;
  61. private Button button16;
  62. private Label label5;
  63. private Button button14;
  64. private Button button13;
  65. private DataGridView dataGridView4;
  66. private Button button12;
  67. private Button button11;
  68. private GroupBox groupBox7;
  69. private GroupBox groupBox4;
  70. private Label label12;
  71. private Label label11;
  72. private Label label10;
  73. private Label label9;
  74. private Label label8;
  75. private Label label7;
  76. private CheckBox checkBox2;
  77. private TextBox textBox5;
  78. private TextBox textBox4;
  79. private TextBox textBox3;
  80. private TextBox textBox2;
  81. private NumericUpDown numericUpDown4;
  82. private GroupBox groupBox10;
  83. private GroupBox groupBox11;
  84. private Label label18;
  85. private RadioButton rb_leftNoFill;
  86. private RadioButton rb_leftFill;
  87. private Panel panel1;
  88. private Label label19;
  89. private TextBox txt_LeftLineWeight;
  90. private Label label20;
  91. private TextBox txt_LeftSize;
  92. private Label label21;
  93. private RadioButton rb_LeftSquare;
  94. private RadioButton rb_LeftCircle;
  95. private Label label22;
  96. private GroupBox groupBox9;
  97. private DataGridView dataGridView1;
  98. private Button button1;
  99. private CheckBox checkBox3;
  100. private Panel panel4;
  101. private Button button7;
  102. #endregion
  103. /// <summary>
  104. /// 切换图片
  105. /// </summary>
  106. private bool init = true;
  107. /// <summary>
  108. /// 处理程序
  109. /// </summary>
  110. private ParamObject action = new Data.Action.Action1010();
  111. /// <summary>
  112. /// 选中图片的mat
  113. /// </summary>
  114. private Mat imageMat;
  115. /// <summary>
  116. /// 存在视场标记
  117. /// </summary>
  118. private bool existViewFlag = false;
  119. /// <summary>
  120. /// 是否选择了图片
  121. /// </summary>
  122. private bool selectPicture = false;
  123. /// <summary>
  124. /// 参数下拉的集合
  125. /// </summary>
  126. private List<string> files = new List<string>();
  127. /// <summary>
  128. /// 当前选择的图片
  129. /// </summary>
  130. private Mat mat;
  131. /// <summary>
  132. /// 主控件
  133. /// </summary>
  134. private AppWorkspace appWorkspace;
  135. /// <summary>
  136. /// 中间数据
  137. /// </summary>
  138. private List<ExportProjectModel> tempDataModel = new List<ExportProjectModel>();
  139. /// <summary>
  140. /// 结果数据
  141. /// </summary>
  142. DataTable tableResult = new DataTable();
  143. /// <summary>
  144. /// 数据变化
  145. /// </summary>
  146. private bool saveSuccess = false;
  147. /// <summary>
  148. /// 所有截点
  149. /// </summary>
  150. public List<RectangleF> p1RectangleFs = new List<RectangleF>();
  151. /// <summary>
  152. /// 图像面板
  153. /// </summary>
  154. private DocumentWorkspaceWindow documentWorkspace;
  155. /// <summary>
  156. /// 公共控件
  157. /// </summary>
  158. private GeneralAnalysisCommonControlButtons commonControlButtons;
  159. /// <summary>
  160. /// 调色板
  161. /// </summary>
  162. PaintDotNet.ColorsForm colorsForm1;
  163. /// <summary>
  164. /// 调色板
  165. /// </summary>
  166. PaintDotNet.ColorsForm colorsForm2;
  167. /// <summary>
  168. /// 调色板
  169. /// </summary>
  170. PaintDotNet.ColorsForm colorsForm3;
  171. /// <summary>
  172. /// 调色板
  173. /// </summary>
  174. PaintDotNet.ColorsForm colorsForm4;
  175. /// <summary>
  176. /// 垂线截点数
  177. /// </summary>
  178. private int vPointCount = 0;
  179. /// <summary>
  180. /// 水平线截点数
  181. /// </summary>
  182. private int hPointCount = 0;
  183. #region 网格样式
  184. /// <summary>
  185. /// 水平数量
  186. /// </summary>
  187. private int hNumber;
  188. /// <summary>
  189. /// 垂直数量
  190. /// </summary>
  191. private int vNumber;
  192. /// <summary>
  193. /// 网格线宽
  194. /// </summary>
  195. private int gridWidth;
  196. /// <summary>
  197. /// 网格间距
  198. /// </summary>
  199. private int gridSpacing;
  200. /// <summary>
  201. /// 网格颜色
  202. /// </summary>
  203. private int gridColor;
  204. /// <summary>
  205. /// 全图 true:全图 false:非全图
  206. /// </summary>
  207. private bool wholePicture;
  208. /// <summary>
  209. /// 开始测量
  210. /// </summary>
  211. private bool startText = false;
  212. /// <summary>
  213. /// 余白
  214. /// </summary>
  215. private float blank;
  216. #endregion
  217. /// <summary>
  218. /// 垂直测量线
  219. /// </summary>
  220. private List<RectangleF> vRectangleFs = new List<RectangleF>();
  221. /// <summary>
  222. /// 水平测量线
  223. /// </summary>
  224. private List<RectangleF> hRectangleFs = new List<RectangleF>();
  225. /// <summary>
  226. /// 图片测量记录
  227. /// </summary>
  228. private List<DataTable> pictureDataTables = new List<DataTable>();
  229. /// <summary>
  230. /// 是否全部显示
  231. /// </summary>
  232. private bool allShow = false;
  233. /// <summary>
  234. /// 超出尺寸
  235. /// </summary>
  236. private bool exceed;
  237. /// <summary>
  238. /// 网格Xml
  239. /// </summary>
  240. private MicrostructureBandModel microstructureBandModel ;
  241. /// <summary>
  242. /// 网格绘制区域
  243. /// </summary>
  244. private float minX;
  245. private float maxX;
  246. private float minY;
  247. private float maxY;
  248. /// <summary>
  249. /// 保存用于生成报告的图片
  250. /// </summary>
  251. private List<Bitmap> bitList;
  252. /// <summary>
  253. /// 是否要调用二值化的算法
  254. /// </summary>
  255. private bool toApplyBinary = true;
  256. /// <summary>
  257. /// 切换图片
  258. /// </summary>
  259. private bool switchImg;
  260. private bool canMove = false;
  261. private PointF oldLocation = new PointF();
  262. private bool selected = false;
  263. /// <summary>
  264. /// 储存点击保存结果后的所有原图与分析图
  265. /// </summary>
  266. private Dictionary<string, List<Bitmap>> bitDic = new Dictionary<string, List<Bitmap>>();
  267. //二值化集成1
  268. BinaryClass binaryClass;
  269. private int menuId;
  270. private string menuName;
  271. private GroupBox groupBox12;
  272. private CheckBox checkBox4;
  273. private DataGridViewTextBoxColumn Column11;
  274. private DataGridViewTextBoxColumn dataGridViewTextBoxColumn1;
  275. private DataGridViewTextBoxColumn dataGridViewTextBoxColumn2;
  276. private DataGridViewTextBoxColumn dataGridViewTextBoxColumn3;
  277. private DataGridViewTextBoxColumn dataGridViewTextBoxColumn4;
  278. private DataGridView dataGridView2;
  279. private DataGridViewTextBoxColumn Column13;
  280. private DataGridViewTextBoxColumn Column14;
  281. private DataGridViewTextBoxColumn Column15;
  282. private DataGridViewTextBoxColumn Column16;
  283. private DataGridViewTextBoxColumn Column17;
  284. private DataGridViewTextBoxColumn Column18;
  285. private DataGridView dataGridView3;
  286. private DataGridViewTextBoxColumn dataGridViewTextBoxColumn5;
  287. private DataGridViewTextBoxColumn dataGridViewTextBoxColumn6;
  288. private DataGridViewTextBoxColumn dataGridViewTextBoxColumn7;
  289. private DataGridViewTextBoxColumn dataGridViewTextBoxColumn8;
  290. private DataGridViewTextBoxColumn dataGridViewTextBoxColumn9;
  291. private DataGridViewTextBoxColumn Column12;
  292. private DataGridViewTextBoxColumn Column1;
  293. private DataGridViewTextBoxColumn Column2;
  294. private DataGridViewTextBoxColumn Column3;
  295. private DataGridViewTextBoxColumn Column4;
  296. private DataGridViewTextBoxColumn Column5;
  297. private DataGridViewTextBoxColumn Column6;
  298. private DataGridViewTextBoxColumn Column7;
  299. private DataGridViewTextBoxColumn Column8;
  300. private DataGridViewTextBoxColumn Column9;
  301. private DataGridViewTextBoxColumn Column10;
  302. private CheckBox checkBox5;
  303. private Button button8;
  304. private int changeCount;
  305. private BinaryControl bc;
  306. /// <summary>
  307. /// 初始系统参数配置值
  308. /// </summary>
  309. private BinaryExtractionModel binaryExtractionModel;
  310. private ToolTip toolTip1;
  311. /// <summary>
  312. /// 标尺
  313. /// </summary>
  314. private double unitLength;
  315. private int defaultIndex = -1;
  316. /// <summary>
  317. /// 是否脚本运行
  318. /// </summary>
  319. private Boolean initScriptValues = false;
  320. // <summary>
  321. /// 保存窗口参数
  322. /// </summary>
  323. private GrainSizeAnalysisModel analysisModel;
  324. private const string ParamKey_GridUse = "gridUse";//使用网格
  325. private const string ParamKey_GridMove = "gridMove";//网格移动
  326. private const string ParamKey_Report = "report";//报告设置
  327. private const string ParamKey_Circular = "circular";//圆形
  328. private const string ParamKey_Square = "square";//方形
  329. private const string ParamKey_Solid = "solid";//实心
  330. private const string ParamKey_Hollow = "hollow";//空心
  331. private const string ParamKey_Size = "size";//尺寸
  332. private const string ParamKey_Width = "width";//线宽
  333. private const string ParamKey_Colour = "colour";//颜色
  334. private const string ParamKey_DecimalPlace = "decimalPlace";//保留小数位数
  335. public MicrostructureBandDialog(AppWorkspace appWorkspace, PdnMenuItem menuItem)
  336. {
  337. this.menuId = menuItem.MenuId;
  338. this.menuName = menuItem.Text;
  339. binaryClass = new BinaryClass(menuId);
  340. string filePath = Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\GrainSizeAnalyze\\GrainSizeAnalysisModel.xml";
  341. GrainSizeAnalysisModel analysisModelXml = XmlSerializeHelper.DESerializer<GrainSizeAnalysisModel>(FileOperationHelper.ReadStringFromFile(filePath, System.IO.FileMode.Open));
  342. this.analysisModel = analysisModelXml.cloneListParamModel(this.menuId);
  343. foreach (var item in this.analysisModel.ListParam)
  344. item.setValue();
  345. InitializeComponent();
  346. InitializeLanguageText();
  347. this.button7.Visible = false;
  348. this.button6.Visible = true;
  349. this.button11.Visible = true;
  350. this.button16.Visible = false;
  351. //调色板
  352. this.colorsForm1 = new ColorsForm();
  353. this.colorsForm1.StartPosition = FormStartPosition.CenterScreen;
  354. this.colorsForm1.UserPrimaryColorChanged += new ColorEventHandler(this.colorsFormUserPrimaryColorChanged);
  355. //调色板
  356. this.colorsForm2 = new ColorsForm();
  357. this.colorsForm2.StartPosition = FormStartPosition.CenterScreen;
  358. this.colorsForm2.UserPrimaryColorChanged += new ColorEventHandler(this.colorsFormUserPrimaryColorChanged);
  359. //调色板
  360. this.colorsForm3 = new ColorsForm();
  361. this.colorsForm3.StartPosition = FormStartPosition.CenterScreen;
  362. this.colorsForm3.UserPrimaryColorChanged += new ColorEventHandler(this.colorsFormUserPrimaryColorChanged);
  363. //调色板
  364. this.colorsForm4 = new ColorsForm();
  365. this.colorsForm4.StartPosition = FormStartPosition.CenterScreen;
  366. this.colorsForm4.UserPrimaryColorChanged += new ColorEventHandler(this.colorsFormUserPrimaryColorChanged);
  367. //初始化头
  368. this.listView2.View = View.Details;
  369. ColumnHeader header0 = new ColumnHeader();
  370. header0.Text = "";
  371. header0.Width = 180;
  372. this.listView2.Columns.Add(header0);
  373. this.appWorkspace = appWorkspace;
  374. this.documentWorkspace = new DocumentWorkspaceWindow(appWorkspace);
  375. this.documentWorkspace.Dock = DockStyle.Fill;
  376. this.documentWorkspace.HookMouseEvents();
  377. this.documentWorkspace.AuxiliaryLineEnabled = false;
  378. this.documentWorkspace.Visible = false;
  379. this.documentWorkspace.panel.Paint += Panel_Paint;
  380. this.documentWorkspace.panel.MouseDown += OnMouseDown;
  381. this.documentWorkspace.panel.Paint += Panel_Paint;
  382. this.documentWorkspace.panel.MouseUp += OnMouseUp;
  383. this.documentWorkspace.panel.MouseMove += onMouseMove;
  384. this.documentWorkspace.panel.PreviewKeyDown += onPreviewKeyDown;
  385. this.documentWorkspace.ActiveTool = DrawToolType.Pointer;
  386. this.groupBox7.Controls.Add(this.documentWorkspace);
  387. this.commonControlButtons = new GeneralAnalysisCommonControlButtons();
  388. this.commonControlButtons.Dock = DockStyle.Top;
  389. this.commonControlButtons.Height = 30;
  390. this.commonControlButtons.HideZoomToWindowAndActualSize();
  391. this.commonControlButtons.trackLabel.Text = PdnResources.GetString("Menu.icktheleftmousebuttontod.text");
  392. this.commonControlButtons.trackLabel.Visible = true;
  393. this.commonControlButtons.trackLabel.Width = 300;
  394. this.commonControlButtons.Visible = false;
  395. this.groupBox7.Controls.Add(commonControlButtons);
  396. foreach (DataGridViewColumn column in dataGridView4.Columns)
  397. { column.SortMode = DataGridViewColumnSortMode.NotSortable; }
  398. InitCommonButtonEvent();
  399. InitGridStyle();
  400. InitPicList();
  401. SetAnalyzeModelFromXml("Template.Manager.item3.MicrostructureBan_ASTME1268");
  402. //二值化集成2
  403. bc.OriginCheckedChangedAction += new EventHandler(this.bcOriginCheckedChanged);//初始化原图勾选改变事件
  404. binaryClass.createDocumentItems(new string[] { PdnResources.GetString("Menu.BinaryAction.BinaryExtraction.Text"), PdnResources.GetString("Menu.Grainboundarytoreproduce.text") }
  405. , this.bc, this.appWorkspace, this.documentWorkspace, this.listView1);//初始化相的工作结构
  406. binaryClass.BinaryImplFinishAction += new EventHandler(this.bClassBinaryImplFinishAction);//二值化后续处理事件
  407. //如果是脚本执行,将参数带入
  408. if (appWorkspace.ScriptRunning && appWorkspace.ScriptCurrentParam != null)
  409. {
  410. this.initScriptValues = true;//ScriptAutomatic
  411. //Boolean initScriptValues = true;
  412. ////在这里反射出对应功能的参数类
  413. string className = InvariantData.path_Action + ".Action" + menuId;
  414. ParamObject param = (ParamObject)System.Reflection.Assembly.Load(InvariantData.assembly_Data).CreateInstance(className);
  415. foreach (Args arg in param.Lists)
  416. {
  417. Args param1 = appWorkspace.ScriptCurrentParam.Lists.Find(m => m.Key.Equals(arg.Key));
  418. if (param1.value != null)
  419. arg.Value = param1.value;
  420. getValue(arg.key, arg.Value);
  421. }
  422. appWorkspace.ScriptCurrentParam = null;//阻止第二次进入仍然被赋值参数
  423. }
  424. else
  425. {//读取上次关闭窗口时保存的参数
  426. GetListParamModel();
  427. }
  428. for (int i = 0; i < this.dataGridView1.Columns.Count; i++)
  429. {
  430. this.dataGridView1.Columns[i].SortMode = DataGridViewColumnSortMode.NotSortable;
  431. }
  432. for (int i = 0; i < this.dataGridView2.Columns.Count; i++)
  433. {
  434. this.dataGridView2.Columns[i].SortMode = DataGridViewColumnSortMode.NotSortable;
  435. }
  436. for (int i = 0; i < this.dataGridView3.Columns.Count; i++)
  437. {
  438. this.dataGridView3.Columns[i].SortMode = DataGridViewColumnSortMode.NotSortable;
  439. }
  440. for (int i = 0; i < this.dataGridView4.Columns.Count; i++)
  441. {
  442. this.dataGridView4.Columns[i].SortMode = DataGridViewColumnSortMode.NotSortable;
  443. }
  444. //this.appWorkspace.getMeasureInfo().TryGetValue(MeasurementUnit.Micron, out unitLength);
  445. }
  446. //二值化集成3
  447. #region 二值化相关方法
  448. private void InclusionsStandardDialog_FormClosing(object sender, FormClosingEventArgs e)
  449. {
  450. #region [开启脚本录制]
  451. if (appWorkspace.startScriptRecording)
  452. {
  453. getScriptRecording();
  454. }
  455. #endregion
  456. binaryClass.saveParams();
  457. this.saveDialogParamValues();
  458. //xml保存路径
  459. string filePath = Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\GrainSizeAnalyze\\GrainSizeAnalysisModel.xml";
  460. GrainSizeAnalysisModel analysisModelXml = XmlSerializeHelper.DESerializer<GrainSizeAnalysisModel>(FileOperationHelper.ReadStringFromFile(filePath, System.IO.FileMode.Open));
  461. foreach (var analysisItem in this.analysisModel.ListParam)
  462. {
  463. bool foundItem = false;
  464. foreach (var item in analysisModelXml.ListParam)
  465. {
  466. if (item.param_key.Equals(analysisItem.param_key) && item.menuId == analysisItem.menuId)
  467. {
  468. item.param_value = analysisItem.param_value;
  469. foundItem = true;
  470. break;
  471. }
  472. }
  473. if (!foundItem)
  474. analysisModelXml.ListParam.Add(analysisItem.cloneModel());
  475. }
  476. //按路径和名称保存xml文件
  477. string userInfoXml = XmlSerializeHelper.XmlSerialize<GrainSizeAnalysisModel>(analysisModelXml);
  478. //保存xml
  479. FileOperationHelper.WriteStringToFile(userInfoXml, filePath, System.IO.FileMode.Create);
  480. }
  481. private void ShownChoiseItemAndInitData(object sender, EventArgs e)
  482. {
  483. binaryClass.RefreshHistogramControl1Values();
  484. }
  485. /// <summary>
  486. /// 添加参数改变的监听
  487. /// </summary>
  488. /// <param name="sender"></param>
  489. /// <param name="e"></param>
  490. private void MicrostructureBandDialog_Load(object sender, EventArgs e)
  491. {
  492. this.binaryClass.loadParams();
  493. }
  494. private bool bcBinaryChecked()
  495. {
  496. return bc != null && bc.BinaryChecked;
  497. }
  498. private bool bcOriginChecked()
  499. {
  500. return bc != null && bc.OriginChecked;
  501. }
  502. /// <summary>
  503. /// 参数改变时,重新处理图像
  504. /// </summary>
  505. /// <param name="sender"></param>
  506. /// <param name="e"></param>
  507. private void bClassBinaryImplFinishAction(object sender, EventArgs e)
  508. {
  509. if (this.checkBox4.Checked)
  510. {
  511. GetNumberOfGrains();
  512. RefreshResultsData();
  513. }
  514. this.documentWorkspace.Refresh();
  515. }
  516. /// <summary>
  517. /// 显示原图/原图+二值图
  518. /// </summary>
  519. /// <param name="sender"></param>
  520. /// <param name="e"></param>
  521. private void bcOriginCheckedChanged(object sender, EventArgs e)
  522. {
  523. if (!bcOriginChecked())
  524. {
  525. if (bcBinaryChecked())
  526. this.documentWorkspace.PhaseModels[0].choise = true;
  527. }
  528. else
  529. {
  530. this.documentWorkspace.PhaseModels[0].choise = false;
  531. this.documentWorkspace.PhaseModels[1].choise = false;
  532. }
  533. this.documentWorkspace.Refresh();
  534. }
  535. #endregion
  536. private void ShowImgEvent(object sender, EventArgs e)
  537. {
  538. listView1.Focus();
  539. if (this.defaultIndex != -1)
  540. {
  541. this.listView1.Items[defaultIndex].Focused = true;
  542. this.listView1.Items[defaultIndex].Selected = true;
  543. }
  544. }
  545. /// <summary>
  546. /// 初始化画面数据
  547. /// </summary>
  548. private void InitGridStyle()
  549. {
  550. microstructureBandModel = XmlSerializeHelper.DESerializer<MicrostructureBandModel>(FileOperationHelper.ReadStringFromFile(Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\MicrostructureBandModel.xml", FileMode.Open));
  551. if (microstructureBandModel.GridStyleList != null)
  552. {
  553. ArrayList arrayList = new ArrayList();
  554. foreach (var GridStyle in microstructureBandModel.GridStyleList)
  555. {
  556. arrayList.Add(GridStyle.gridName);
  557. }
  558. this.comboBox1.DataSource = null;
  559. this.comboBox1.DataSource = arrayList;
  560. if (microstructureBandModel.GridStyleList.Count == 0)
  561. {
  562. this.textBox2.Text = "0";
  563. this.textBox3.Text = "0";
  564. this.textBox4.Text = "0";
  565. this.textBox5.Text = "0";
  566. this.numericUpDown4.Value = 0;
  567. this.checkBox2.Checked = false;
  568. this.label10.Visible = true;
  569. this.textBox5.Visible = true;
  570. this.label12.Visible = false;
  571. this.numericUpDown4.Visible = false;
  572. }
  573. }
  574. }
  575. /// <summary>
  576. /// 更新辅助线下拉并保存
  577. /// </summary>
  578. public void RefreshGridItems(string gridName)
  579. {
  580. if (!string.IsNullOrEmpty(gridName))
  581. {
  582. MicrostructureBandModel.GridStyle gridStyle = new MicrostructureBandModel.GridStyle();
  583. gridStyle.gridName = gridName;
  584. gridStyle.hNumber = Convert.ToInt32(this.textBox2.Text);
  585. gridStyle.vNumber = Convert.ToInt32(this.textBox3.Text);
  586. gridStyle.gridWidth = Convert.ToInt32(this.textBox4.Text);
  587. gridStyle.gridSpacing = Convert.ToInt32(this.textBox5.Text);
  588. gridStyle.gridColor = Convert.ToInt32(this.panel4.BackColor.ToArgb());
  589. gridStyle.wholePicture = this.checkBox2.Checked;
  590. gridStyle.blank = Convert.ToInt32(this.numericUpDown4.Value);
  591. if (this.microstructureBandModel.GridStyleList != null)
  592. this.microstructureBandModel.GridStyleList.Add(gridStyle);
  593. ArrayList arrayList = new ArrayList();
  594. foreach (var GridStyle in microstructureBandModel.GridStyleList)
  595. {
  596. arrayList.Add(GridStyle.gridName);
  597. }
  598. this.comboBox1.DataSource = null;
  599. this.comboBox1.DataSource = arrayList;
  600. }
  601. else
  602. {
  603. if (this.microstructureBandModel.GridStyleList != null)
  604. {
  605. foreach (var GridStyle in this.microstructureBandModel.GridStyleList)
  606. {
  607. if (GridStyle.gridName.Equals(this.comboBox1.SelectedItem))
  608. {
  609. GridStyle.hNumber = Convert.ToInt32(this.textBox2.Text);
  610. GridStyle.vNumber = Convert.ToInt32(this.textBox3.Text);
  611. GridStyle.gridWidth = Convert.ToInt32(this.textBox4.Text);
  612. GridStyle.gridSpacing = Convert.ToInt32(this.textBox5.Text);
  613. GridStyle.gridColor = Convert.ToInt32(this.panel4.BackColor.ToArgb());
  614. GridStyle.wholePicture = this.checkBox2.Checked;
  615. GridStyle.blank = Convert.ToInt32(this.numericUpDown4.Value);
  616. }
  617. }
  618. }
  619. }
  620. //以下保存xml文件信息
  621. string stageModelXml = XmlSerializeHelper.XmlSerialize<MicrostructureBandModel>(microstructureBandModel);
  622. string filePath = Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\MicrostructureBandModel.xml";
  623. FileOperationHelper.WriteStringToFile(stageModelXml, filePath, FileMode.Create);
  624. }
  625. /// <summary>
  626. /// 初始化图片列表数据
  627. /// </summary>
  628. public void InitPicList()
  629. {
  630. //初始化图片列表
  631. for (int i = 0; i < this.appWorkspace.DocumentWorkspaces.Length; i++)
  632. {
  633. this.imageList1.Images.Add("img" + i, this.appWorkspace.DocumentWorkspaces[i].BinarizationThumbnail);
  634. this.listView1.Items.Add("", i);
  635. this.listView1.Items[i].ImageIndex = i;
  636. this.listView1.Items[i].Text = this.appWorkspace.DocumentWorkspaces[i].GetFriendlyName();
  637. this.listView1.Items[i].Name = this.appWorkspace.DocumentWorkspaces[i].GetFriendlyName();
  638. if (this.appWorkspace.DocumentWorkspaces[i].Equals(this.appWorkspace.ActiveDocumentWorkspace))
  639. {
  640. defaultIndex = i;
  641. }
  642. }
  643. this.Shown += ShowImgEvent;
  644. }
  645. internal class DocumentItem
  646. {
  647. public Bitmap bitmap;
  648. public GraphicsList graphicsList;
  649. public List<PhaseModel> phaseModels;
  650. public AnalysisResult analysisResult;
  651. public DocumentItem(Bitmap bitmap, GraphicsList graphicsList, List<PhaseModel> phaseModels)
  652. {
  653. this.bitmap = bitmap;
  654. this.graphicsList = graphicsList;
  655. this.phaseModels = phaseModels;
  656. }
  657. }
  658. RectangleF drawRectangleF = new RectangleF();
  659. /// <summary>
  660. /// 刷新绘制区域
  661. /// </summary>
  662. private void RefreshDrawRegion(PointF pointF, bool moveRec)
  663. {
  664. if (this.wholePicture)
  665. return;
  666. float hGridSpacingDraw = 0;
  667. float vGridSpacingDraw = 0;
  668. if (!this.wholePicture)
  669. {
  670. hGridSpacingDraw = (float)(this.gridSpacing / unitLength);
  671. vGridSpacingDraw = (float)(this.gridSpacing / unitLength);
  672. }
  673. exceed = false;
  674. ArrayList xs = new ArrayList();
  675. ArrayList ys = new ArrayList();
  676. if (this.hNumber > 0)
  677. {
  678. if (this.hNumber % 2 == 0)
  679. {
  680. float Spacing = hGridSpacingDraw / 2;
  681. for (int i = 0; i < this.hNumber / 2; i++)
  682. {
  683. if ((float)this.documentWorkspace.CompositionSurface.Height / 2 - Spacing >= 0
  684. && (float)this.documentWorkspace.CompositionSurface.Height / 2 + Spacing <= this.documentWorkspace.CompositionSurface.Height)
  685. {
  686. ys.Add((float)this.documentWorkspace.CompositionSurface.Height / 2 - Spacing);
  687. ys.Add((float)this.documentWorkspace.CompositionSurface.Height / 2 + Spacing);
  688. }
  689. else
  690. exceed = true;
  691. Spacing += hGridSpacingDraw;
  692. }
  693. }
  694. else
  695. {
  696. if (this.hNumber == 1)
  697. ys.Add((float)this.documentWorkspace.CompositionSurface.Height / 2);
  698. else
  699. {
  700. float Spacing = hGridSpacingDraw;
  701. for (int i = 0; i < (this.hNumber - 1) / 2; i++)
  702. {
  703. if (i == 0)
  704. ys.Add((float)this.documentWorkspace.CompositionSurface.Height / 2);
  705. if ((float)this.documentWorkspace.CompositionSurface.Height / 2 - Spacing >= 0
  706. && (float)this.documentWorkspace.CompositionSurface.Height / 2 + Spacing <= this.documentWorkspace.CompositionSurface.Height)
  707. {
  708. ys.Add((float)this.documentWorkspace.CompositionSurface.Height / 2 - Spacing);
  709. ys.Add((float)this.documentWorkspace.CompositionSurface.Height / 2 + Spacing);
  710. }
  711. else
  712. exceed = true;
  713. Spacing += hGridSpacingDraw;
  714. }
  715. }
  716. }
  717. }
  718. if (this.vNumber > 0)
  719. {
  720. if (this.vNumber % 2 == 0)
  721. {
  722. float Spacing = vGridSpacingDraw / 2;
  723. for (int i = 0; i < this.vNumber / 2; i++)
  724. {
  725. if ((float)this.documentWorkspace.CompositionSurface.Width / 2 - Spacing >= 0
  726. && (float)this.documentWorkspace.CompositionSurface.Width / 2 + Spacing <= this.documentWorkspace.CompositionSurface.Width)
  727. {
  728. xs.Add((float)this.documentWorkspace.CompositionSurface.Width / 2 - Spacing);
  729. xs.Add((float)this.documentWorkspace.CompositionSurface.Width / 2 + Spacing);
  730. }
  731. else
  732. exceed = true;
  733. Spacing += vGridSpacingDraw;
  734. }
  735. }
  736. else
  737. {
  738. if (this.vNumber == 1)
  739. xs.Add((float)this.documentWorkspace.CompositionSurface.Width / 2);
  740. else
  741. {
  742. float Spacing = vGridSpacingDraw;
  743. for (int i = 0; i < (this.vNumber - 1) / 2; i++)
  744. {
  745. if (i == 0)
  746. xs.Add((float)this.documentWorkspace.CompositionSurface.Width / 2);
  747. if ((float)this.documentWorkspace.CompositionSurface.Width / 2 + Spacing <= this.documentWorkspace.CompositionSurface.Width
  748. && (float)this.documentWorkspace.CompositionSurface.Width / 2 - Spacing >= 0)
  749. {
  750. xs.Add((float)this.documentWorkspace.CompositionSurface.Width / 2 - Spacing);
  751. xs.Add((float)this.documentWorkspace.CompositionSurface.Width / 2 + Spacing);
  752. }
  753. else
  754. exceed = true;
  755. Spacing += vGridSpacingDraw;
  756. }
  757. }
  758. }
  759. }
  760. // 矩形位置
  761. float rectangleFx = 0;
  762. float rectangleFy = 0;
  763. // 矩形右下角
  764. float rectangleFrbx = 0;
  765. float rectangleFrby = 0;
  766. if (xs.Count > 1)
  767. {
  768. rectangleFx = (float)xs[xs.Count - 2];
  769. rectangleFrbx = (float)xs[xs.Count - 1];
  770. }
  771. if (ys.Count > 1)
  772. {
  773. rectangleFy = (float)ys[ys.Count - 2];
  774. rectangleFrby = (float)ys[ys.Count - 1];
  775. }
  776. if (pointF.Equals(PointF.Empty) && exceed)
  777. {
  778. MessageBox.Show(PdnResources.GetString("Menu.Thegridsizehasexceededtheimage.text") + "!");
  779. this.textBox5.Text = "0";
  780. return;
  781. }
  782. if (pointF.Equals(PointF.Empty))
  783. pointF = new PointF(rectangleFx, rectangleFy);
  784. this.drawRectangleF = new RectangleF(pointF.X, pointF.Y
  785. , Math.Abs(rectangleFrbx - rectangleFx), Math.Abs(rectangleFrby - rectangleFy));
  786. RefreshGridIntersections(moveRec);
  787. this.documentWorkspace.Refresh();
  788. }
  789. /// <summary>
  790. /// 刷新网格矩形
  791. /// </summary>
  792. private void RefreshGridIntersections(bool moveRec)
  793. {
  794. this.vRectangleFs.Clear();
  795. this.hRectangleFs.Clear();
  796. float hGridSpacingDraw;
  797. float vGridSpacingDraw;
  798. if (this.wholePicture)
  799. {
  800. hGridSpacingDraw = (float)(this.documentWorkspace.CompositionSurface.Height - 2 * this.blank) / (this.hNumber - 1);
  801. vGridSpacingDraw = (float)(this.documentWorkspace.CompositionSurface.Width - 2 * this.blank) / (this.vNumber - 1);
  802. exceed = false;
  803. ArrayList xs = new ArrayList();
  804. ArrayList ys = new ArrayList();
  805. if (this.hNumber > 0)
  806. {
  807. if (this.hNumber % 2 == 0)
  808. {
  809. float Spacing = hGridSpacingDraw / 2;
  810. for (int i = 0; i < this.hNumber / 2; i++)
  811. {
  812. if ((float)this.documentWorkspace.CompositionSurface.Height / 2 - Math.Round(Spacing, 2) >= 0
  813. && (float)this.documentWorkspace.CompositionSurface.Height / 2 + Math.Round(Spacing, 2) <= this.documentWorkspace.CompositionSurface.Height)
  814. {
  815. ys.Add((float)this.documentWorkspace.CompositionSurface.Height / 2 - Math.Round(Spacing, 2));
  816. ys.Add((float)this.documentWorkspace.CompositionSurface.Height / 2 + Math.Round(Spacing, 2));
  817. }
  818. else
  819. {
  820. if (!this.wholePicture)
  821. exceed = true;
  822. }
  823. Spacing += hGridSpacingDraw;
  824. }
  825. }
  826. else
  827. {
  828. if (this.hNumber == 1)
  829. ys.Add((float)this.documentWorkspace.CompositionSurface.Height / 2);
  830. else
  831. {
  832. float Spacing = hGridSpacingDraw;
  833. for (int i = 0; i < (this.hNumber - 1) / 2; i++)
  834. {
  835. if (i == 0)
  836. ys.Add((float)this.documentWorkspace.CompositionSurface.Height / 2);
  837. if ((float)this.documentWorkspace.CompositionSurface.Height / 2 - Math.Round(Spacing, 2) >= 0
  838. && (float)this.documentWorkspace.CompositionSurface.Height / 2 + Math.Round(Spacing, 2) <= this.documentWorkspace.CompositionSurface.Height)
  839. {
  840. ys.Add((float)this.documentWorkspace.CompositionSurface.Height / 2 - Math.Round(Spacing, 2));
  841. ys.Add((float)this.documentWorkspace.CompositionSurface.Height / 2 + Math.Round(Spacing, 2));
  842. }
  843. else
  844. {
  845. if (!this.wholePicture)
  846. exceed = true;
  847. }
  848. Spacing += hGridSpacingDraw;
  849. }
  850. }
  851. }
  852. }
  853. if (this.vNumber > 0)
  854. {
  855. if (this.vNumber % 2 == 0)
  856. {
  857. float Spacing = vGridSpacingDraw / 2;
  858. for (int i = 0; i < this.vNumber / 2; i++)
  859. {
  860. if ((float)this.documentWorkspace.CompositionSurface.Width / 2 - Math.Round(Spacing, 2) >= 0
  861. && (float)this.documentWorkspace.CompositionSurface.Width / 2 + Math.Round(Spacing, 2) <= this.documentWorkspace.CompositionSurface.Width)
  862. {
  863. xs.Add((float)this.documentWorkspace.CompositionSurface.Width / 2 - Math.Round(Spacing, 2));
  864. xs.Add((float)this.documentWorkspace.CompositionSurface.Width / 2 + Math.Round(Spacing, 2));
  865. }
  866. else
  867. {
  868. if (!this.wholePicture)
  869. exceed = true;
  870. }
  871. Spacing += vGridSpacingDraw;
  872. }
  873. }
  874. else
  875. {
  876. if (this.vNumber == 1)
  877. xs.Add((float)this.documentWorkspace.CompositionSurface.Width / 2);
  878. else
  879. {
  880. float Spacing = vGridSpacingDraw;
  881. for (int i = 0; i < (this.vNumber - 1) / 2; i++)
  882. {
  883. if (i == 0)
  884. xs.Add((float)this.documentWorkspace.CompositionSurface.Width / 2);
  885. if ((float)this.documentWorkspace.CompositionSurface.Width / 2 + Math.Round(Spacing, 2) <= this.documentWorkspace.CompositionSurface.Width
  886. && (float)this.documentWorkspace.CompositionSurface.Width / 2 - Math.Round(Spacing, 2) >= 0)
  887. {
  888. xs.Add((float)this.documentWorkspace.CompositionSurface.Width / 2 - Math.Round(Spacing, 2));
  889. xs.Add((float)this.documentWorkspace.CompositionSurface.Width / 2 + Math.Round(Spacing, 2));
  890. }
  891. else
  892. {
  893. if (!this.wholePicture)
  894. exceed = true;
  895. }
  896. Spacing += vGridSpacingDraw;
  897. }
  898. }
  899. }
  900. }
  901. if (xs.Count > 1)
  902. {
  903. this.minX = (float)Convert.ToDecimal(xs[xs.Count - 2]);
  904. this.maxX = (float)Convert.ToDecimal(xs[xs.Count - 1]);
  905. }
  906. if (ys.Count > 1)
  907. {
  908. this.minY = (float)Convert.ToDecimal(ys[ys.Count - 2]);
  909. this.maxY = (float)Convert.ToDecimal(ys[ys.Count - 1]);
  910. }
  911. foreach (var x in xs)
  912. {
  913. this.vRectangleFs.Add(new RectangleF((float)(Convert.ToDecimal(x) - Convert.ToDecimal((float)this.gridWidth / 2) - 3)
  914. , (float)(Convert.ToDecimal(this.minY) - Convert.ToDecimal((float)this.gridWidth / 2) - 3), this.gridWidth + 6, (this.maxY - this.minY) + 6));
  915. }
  916. foreach (var y in ys)
  917. {
  918. this.hRectangleFs.Add(new RectangleF((float)(Convert.ToDecimal(this.minX) - Convert.ToDecimal((float)this.gridWidth / 2) - 3)
  919. , (float)(Convert.ToDecimal(y) - Convert.ToDecimal((float)this.gridWidth / 2) - 3), (this.maxX - this.minX) + 6, this.gridWidth + 6));
  920. }
  921. }
  922. else
  923. {
  924. hGridSpacingDraw = (float)(this.gridSpacing / unitLength);
  925. vGridSpacingDraw = (float)(this.gridSpacing / unitLength);
  926. exceed = false;
  927. ArrayList xs = new ArrayList();
  928. ArrayList ys = new ArrayList();
  929. if (this.hNumber > 0)
  930. {
  931. if (this.hNumber % 2 == 0)
  932. {
  933. float Spacing = hGridSpacingDraw / 2;
  934. for (int i = 0; i < this.hNumber / 2; i++)
  935. {
  936. if ((float)this.drawRectangleF.Top + (float)this.drawRectangleF.Height / 2 - Spacing >= (float)this.drawRectangleF.Top
  937. && (float)this.drawRectangleF.Top + (float)this.drawRectangleF.Height / 2 + Spacing <= this.drawRectangleF.Bottom)
  938. {
  939. ys.Add((float)this.drawRectangleF.Top + (float)this.drawRectangleF.Height / 2 - Spacing);
  940. ys.Add((float)this.drawRectangleF.Top + (float)this.drawRectangleF.Height / 2 + Spacing);
  941. }
  942. else
  943. exceed = true;
  944. Spacing += hGridSpacingDraw;
  945. }
  946. }
  947. else
  948. {
  949. if (this.hNumber == 1)
  950. ys.Add((float)this.drawRectangleF.Top + (float)this.drawRectangleF.Height / 2);
  951. else
  952. {
  953. float Spacing = hGridSpacingDraw;
  954. for (int i = 0; i < (this.hNumber - 1) / 2; i++)
  955. {
  956. if (i == 0)
  957. ys.Add((float)this.drawRectangleF.Top + (float)this.drawRectangleF.Height / 2);
  958. if ((float)this.drawRectangleF.Top + (float)this.drawRectangleF.Height / 2 - Spacing >= this.drawRectangleF.Top
  959. && (float)this.drawRectangleF.Top + (float)this.drawRectangleF.Height / 2 + Spacing <= this.drawRectangleF.Bottom)
  960. {
  961. ys.Add((float)this.drawRectangleF.Top + (float)this.drawRectangleF.Height / 2 - Spacing);
  962. ys.Add((float)this.drawRectangleF.Top + (float)this.drawRectangleF.Height / 2 + Spacing);
  963. }
  964. else
  965. exceed = true;
  966. Spacing += hGridSpacingDraw;
  967. }
  968. }
  969. }
  970. }
  971. if (this.vNumber > 0)
  972. {
  973. if (this.vNumber % 2 == 0)
  974. {
  975. float Spacing = vGridSpacingDraw / 2;
  976. for (int i = 0; i < this.vNumber / 2; i++)
  977. {
  978. if ((float)this.drawRectangleF.Left + (float)this.drawRectangleF.Width / 2 - Spacing >= this.drawRectangleF.Left
  979. && (float)this.drawRectangleF.Left + (float)this.drawRectangleF.Width / 2 + Spacing <= this.drawRectangleF.Right)
  980. {
  981. xs.Add((float)this.drawRectangleF.Left + (float)this.drawRectangleF.Width / 2 - Spacing);
  982. xs.Add((float)this.drawRectangleF.Left + (float)this.drawRectangleF.Width / 2 + Spacing);
  983. }
  984. else
  985. {
  986. if (!this.wholePicture)
  987. exceed = true;
  988. }
  989. Spacing += vGridSpacingDraw;
  990. }
  991. }
  992. else
  993. {
  994. if (this.vNumber == 1)
  995. xs.Add((float)this.drawRectangleF.Left + (float)this.drawRectangleF.Width / 2);
  996. else
  997. {
  998. float Spacing = vGridSpacingDraw;
  999. for (int i = 0; i < (this.vNumber - 1) / 2; i++)
  1000. {
  1001. if (i == 0)
  1002. xs.Add((float)this.drawRectangleF.Left + (float)this.drawRectangleF.Width / 2);
  1003. if ((float)this.drawRectangleF.Left + (float)this.drawRectangleF.Width / 2 + Spacing <= this.drawRectangleF.Right
  1004. && (float)this.drawRectangleF.Left + (float)this.drawRectangleF.Width / 2 - Spacing >= this.drawRectangleF.Left)
  1005. {
  1006. xs.Add((float)this.drawRectangleF.Left + (float)this.drawRectangleF.Width / 2 - Spacing);
  1007. xs.Add((float)this.drawRectangleF.Left + (float)this.drawRectangleF.Width / 2 + Spacing);
  1008. }
  1009. else
  1010. {
  1011. if (!this.wholePicture)
  1012. exceed = true;
  1013. }
  1014. Spacing += vGridSpacingDraw;
  1015. }
  1016. }
  1017. }
  1018. }
  1019. if (xs.Count > 1)
  1020. {
  1021. this.minX = (float)Convert.ToDecimal(xs[xs.Count - 2]);
  1022. this.maxX = (float)Convert.ToDecimal(xs[xs.Count - 1]);
  1023. }
  1024. if (ys.Count > 1)
  1025. {
  1026. this.minY = (float)Convert.ToDecimal(ys[ys.Count - 2]);
  1027. this.maxY = (float)Convert.ToDecimal(ys[ys.Count - 1]);
  1028. }
  1029. foreach (var x in xs)
  1030. {
  1031. this.vRectangleFs.Add(new RectangleF((float)(Convert.ToDecimal(x) - Convert.ToDecimal((float)this.gridWidth / 2) - 3)
  1032. , (float)(Convert.ToDecimal(this.minY) - Convert.ToDecimal((float)this.gridWidth / 2) - 3), this.gridWidth + 6, (this.maxY - this.minY) + 6));
  1033. }
  1034. foreach (var y in ys)
  1035. {
  1036. this.hRectangleFs.Add(new RectangleF((float)(Convert.ToDecimal(this.minX) - Convert.ToDecimal((float)this.gridWidth / 2) - 3)
  1037. , (float)(Convert.ToDecimal(y) - Convert.ToDecimal((float)this.gridWidth / 2) - 3), (this.maxX - this.minX) + 6, this.gridWidth + 6));
  1038. }
  1039. }
  1040. if (exceed && !moveRec)
  1041. MessageBox.Show(PdnResources.GetString("Menu.Thegridsizehasexceededtheimage.text")+"!");
  1042. this.documentWorkspace.Refresh();
  1043. }
  1044. #region 初始化
  1045. private void InitializeLanguageText()
  1046. {
  1047. this.bc = new PaintDotNet.CustomControl.BinaryControl();
  1048. //
  1049. // bc
  1050. //
  1051. this.bc.BinaryBackColor = System.Drawing.Color.Red;
  1052. this.bc.BinaryChecked = false;
  1053. this.bc.BinaryStyle = 1;
  1054. this.bc.Location = new System.Drawing.Point(150, 57);
  1055. this.bc.Name = "bc";
  1056. this.bc.OriginChecked = false;
  1057. this.bc.scope1End = 0D;
  1058. this.bc.scope1Start = 0D;
  1059. this.bc.scope2End = 0D;
  1060. this.bc.scope2Start = 0D;
  1061. this.bc.scope3End = 0D;
  1062. this.bc.scope3Start = 0D;
  1063. this.bc.Size = new System.Drawing.Size(360, 292);
  1064. this.bc.TabIndex = 22;
  1065. this.Controls.Add(this.bc);
  1066. this.Controls.SetChildIndex(this.bc, 0);
  1067. this.groupBox1.Text = PdnResources.GetString("Menu.operation.text");
  1068. this.button7.Text = PdnResources.GetString("Menu.stop.text");
  1069. this.checkBox3.Text = PdnResources.GetString("Menu.Opensettingsatingreport.text");
  1070. this.button6.Text = PdnResources.GetString("Menu.Started.text");
  1071. this.button5.Text = PdnResources.GetString("Menu.Edit.Delete.Text");
  1072. this.button4.Text = PdnResources.GetString("Menu.File.SaveAs.Text");
  1073. this.button3.Text = PdnResources.GetString("CommonAction.Save");
  1074. this.label1.Text = PdnResources.GetString("Menu.Usegrid.text") + ":";
  1075. this.button2.Text = PdnResources.GetString("Menu.Saveresult.text");
  1076. this.button1.Text = PdnResources.GetString("Menu.Setting.Text");
  1077. this.groupBox2.Text = PdnResources.GetString("Menu.Tools.ImageIndex.Text");
  1078. this.groupBox8.Text = PdnResources.GetString("Menu.Analysisresult.text");
  1079. this.button8.Text = PdnResources.GetString("Menu.Exportproject.text");
  1080. this.Column13.HeaderText = PdnResources.GetString("Menu.picture.Text");
  1081. this.Column14.HeaderText = PdnResources.GetString("Menu.view.text");
  1082. this.button16.Text = PdnResources.GetString("Menu.Cancelshowall.text");
  1083. this.label5.Text = PdnResources.GetString("Menu.Decimal.text") + ":";
  1084. this.button14.Text = PdnResources.GetString("Menu.Exportresults.text");
  1085. this.button13.Text = PdnResources.GetString("Menu.Tools.CreateReport.Text");
  1086. this.Column12.HeaderText = PdnResources.GetString("Menu.params.text");
  1087. this.Column1.HeaderText = "NL⊥" + PdnResources.GetString("Menu.Image.Average.Text") + "(No./mm)";
  1088. this.Column2.HeaderText = "NL∥" + PdnResources.GetString("Menu.Image.Average.Text") + "No./mm)";
  1089. this.Column3.HeaderText = "AI(NL⊥" + PdnResources.GetString("Menu.Image.Average.Text") + "/NL∥" + PdnResources.GetString("Menu.Image.Average.Text") + ")";
  1090. this.Column5.HeaderText = "PL⊥" + PdnResources.GetString("Menu.Image.Average.Text") + "(No./mm)";
  1091. this.Column6.HeaderText = "PL∥" + PdnResources.GetString("Menu.Image.Average.Text") + "(No./mm)";
  1092. this.Column7.HeaderText = "AI(PL⊥" + PdnResources.GetString("Menu.Image.Average.Text") + "/PL∥" + PdnResources.GetString("Menu.Image.Average.Text") + ")";
  1093. this.button12.Text = PdnResources.GetString("Menu.Edit.Delete.Text");
  1094. this.button11.Text = PdnResources.GetString("Menu.Showall.text");
  1095. this.groupBox7.Text = PdnResources.GetString("Menu.Preview.text");
  1096. this.groupBox4.Text = PdnResources.GetString("Menu.Setting.GridSetting.Text");
  1097. this.label10.Text = PdnResources.GetString("Menu.Dedicatedanalysis.blackmetal.Gridspacing.text") + ":";
  1098. this.checkBox2.Text = PdnResources.GetString("Menu.thefullimage.text");
  1099. this.label12.Text = PdnResources.GetString("Menu.void.text")+":";
  1100. this.label11.Text = PdnResources.GetString("Menu.Gridcolor.text") + ":";
  1101. this.label9.Text = PdnResources.GetString("Menu.Numberofvertical.text") + ":";
  1102. this.label8.Text = PdnResources.GetString("Menu.Dedicatedanalysis.blackmetal.Thelevelofthenumber.text") + ":";
  1103. this.label7.Text = PdnResources.GetString("Menu.Gridlinewidth.text") + ":";
  1104. this.groupBox10.Text = PdnResources.GetString("Menu.Cutoffpointset.text");
  1105. this.label18.Text = PdnResources.GetString("Menu.style.text") + ":";
  1106. this.rb_leftNoFill.Text = PdnResources.GetString("Menu.Hollow.text");
  1107. this.rb_leftFill.Text = PdnResources.GetString("Menu.solid.text");
  1108. this.label19.Text = PdnResources.GetString("Menu.color.text") + ":";
  1109. this.label20.Text = PdnResources.GetString("Menu.Linewidth.text") + ":";
  1110. this.label21.Text = PdnResources.GetString("Menu.sizeed.text") + ":";
  1111. this.rb_LeftSquare.Text = PdnResources.GetString("Menu.Square.text");
  1112. this.rb_LeftCircle.Text = PdnResources.GetString("Menu.circular.Text");
  1113. this.label22.Text = PdnResources.GetString("Menu.shape.text") + ":";
  1114. this.groupBox9.Text = PdnResources.GetString("Menu.Resultspreview.text");
  1115. this.dataGridViewTextBoxColumn5.HeaderText = PdnResources.GetString("Menu.view.text");
  1116. this.Column11.HeaderText = PdnResources.GetString("Menu.view.text");
  1117. this.groupBox12.Text = PdnResources.GetString("Menu.Dedicatedanalysis.blackmetal.autoadd.text");
  1118. this.checkBox5.Text = PdnResources.GetString("Menu.Thegridmobile.text");
  1119. this.checkBox4.Text = PdnResources.GetString("Menu.autoaddsection.text");
  1120. this.Text = PdnResources.GetString("Menu.DedicatedAnalysis.BlackMetal.BandedStructure.Text") + "_ASTM_E1268-01";
  1121. }
  1122. private void InitializeComponent()
  1123. {
  1124. this.components = new System.ComponentModel.Container();
  1125. System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle();
  1126. System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle();
  1127. System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle();
  1128. System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle4 = new System.Windows.Forms.DataGridViewCellStyle();
  1129. System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle5 = new System.Windows.Forms.DataGridViewCellStyle();
  1130. System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle6 = new System.Windows.Forms.DataGridViewCellStyle();
  1131. System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle7 = new System.Windows.Forms.DataGridViewCellStyle();
  1132. System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle8 = new System.Windows.Forms.DataGridViewCellStyle();
  1133. System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle9 = new System.Windows.Forms.DataGridViewCellStyle();
  1134. System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle10 = new System.Windows.Forms.DataGridViewCellStyle();
  1135. System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle11 = new System.Windows.Forms.DataGridViewCellStyle();
  1136. System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle12 = new System.Windows.Forms.DataGridViewCellStyle();
  1137. System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle13 = new System.Windows.Forms.DataGridViewCellStyle();
  1138. System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle14 = new System.Windows.Forms.DataGridViewCellStyle();
  1139. System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle15 = new System.Windows.Forms.DataGridViewCellStyle();
  1140. System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle16 = new System.Windows.Forms.DataGridViewCellStyle();
  1141. System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle17 = new System.Windows.Forms.DataGridViewCellStyle();
  1142. System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle18 = new System.Windows.Forms.DataGridViewCellStyle();
  1143. System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle19 = new System.Windows.Forms.DataGridViewCellStyle();
  1144. System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle20 = new System.Windows.Forms.DataGridViewCellStyle();
  1145. System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle21 = new System.Windows.Forms.DataGridViewCellStyle();
  1146. System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle22 = new System.Windows.Forms.DataGridViewCellStyle();
  1147. System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle23 = new System.Windows.Forms.DataGridViewCellStyle();
  1148. System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle24 = new System.Windows.Forms.DataGridViewCellStyle();
  1149. System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle25 = new System.Windows.Forms.DataGridViewCellStyle();
  1150. System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle26 = new System.Windows.Forms.DataGridViewCellStyle();
  1151. System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle27 = new System.Windows.Forms.DataGridViewCellStyle();
  1152. System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle28 = new System.Windows.Forms.DataGridViewCellStyle();
  1153. System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle29 = new System.Windows.Forms.DataGridViewCellStyle();
  1154. System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle30 = new System.Windows.Forms.DataGridViewCellStyle();
  1155. System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle31 = new System.Windows.Forms.DataGridViewCellStyle();
  1156. this.groupBox1 = new System.Windows.Forms.GroupBox();
  1157. this.button7 = new System.Windows.Forms.Button();
  1158. this.checkBox3 = new System.Windows.Forms.CheckBox();
  1159. this.button6 = new System.Windows.Forms.Button();
  1160. this.button5 = new System.Windows.Forms.Button();
  1161. this.button4 = new System.Windows.Forms.Button();
  1162. this.button3 = new System.Windows.Forms.Button();
  1163. this.comboBox1 = new System.Windows.Forms.ComboBox();
  1164. this.label1 = new System.Windows.Forms.Label();
  1165. this.button2 = new System.Windows.Forms.Button();
  1166. this.button1 = new System.Windows.Forms.Button();
  1167. this.listView1 = new System.Windows.Forms.ListView();
  1168. this.imageList1 = new System.Windows.Forms.ImageList(this.components);
  1169. this.groupBox2 = new System.Windows.Forms.GroupBox();
  1170. this.groupBox8 = new System.Windows.Forms.GroupBox();
  1171. this.button8 = new System.Windows.Forms.Button();
  1172. this.dataGridView2 = new System.Windows.Forms.DataGridView();
  1173. this.Column13 = new System.Windows.Forms.DataGridViewTextBoxColumn();
  1174. this.Column14 = new System.Windows.Forms.DataGridViewTextBoxColumn();
  1175. this.Column15 = new System.Windows.Forms.DataGridViewTextBoxColumn();
  1176. this.Column16 = new System.Windows.Forms.DataGridViewTextBoxColumn();
  1177. this.Column17 = new System.Windows.Forms.DataGridViewTextBoxColumn();
  1178. this.Column18 = new System.Windows.Forms.DataGridViewTextBoxColumn();
  1179. this.listView2 = new System.Windows.Forms.ListView();
  1180. this.numericUpDown1 = new System.Windows.Forms.NumericUpDown();
  1181. this.button16 = new System.Windows.Forms.Button();
  1182. this.label5 = new System.Windows.Forms.Label();
  1183. this.button14 = new System.Windows.Forms.Button();
  1184. this.button13 = new System.Windows.Forms.Button();
  1185. this.dataGridView4 = new System.Windows.Forms.DataGridView();
  1186. this.Column12 = new System.Windows.Forms.DataGridViewTextBoxColumn();
  1187. this.Column1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
  1188. this.Column2 = new System.Windows.Forms.DataGridViewTextBoxColumn();
  1189. this.Column3 = new System.Windows.Forms.DataGridViewTextBoxColumn();
  1190. this.Column4 = new System.Windows.Forms.DataGridViewTextBoxColumn();
  1191. this.Column5 = new System.Windows.Forms.DataGridViewTextBoxColumn();
  1192. this.Column6 = new System.Windows.Forms.DataGridViewTextBoxColumn();
  1193. this.Column7 = new System.Windows.Forms.DataGridViewTextBoxColumn();
  1194. this.Column8 = new System.Windows.Forms.DataGridViewTextBoxColumn();
  1195. this.Column9 = new System.Windows.Forms.DataGridViewTextBoxColumn();
  1196. this.Column10 = new System.Windows.Forms.DataGridViewTextBoxColumn();
  1197. this.button12 = new System.Windows.Forms.Button();
  1198. this.button11 = new System.Windows.Forms.Button();
  1199. this.groupBox7 = new System.Windows.Forms.GroupBox();
  1200. this.groupBox4 = new System.Windows.Forms.GroupBox();
  1201. this.textBox5 = new System.Windows.Forms.TextBox();
  1202. this.panel4 = new System.Windows.Forms.Panel();
  1203. this.label10 = new System.Windows.Forms.Label();
  1204. this.textBox4 = new System.Windows.Forms.TextBox();
  1205. this.textBox3 = new System.Windows.Forms.TextBox();
  1206. this.textBox2 = new System.Windows.Forms.TextBox();
  1207. this.numericUpDown4 = new System.Windows.Forms.NumericUpDown();
  1208. this.checkBox2 = new System.Windows.Forms.CheckBox();
  1209. this.label12 = new System.Windows.Forms.Label();
  1210. this.label11 = new System.Windows.Forms.Label();
  1211. this.label9 = new System.Windows.Forms.Label();
  1212. this.label8 = new System.Windows.Forms.Label();
  1213. this.label7 = new System.Windows.Forms.Label();
  1214. this.groupBox10 = new System.Windows.Forms.GroupBox();
  1215. this.groupBox11 = new System.Windows.Forms.GroupBox();
  1216. this.label18 = new System.Windows.Forms.Label();
  1217. this.rb_leftNoFill = new System.Windows.Forms.RadioButton();
  1218. this.rb_leftFill = new System.Windows.Forms.RadioButton();
  1219. this.panel1 = new System.Windows.Forms.Panel();
  1220. this.label19 = new System.Windows.Forms.Label();
  1221. this.txt_LeftLineWeight = new System.Windows.Forms.TextBox();
  1222. this.label20 = new System.Windows.Forms.Label();
  1223. this.txt_LeftSize = new System.Windows.Forms.TextBox();
  1224. this.label21 = new System.Windows.Forms.Label();
  1225. this.rb_LeftSquare = new System.Windows.Forms.RadioButton();
  1226. this.rb_LeftCircle = new System.Windows.Forms.RadioButton();
  1227. this.label22 = new System.Windows.Forms.Label();
  1228. this.groupBox9 = new System.Windows.Forms.GroupBox();
  1229. this.dataGridView3 = new System.Windows.Forms.DataGridView();
  1230. this.dataGridViewTextBoxColumn5 = new System.Windows.Forms.DataGridViewTextBoxColumn();
  1231. this.dataGridViewTextBoxColumn6 = new System.Windows.Forms.DataGridViewTextBoxColumn();
  1232. this.dataGridViewTextBoxColumn7 = new System.Windows.Forms.DataGridViewTextBoxColumn();
  1233. this.dataGridViewTextBoxColumn8 = new System.Windows.Forms.DataGridViewTextBoxColumn();
  1234. this.dataGridViewTextBoxColumn9 = new System.Windows.Forms.DataGridViewTextBoxColumn();
  1235. this.dataGridView1 = new System.Windows.Forms.DataGridView();
  1236. this.Column11 = new System.Windows.Forms.DataGridViewTextBoxColumn();
  1237. this.dataGridViewTextBoxColumn1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
  1238. this.dataGridViewTextBoxColumn2 = new System.Windows.Forms.DataGridViewTextBoxColumn();
  1239. this.dataGridViewTextBoxColumn3 = new System.Windows.Forms.DataGridViewTextBoxColumn();
  1240. this.dataGridViewTextBoxColumn4 = new System.Windows.Forms.DataGridViewTextBoxColumn();
  1241. this.groupBox12 = new System.Windows.Forms.GroupBox();
  1242. this.checkBox5 = new System.Windows.Forms.CheckBox();
  1243. this.checkBox4 = new System.Windows.Forms.CheckBox();
  1244. this.toolTip1 = new System.Windows.Forms.ToolTip(this.components);
  1245. this.groupBox1.SuspendLayout();
  1246. this.groupBox2.SuspendLayout();
  1247. this.groupBox8.SuspendLayout();
  1248. ((System.ComponentModel.ISupportInitialize)(this.dataGridView2)).BeginInit();
  1249. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).BeginInit();
  1250. ((System.ComponentModel.ISupportInitialize)(this.dataGridView4)).BeginInit();
  1251. this.groupBox4.SuspendLayout();
  1252. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown4)).BeginInit();
  1253. this.groupBox10.SuspendLayout();
  1254. this.groupBox11.SuspendLayout();
  1255. this.groupBox9.SuspendLayout();
  1256. ((System.ComponentModel.ISupportInitialize)(this.dataGridView3)).BeginInit();
  1257. ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit();
  1258. this.groupBox12.SuspendLayout();
  1259. this.SuspendLayout();
  1260. //
  1261. // groupBox1
  1262. //
  1263. this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
  1264. | System.Windows.Forms.AnchorStyles.Right)));
  1265. this.groupBox1.Controls.Add(this.button7);
  1266. this.groupBox1.Controls.Add(this.checkBox3);
  1267. this.groupBox1.Controls.Add(this.button6);
  1268. this.groupBox1.Controls.Add(this.button5);
  1269. this.groupBox1.Controls.Add(this.button4);
  1270. this.groupBox1.Controls.Add(this.button3);
  1271. this.groupBox1.Controls.Add(this.comboBox1);
  1272. this.groupBox1.Controls.Add(this.label1);
  1273. this.groupBox1.Controls.Add(this.button2);
  1274. this.groupBox1.Controls.Add(this.button1);
  1275. this.groupBox1.Location = new System.Drawing.Point(14, 3);
  1276. this.groupBox1.Name = "groupBox1";
  1277. this.groupBox1.Size = new System.Drawing.Size(1081, 50);
  1278. this.groupBox1.TabIndex = 2;
  1279. this.groupBox1.TabStop = false;
  1280. //
  1281. // button7
  1282. //
  1283. this.button7.BackColor = System.Drawing.SystemColors.Control;
  1284. this.button7.Location = new System.Drawing.Point(499, 13);
  1285. this.button7.Name = "button7";
  1286. this.button7.Size = new System.Drawing.Size(72, 30);
  1287. this.button7.TabIndex = 22;
  1288. this.button7.UseVisualStyleBackColor = false;
  1289. this.button7.Click += new System.EventHandler(this.button7_Click);
  1290. //
  1291. // checkBox3
  1292. //
  1293. this.checkBox3.AutoEllipsis = true;
  1294. this.checkBox3.ForeColor = System.Drawing.SystemColors.ActiveCaptionText;
  1295. this.checkBox3.Location = new System.Drawing.Point(621, 19);
  1296. this.checkBox3.Name = "checkBox3";
  1297. this.checkBox3.Size = new System.Drawing.Size(236, 20);
  1298. this.checkBox3.TabIndex = 21;
  1299. this.checkBox3.UseVisualStyleBackColor = true;
  1300. //
  1301. // button6
  1302. //
  1303. this.button6.BackColor = System.Drawing.SystemColors.Control;
  1304. this.button6.Location = new System.Drawing.Point(499, 13);
  1305. this.button6.Name = "button6";
  1306. this.button6.Size = new System.Drawing.Size(72, 30);
  1307. this.button6.TabIndex = 9;
  1308. this.button6.UseVisualStyleBackColor = false;
  1309. this.button6.Click += new System.EventHandler(this.button6_Click);
  1310. //
  1311. // button5
  1312. //
  1313. this.button5.BackColor = System.Drawing.SystemColors.Control;
  1314. this.button5.Location = new System.Drawing.Point(421, 13);
  1315. this.button5.Name = "button5";
  1316. this.button5.Size = new System.Drawing.Size(72, 30);
  1317. this.button5.TabIndex = 8;
  1318. this.button5.UseVisualStyleBackColor = false;
  1319. this.button5.Click += new System.EventHandler(this.button5_Click);
  1320. //
  1321. // button4
  1322. //
  1323. this.button4.BackColor = System.Drawing.SystemColors.Control;
  1324. this.button4.Location = new System.Drawing.Point(331, 13);
  1325. this.button4.Name = "button4";
  1326. this.button4.Size = new System.Drawing.Size(84, 30);
  1327. this.button4.TabIndex = 7;
  1328. this.button4.UseVisualStyleBackColor = false;
  1329. this.button4.Click += new System.EventHandler(this.button4_Click);
  1330. //
  1331. // button3
  1332. //
  1333. this.button3.BackColor = System.Drawing.SystemColors.Control;
  1334. this.button3.Location = new System.Drawing.Point(253, 13);
  1335. this.button3.Name = "button3";
  1336. this.button3.Size = new System.Drawing.Size(72, 30);
  1337. this.button3.TabIndex = 6;
  1338. this.button3.UseVisualStyleBackColor = false;
  1339. this.button3.Click += new System.EventHandler(this.button3_Click);
  1340. //
  1341. // comboBox1
  1342. //
  1343. this.comboBox1.FormattingEnabled = true;
  1344. this.comboBox1.Location = new System.Drawing.Point(78, 19);
  1345. this.comboBox1.Name = "comboBox1";
  1346. this.comboBox1.Size = new System.Drawing.Size(159, 20);
  1347. this.comboBox1.TabIndex = 5;
  1348. this.comboBox1.SelectedIndexChanged += new System.EventHandler(this.comboBox1_SelectedIndexChanged);
  1349. //
  1350. // label1
  1351. //
  1352. this.label1.AutoEllipsis = true;
  1353. this.label1.Location = new System.Drawing.Point(18, 23);
  1354. this.label1.Name = "label1";
  1355. this.label1.Size = new System.Drawing.Size(50, 12);
  1356. this.label1.TabIndex = 4;
  1357. //
  1358. // button2
  1359. //
  1360. this.button2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
  1361. this.button2.BackColor = System.Drawing.SystemColors.Control;
  1362. this.button2.Location = new System.Drawing.Point(985, 14);
  1363. this.button2.Name = "button2";
  1364. this.button2.Size = new System.Drawing.Size(84, 30);
  1365. this.button2.TabIndex = 3;
  1366. this.button2.UseVisualStyleBackColor = false;
  1367. this.button2.Click += new System.EventHandler(this.button2_Click);
  1368. //
  1369. // button1
  1370. //
  1371. this.button1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
  1372. this.button1.BackColor = System.Drawing.SystemColors.Control;
  1373. this.button1.Location = new System.Drawing.Point(895, 14);
  1374. this.button1.Name = "button1";
  1375. this.button1.Size = new System.Drawing.Size(84, 30);
  1376. this.button1.TabIndex = 0;
  1377. this.button1.UseVisualStyleBackColor = false;
  1378. this.button1.Click += new System.EventHandler(this.button1_Click);
  1379. //
  1380. // listView1
  1381. //
  1382. this.listView1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  1383. | System.Windows.Forms.AnchorStyles.Left)
  1384. | System.Windows.Forms.AnchorStyles.Right)));
  1385. this.listView1.FullRowSelect = true;
  1386. this.listView1.HideSelection = false;
  1387. this.listView1.LargeImageList = this.imageList1;
  1388. this.listView1.Location = new System.Drawing.Point(5, 17);
  1389. this.listView1.MultiSelect = false;
  1390. this.listView1.Name = "listView1";
  1391. this.listView1.Size = new System.Drawing.Size(124, 609);
  1392. this.listView1.TabIndex = 0;
  1393. this.listView1.UseCompatibleStateImageBehavior = false;
  1394. this.listView1.SelectedIndexChanged += new System.EventHandler(this.listView1_SelectedIndexChanged);
  1395. this.listView1.MouseDown += new System.Windows.Forms.MouseEventHandler(this.listView1_MouseDown);
  1396. this.listView1.MouseUp += new System.Windows.Forms.MouseEventHandler(this.listView1_MouseUp);
  1397. //
  1398. // imageList1
  1399. //
  1400. this.imageList1.ColorDepth = System.Windows.Forms.ColorDepth.Depth8Bit;
  1401. this.imageList1.ImageSize = new System.Drawing.Size(64, 64);
  1402. this.imageList1.TransparentColor = System.Drawing.Color.Transparent;
  1403. //
  1404. // groupBox2
  1405. //
  1406. this.groupBox2.Controls.Add(this.listView1);
  1407. this.groupBox2.Location = new System.Drawing.Point(14, 59);
  1408. this.groupBox2.Name = "groupBox2";
  1409. this.groupBox2.Size = new System.Drawing.Size(135, 634);
  1410. this.groupBox2.TabIndex = 3;
  1411. this.groupBox2.TabStop = false;
  1412. //
  1413. // groupBox8
  1414. //
  1415. this.groupBox8.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  1416. | System.Windows.Forms.AnchorStyles.Left)
  1417. | System.Windows.Forms.AnchorStyles.Right)));
  1418. this.groupBox8.Controls.Add(this.button8);
  1419. this.groupBox8.Controls.Add(this.dataGridView2);
  1420. this.groupBox8.Controls.Add(this.listView2);
  1421. this.groupBox8.Controls.Add(this.numericUpDown1);
  1422. this.groupBox8.Controls.Add(this.button16);
  1423. this.groupBox8.Controls.Add(this.label5);
  1424. this.groupBox8.Controls.Add(this.button14);
  1425. this.groupBox8.Controls.Add(this.button13);
  1426. this.groupBox8.Controls.Add(this.dataGridView4);
  1427. this.groupBox8.Controls.Add(this.button12);
  1428. this.groupBox8.Controls.Add(this.button11);
  1429. this.groupBox8.Location = new System.Drawing.Point(14, 699);
  1430. this.groupBox8.Name = "groupBox8";
  1431. this.groupBox8.Size = new System.Drawing.Size(1081, 234);
  1432. this.groupBox8.TabIndex = 10;
  1433. this.groupBox8.TabStop = false;
  1434. //
  1435. // button8
  1436. //
  1437. this.button8.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
  1438. this.button8.BackColor = System.Drawing.SystemColors.Control;
  1439. this.button8.Location = new System.Drawing.Point(941, 102);
  1440. this.button8.Name = "button8";
  1441. this.button8.Size = new System.Drawing.Size(128, 26);
  1442. this.button8.TabIndex = 24;
  1443. this.button8.UseVisualStyleBackColor = false;
  1444. this.button8.Click += new System.EventHandler(this.button8_Click);
  1445. //
  1446. // dataGridView2
  1447. //
  1448. this.dataGridView2.AllowUserToAddRows = false;
  1449. this.dataGridView2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
  1450. | System.Windows.Forms.AnchorStyles.Right)));
  1451. this.dataGridView2.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill;
  1452. this.dataGridView2.BackgroundColor = System.Drawing.SystemColors.ControlLightLight;
  1453. dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
  1454. dataGridViewCellStyle1.BackColor = System.Drawing.SystemColors.Control;
  1455. dataGridViewCellStyle1.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
  1456. dataGridViewCellStyle1.ForeColor = System.Drawing.SystemColors.WindowText;
  1457. dataGridViewCellStyle1.SelectionBackColor = System.Drawing.SystemColors.Highlight;
  1458. dataGridViewCellStyle1.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
  1459. dataGridViewCellStyle1.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
  1460. this.dataGridView2.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle1;
  1461. this.dataGridView2.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
  1462. this.dataGridView2.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
  1463. this.Column13,
  1464. this.Column14,
  1465. this.Column15,
  1466. this.Column16,
  1467. this.Column17,
  1468. this.Column18});
  1469. this.dataGridView2.Location = new System.Drawing.Point(228, 11);
  1470. this.dataGridView2.MultiSelect = false;
  1471. this.dataGridView2.Name = "dataGridView2";
  1472. this.dataGridView2.ReadOnly = true;
  1473. this.dataGridView2.RowHeadersVisible = false;
  1474. this.dataGridView2.RowTemplate.Height = 23;
  1475. this.dataGridView2.Size = new System.Drawing.Size(693, 97);
  1476. this.dataGridView2.TabIndex = 23;
  1477. //
  1478. // Column13
  1479. //
  1480. dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
  1481. this.Column13.DefaultCellStyle = dataGridViewCellStyle2;
  1482. this.Column13.Name = "Column13";
  1483. this.Column13.ReadOnly = true;
  1484. //
  1485. // Column14
  1486. //
  1487. dataGridViewCellStyle3.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
  1488. this.Column14.DefaultCellStyle = dataGridViewCellStyle3;
  1489. this.Column14.Name = "Column14";
  1490. this.Column14.ReadOnly = true;
  1491. //
  1492. // Column15
  1493. //
  1494. dataGridViewCellStyle4.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
  1495. this.Column15.DefaultCellStyle = dataGridViewCellStyle4;
  1496. this.Column15.HeaderText = "NL⊥";
  1497. this.Column15.Name = "Column15";
  1498. this.Column15.ReadOnly = true;
  1499. //
  1500. // Column16
  1501. //
  1502. dataGridViewCellStyle5.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
  1503. this.Column16.DefaultCellStyle = dataGridViewCellStyle5;
  1504. this.Column16.HeaderText = "NL∥";
  1505. this.Column16.Name = "Column16";
  1506. this.Column16.ReadOnly = true;
  1507. //
  1508. // Column17
  1509. //
  1510. dataGridViewCellStyle6.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
  1511. this.Column17.DefaultCellStyle = dataGridViewCellStyle6;
  1512. this.Column17.HeaderText = "PL⊥";
  1513. this.Column17.Name = "Column17";
  1514. this.Column17.ReadOnly = true;
  1515. //
  1516. // Column18
  1517. //
  1518. dataGridViewCellStyle7.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
  1519. this.Column18.DefaultCellStyle = dataGridViewCellStyle7;
  1520. this.Column18.HeaderText = "PL∥";
  1521. this.Column18.Name = "Column18";
  1522. this.Column18.ReadOnly = true;
  1523. //
  1524. // listView2
  1525. //
  1526. this.listView2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  1527. | System.Windows.Forms.AnchorStyles.Left)));
  1528. this.listView2.FullRowSelect = true;
  1529. this.listView2.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.None;
  1530. this.listView2.HideSelection = false;
  1531. this.listView2.Location = new System.Drawing.Point(16, 56);
  1532. this.listView2.Name = "listView2";
  1533. this.listView2.Size = new System.Drawing.Size(180, 171);
  1534. this.listView2.TabIndex = 22;
  1535. this.listView2.UseCompatibleStateImageBehavior = false;
  1536. this.listView2.ItemSelectionChanged += new System.Windows.Forms.ListViewItemSelectionChangedEventHandler(this.listView2_ItemSelectionChanged);
  1537. this.listView2.SelectedIndexChanged += new System.EventHandler(this.listView2_SelectedIndexChanged);
  1538. //
  1539. // numericUpDown1
  1540. //
  1541. this.numericUpDown1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
  1542. this.numericUpDown1.Location = new System.Drawing.Point(985, 176);
  1543. this.numericUpDown1.Maximum = new decimal(new int[] {
  1544. 10,
  1545. 0,
  1546. 0,
  1547. 0});
  1548. this.numericUpDown1.Name = "numericUpDown1";
  1549. this.numericUpDown1.Size = new System.Drawing.Size(56, 21);
  1550. this.numericUpDown1.TabIndex = 21;
  1551. this.numericUpDown1.Value = new decimal(new int[] {
  1552. 4,
  1553. 0,
  1554. 0,
  1555. 0});
  1556. this.numericUpDown1.ValueChanged += new System.EventHandler(this.numericUpDown1_ValueChanged);
  1557. //
  1558. // button16
  1559. //
  1560. this.button16.BackColor = System.Drawing.SystemColors.Control;
  1561. this.button16.Location = new System.Drawing.Point(15, 20);
  1562. this.button16.Name = "button16";
  1563. this.button16.Size = new System.Drawing.Size(93, 26);
  1564. this.button16.TabIndex = 20;
  1565. this.button16.UseVisualStyleBackColor = false;
  1566. this.button16.Click += new System.EventHandler(this.button16_Click);
  1567. //
  1568. // label5
  1569. //
  1570. this.label5.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
  1571. this.label5.AutoSize = true;
  1572. this.label5.Location = new System.Drawing.Point(946, 182);
  1573. this.label5.Name = "label5";
  1574. this.label5.Size = new System.Drawing.Size(0, 12);
  1575. this.label5.TabIndex = 18;
  1576. //
  1577. // button14
  1578. //
  1579. this.button14.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
  1580. this.button14.BackColor = System.Drawing.SystemColors.Control;
  1581. this.button14.Location = new System.Drawing.Point(941, 68);
  1582. this.button14.Name = "button14";
  1583. this.button14.Size = new System.Drawing.Size(128, 26);
  1584. this.button14.TabIndex = 16;
  1585. this.button14.UseVisualStyleBackColor = false;
  1586. this.button14.Click += new System.EventHandler(this.button14_Click);
  1587. //
  1588. // button13
  1589. //
  1590. this.button13.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
  1591. this.button13.BackColor = System.Drawing.SystemColors.Control;
  1592. this.button13.Location = new System.Drawing.Point(941, 34);
  1593. this.button13.Name = "button13";
  1594. this.button13.Size = new System.Drawing.Size(128, 26);
  1595. this.button13.TabIndex = 12;
  1596. this.button13.UseVisualStyleBackColor = false;
  1597. this.button13.Click += new System.EventHandler(this.button13_Click);
  1598. //
  1599. // dataGridView4
  1600. //
  1601. this.dataGridView4.AllowUserToAddRows = false;
  1602. this.dataGridView4.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  1603. | System.Windows.Forms.AnchorStyles.Left)
  1604. | System.Windows.Forms.AnchorStyles.Right)));
  1605. this.dataGridView4.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill;
  1606. this.dataGridView4.BackgroundColor = System.Drawing.SystemColors.ControlLightLight;
  1607. dataGridViewCellStyle8.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
  1608. dataGridViewCellStyle8.BackColor = System.Drawing.SystemColors.Control;
  1609. dataGridViewCellStyle8.Font = new System.Drawing.Font("宋体", 9F);
  1610. dataGridViewCellStyle8.ForeColor = System.Drawing.SystemColors.WindowText;
  1611. dataGridViewCellStyle8.SelectionBackColor = System.Drawing.SystemColors.Highlight;
  1612. dataGridViewCellStyle8.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
  1613. dataGridViewCellStyle8.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
  1614. this.dataGridView4.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle8;
  1615. this.dataGridView4.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
  1616. this.dataGridView4.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
  1617. this.Column12,
  1618. this.Column1,
  1619. this.Column2,
  1620. this.Column3,
  1621. this.Column4,
  1622. this.Column5,
  1623. this.Column6,
  1624. this.Column7,
  1625. this.Column8,
  1626. this.Column9,
  1627. this.Column10});
  1628. this.dataGridView4.Location = new System.Drawing.Point(228, 114);
  1629. this.dataGridView4.Name = "dataGridView4";
  1630. this.dataGridView4.ReadOnly = true;
  1631. this.dataGridView4.RowHeadersVisible = false;
  1632. this.dataGridView4.RowTemplate.Height = 23;
  1633. this.dataGridView4.Size = new System.Drawing.Size(693, 113);
  1634. this.dataGridView4.TabIndex = 15;
  1635. //
  1636. // Column12
  1637. //
  1638. dataGridViewCellStyle9.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
  1639. this.Column12.DefaultCellStyle = dataGridViewCellStyle9;
  1640. this.Column12.Name = "Column12";
  1641. this.Column12.ReadOnly = true;
  1642. //
  1643. // Column1
  1644. //
  1645. dataGridViewCellStyle10.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
  1646. this.Column1.DefaultCellStyle = dataGridViewCellStyle10;
  1647. this.Column1.Name = "Column1";
  1648. this.Column1.ReadOnly = true;
  1649. //
  1650. // Column2
  1651. //
  1652. dataGridViewCellStyle11.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
  1653. this.Column2.DefaultCellStyle = dataGridViewCellStyle11;
  1654. this.Column2.Name = "Column2";
  1655. this.Column2.ReadOnly = true;
  1656. //
  1657. // Column3
  1658. //
  1659. dataGridViewCellStyle12.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
  1660. this.Column3.DefaultCellStyle = dataGridViewCellStyle12;
  1661. this.Column3.Name = "Column3";
  1662. this.Column3.ReadOnly = true;
  1663. //
  1664. // Column4
  1665. //
  1666. dataGridViewCellStyle13.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
  1667. this.Column4.DefaultCellStyle = dataGridViewCellStyle13;
  1668. this.Column4.HeaderText = "Ω12(N)";
  1669. this.Column4.Name = "Column4";
  1670. this.Column4.ReadOnly = true;
  1671. //
  1672. // Column5
  1673. //
  1674. dataGridViewCellStyle14.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
  1675. this.Column5.DefaultCellStyle = dataGridViewCellStyle14;
  1676. this.Column5.Name = "Column5";
  1677. this.Column5.ReadOnly = true;
  1678. //
  1679. // Column6
  1680. //
  1681. dataGridViewCellStyle15.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
  1682. this.Column6.DefaultCellStyle = dataGridViewCellStyle15;
  1683. this.Column6.Name = "Column6";
  1684. this.Column6.ReadOnly = true;
  1685. //
  1686. // Column7
  1687. //
  1688. dataGridViewCellStyle16.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
  1689. this.Column7.DefaultCellStyle = dataGridViewCellStyle16;
  1690. this.Column7.Name = "Column7";
  1691. this.Column7.ReadOnly = true;
  1692. //
  1693. // Column8
  1694. //
  1695. dataGridViewCellStyle17.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
  1696. this.Column8.DefaultCellStyle = dataGridViewCellStyle17;
  1697. this.Column8.HeaderText = "Ω12(P)";
  1698. this.Column8.Name = "Column8";
  1699. this.Column8.ReadOnly = true;
  1700. //
  1701. // Column9
  1702. //
  1703. dataGridViewCellStyle18.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
  1704. this.Column9.DefaultCellStyle = dataGridViewCellStyle18;
  1705. this.Column9.HeaderText = "SB⊥(mm)";
  1706. this.Column9.Name = "Column9";
  1707. this.Column9.ReadOnly = true;
  1708. //
  1709. // Column10
  1710. //
  1711. dataGridViewCellStyle19.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
  1712. this.Column10.DefaultCellStyle = dataGridViewCellStyle19;
  1713. this.Column10.HeaderText = "λ⊥(mm)";
  1714. this.Column10.Name = "Column10";
  1715. this.Column10.ReadOnly = true;
  1716. //
  1717. // button12
  1718. //
  1719. this.button12.BackColor = System.Drawing.SystemColors.Control;
  1720. this.button12.Location = new System.Drawing.Point(145, 20);
  1721. this.button12.Name = "button12";
  1722. this.button12.Size = new System.Drawing.Size(52, 26);
  1723. this.button12.TabIndex = 13;
  1724. this.button12.UseVisualStyleBackColor = false;
  1725. this.button12.Click += new System.EventHandler(this.button12_Click);
  1726. //
  1727. // button11
  1728. //
  1729. this.button11.BackColor = System.Drawing.SystemColors.Control;
  1730. this.button11.Location = new System.Drawing.Point(15, 20);
  1731. this.button11.Name = "button11";
  1732. this.button11.Size = new System.Drawing.Size(63, 26);
  1733. this.button11.TabIndex = 12;
  1734. this.button11.UseVisualStyleBackColor = false;
  1735. this.button11.Click += new System.EventHandler(this.button11_Click);
  1736. //
  1737. // groupBox7
  1738. //
  1739. this.groupBox7.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
  1740. | System.Windows.Forms.AnchorStyles.Right)));
  1741. this.groupBox7.Location = new System.Drawing.Point(515, 59);
  1742. this.groupBox7.Name = "groupBox7";
  1743. this.groupBox7.Size = new System.Drawing.Size(580, 634);
  1744. this.groupBox7.TabIndex = 11;
  1745. this.groupBox7.TabStop = false;
  1746. //
  1747. // groupBox4
  1748. //
  1749. this.groupBox4.Controls.Add(this.textBox5);
  1750. this.groupBox4.Controls.Add(this.panel4);
  1751. this.groupBox4.Controls.Add(this.label10);
  1752. this.groupBox4.Controls.Add(this.textBox4);
  1753. this.groupBox4.Controls.Add(this.textBox3);
  1754. this.groupBox4.Controls.Add(this.textBox2);
  1755. this.groupBox4.Controls.Add(this.numericUpDown4);
  1756. this.groupBox4.Controls.Add(this.checkBox2);
  1757. this.groupBox4.Controls.Add(this.label12);
  1758. this.groupBox4.Controls.Add(this.label11);
  1759. this.groupBox4.Controls.Add(this.label9);
  1760. this.groupBox4.Controls.Add(this.label8);
  1761. this.groupBox4.Controls.Add(this.label7);
  1762. this.groupBox4.Location = new System.Drawing.Point(156, 352);
  1763. this.groupBox4.Name = "groupBox4";
  1764. this.groupBox4.Size = new System.Drawing.Size(352, 73);
  1765. this.groupBox4.TabIndex = 13;
  1766. this.groupBox4.TabStop = false;
  1767. //
  1768. // textBox5
  1769. //
  1770. this.textBox5.Location = new System.Drawing.Point(288, 46);
  1771. this.textBox5.Name = "textBox5";
  1772. this.textBox5.Size = new System.Drawing.Size(49, 21);
  1773. this.textBox5.TabIndex = 13;
  1774. this.textBox5.TextChanged += new System.EventHandler(this.textBox5_TextChanged);
  1775. this.textBox5.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.textBox5_KeyPress);
  1776. //
  1777. // panel4
  1778. //
  1779. this.panel4.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
  1780. this.panel4.Location = new System.Drawing.Point(83, 49);
  1781. this.panel4.Name = "panel4";
  1782. this.panel4.Size = new System.Drawing.Size(80, 17);
  1783. this.panel4.TabIndex = 28;
  1784. this.panel4.BackColorChanged += new System.EventHandler(this.panel4_BackColorChanged);
  1785. this.panel4.Click += new System.EventHandler(this.panel4_Click);
  1786. //
  1787. // label10
  1788. //
  1789. this.label10.AutoSize = true;
  1790. this.label10.Location = new System.Drawing.Point(224, 51);
  1791. this.label10.Name = "label10";
  1792. this.label10.Size = new System.Drawing.Size(0, 12);
  1793. this.label10.TabIndex = 5;
  1794. //
  1795. // textBox4
  1796. //
  1797. this.textBox4.Location = new System.Drawing.Point(284, 19);
  1798. this.textBox4.Name = "textBox4";
  1799. this.textBox4.Size = new System.Drawing.Size(35, 21);
  1800. this.textBox4.TabIndex = 12;
  1801. this.textBox4.TextChanged += new System.EventHandler(this.textBox4_TextChanged);
  1802. this.textBox4.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.textBox4_KeyPress);
  1803. //
  1804. // textBox3
  1805. //
  1806. this.textBox3.Location = new System.Drawing.Point(176, 19);
  1807. this.textBox3.Name = "textBox3";
  1808. this.textBox3.Size = new System.Drawing.Size(35, 21);
  1809. this.textBox3.TabIndex = 11;
  1810. this.textBox3.TextChanged += new System.EventHandler(this.textBox3_TextChanged);
  1811. this.textBox3.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.textBox3_KeyPress);
  1812. //
  1813. // textBox2
  1814. //
  1815. this.textBox2.Location = new System.Drawing.Point(74, 19);
  1816. this.textBox2.Name = "textBox2";
  1817. this.textBox2.Size = new System.Drawing.Size(35, 21);
  1818. this.textBox2.TabIndex = 10;
  1819. this.textBox2.TextChanged += new System.EventHandler(this.textBox2_TextChanged);
  1820. this.textBox2.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.textBox2_KeyPress);
  1821. //
  1822. // numericUpDown4
  1823. //
  1824. this.numericUpDown4.Location = new System.Drawing.Point(262, 46);
  1825. this.numericUpDown4.Maximum = new decimal(new int[] {
  1826. 999999,
  1827. 0,
  1828. 0,
  1829. 0});
  1830. this.numericUpDown4.Name = "numericUpDown4";
  1831. this.numericUpDown4.Size = new System.Drawing.Size(49, 21);
  1832. this.numericUpDown4.TabIndex = 9;
  1833. this.numericUpDown4.ValueChanged += new System.EventHandler(this.numericUpDown4_ValueChanged);
  1834. //
  1835. // checkBox2
  1836. //
  1837. this.checkBox2.AutoSize = true;
  1838. this.checkBox2.Location = new System.Drawing.Point(173, 51);
  1839. this.checkBox2.Name = "checkBox2";
  1840. this.checkBox2.Size = new System.Drawing.Size(15, 14);
  1841. this.checkBox2.TabIndex = 8;
  1842. this.checkBox2.UseVisualStyleBackColor = true;
  1843. this.checkBox2.CheckedChanged += new System.EventHandler(this.checkBox2_CheckedChanged);
  1844. //
  1845. // label12
  1846. //
  1847. this.label12.AutoSize = true;
  1848. this.label12.Location = new System.Drawing.Point(224, 51);
  1849. this.label12.Name = "label12";
  1850. this.label12.Size = new System.Drawing.Size(0, 12);
  1851. this.label12.TabIndex = 7;
  1852. //
  1853. // label11
  1854. //
  1855. this.label11.AutoSize = true;
  1856. this.label11.Location = new System.Drawing.Point(16, 51);
  1857. this.label11.Name = "label11";
  1858. this.label11.Size = new System.Drawing.Size(0, 12);
  1859. this.label11.TabIndex = 6;
  1860. //
  1861. // label9
  1862. //
  1863. this.label9.AutoSize = true;
  1864. this.label9.Location = new System.Drawing.Point(115, 22);
  1865. this.label9.Name = "label9";
  1866. this.label9.Size = new System.Drawing.Size(0, 12);
  1867. this.label9.TabIndex = 4;
  1868. //
  1869. // label8
  1870. //
  1871. this.label8.AutoSize = true;
  1872. this.label8.Location = new System.Drawing.Point(16, 22);
  1873. this.label8.Name = "label8";
  1874. this.label8.Size = new System.Drawing.Size(0, 12);
  1875. this.label8.TabIndex = 3;
  1876. //
  1877. // label7
  1878. //
  1879. this.label7.AutoSize = true;
  1880. this.label7.Location = new System.Drawing.Point(217, 22);
  1881. this.label7.Name = "label7";
  1882. this.label7.Size = new System.Drawing.Size(0, 12);
  1883. this.label7.TabIndex = 2;
  1884. //
  1885. // groupBox10
  1886. //
  1887. this.groupBox10.Controls.Add(this.groupBox11);
  1888. this.groupBox10.Controls.Add(this.panel1);
  1889. this.groupBox10.Controls.Add(this.label19);
  1890. this.groupBox10.Controls.Add(this.txt_LeftLineWeight);
  1891. this.groupBox10.Controls.Add(this.label20);
  1892. this.groupBox10.Controls.Add(this.txt_LeftSize);
  1893. this.groupBox10.Controls.Add(this.label21);
  1894. this.groupBox10.Controls.Add(this.rb_LeftSquare);
  1895. this.groupBox10.Controls.Add(this.rb_LeftCircle);
  1896. this.groupBox10.Controls.Add(this.label22);
  1897. this.groupBox10.Location = new System.Drawing.Point(156, 433);
  1898. this.groupBox10.Name = "groupBox10";
  1899. this.groupBox10.Size = new System.Drawing.Size(352, 82);
  1900. this.groupBox10.TabIndex = 18;
  1901. this.groupBox10.TabStop = false;
  1902. //
  1903. // groupBox11
  1904. //
  1905. this.groupBox11.Controls.Add(this.label18);
  1906. this.groupBox11.Controls.Add(this.rb_leftNoFill);
  1907. this.groupBox11.Controls.Add(this.rb_leftFill);
  1908. this.groupBox11.Location = new System.Drawing.Point(171, 8);
  1909. this.groupBox11.Name = "groupBox11";
  1910. this.groupBox11.Size = new System.Drawing.Size(173, 38);
  1911. this.groupBox11.TabIndex = 25;
  1912. this.groupBox11.TabStop = false;
  1913. //
  1914. // label18
  1915. //
  1916. this.label18.AutoSize = true;
  1917. this.label18.Location = new System.Drawing.Point(12, 16);
  1918. this.label18.Name = "label18";
  1919. this.label18.Size = new System.Drawing.Size(0, 12);
  1920. this.label18.TabIndex = 22;
  1921. //
  1922. // rb_leftNoFill
  1923. //
  1924. this.rb_leftNoFill.AutoSize = true;
  1925. this.rb_leftNoFill.Checked = true;
  1926. this.rb_leftNoFill.Location = new System.Drawing.Point(112, 14);
  1927. this.rb_leftNoFill.Name = "rb_leftNoFill";
  1928. this.rb_leftNoFill.Size = new System.Drawing.Size(14, 13);
  1929. this.rb_leftNoFill.TabIndex = 20;
  1930. this.rb_leftNoFill.TabStop = true;
  1931. this.rb_leftNoFill.UseVisualStyleBackColor = true;
  1932. //
  1933. // rb_leftFill
  1934. //
  1935. this.rb_leftFill.AutoSize = true;
  1936. this.rb_leftFill.Location = new System.Drawing.Point(53, 14);
  1937. this.rb_leftFill.Name = "rb_leftFill";
  1938. this.rb_leftFill.Size = new System.Drawing.Size(14, 13);
  1939. this.rb_leftFill.TabIndex = 19;
  1940. this.rb_leftFill.UseVisualStyleBackColor = true;
  1941. this.rb_leftFill.CheckedChanged += new System.EventHandler(this.rb_leftFill_CheckedChanged);
  1942. //
  1943. // panel1
  1944. //
  1945. this.panel1.BackColor = System.Drawing.Color.Yellow;
  1946. this.panel1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
  1947. this.panel1.Location = new System.Drawing.Point(262, 54);
  1948. this.panel1.Name = "panel1";
  1949. this.panel1.Size = new System.Drawing.Size(79, 21);
  1950. this.panel1.TabIndex = 25;
  1951. this.panel1.BackColorChanged += new System.EventHandler(this.panel1_BackColorChanged);
  1952. this.panel1.Click += new System.EventHandler(this.panel1_Click);
  1953. //
  1954. // label19
  1955. //
  1956. this.label19.AutoSize = true;
  1957. this.label19.Location = new System.Drawing.Point(224, 57);
  1958. this.label19.Name = "label19";
  1959. this.label19.Size = new System.Drawing.Size(0, 12);
  1960. this.label19.TabIndex = 10;
  1961. //
  1962. // txt_LeftLineWeight
  1963. //
  1964. this.txt_LeftLineWeight.Location = new System.Drawing.Point(158, 54);
  1965. this.txt_LeftLineWeight.Name = "txt_LeftLineWeight";
  1966. this.txt_LeftLineWeight.Size = new System.Drawing.Size(45, 21);
  1967. this.txt_LeftLineWeight.TabIndex = 9;
  1968. this.txt_LeftLineWeight.Text = "2";
  1969. this.txt_LeftLineWeight.TextChanged += new System.EventHandler(this.txt_LeftLineWeight_TextChanged);
  1970. this.txt_LeftLineWeight.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.textBoxLeftWidth_KeyPress);
  1971. //
  1972. // label20
  1973. //
  1974. this.label20.AutoSize = true;
  1975. this.label20.Location = new System.Drawing.Point(121, 57);
  1976. this.label20.Name = "label20";
  1977. this.label20.Size = new System.Drawing.Size(0, 12);
  1978. this.label20.TabIndex = 8;
  1979. //
  1980. // txt_LeftSize
  1981. //
  1982. this.txt_LeftSize.Location = new System.Drawing.Point(62, 54);
  1983. this.txt_LeftSize.Name = "txt_LeftSize";
  1984. this.txt_LeftSize.Size = new System.Drawing.Size(45, 21);
  1985. this.txt_LeftSize.TabIndex = 7;
  1986. this.txt_LeftSize.Text = "3";
  1987. this.txt_LeftSize.TextChanged += new System.EventHandler(this.txt_LeftSize_TextChanged);
  1988. this.txt_LeftSize.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.textBoxLeftSize_KeyPress);
  1989. //
  1990. // label21
  1991. //
  1992. this.label21.AutoSize = true;
  1993. this.label21.Location = new System.Drawing.Point(27, 57);
  1994. this.label21.Name = "label21";
  1995. this.label21.Size = new System.Drawing.Size(0, 12);
  1996. this.label21.TabIndex = 6;
  1997. //
  1998. // rb_LeftSquare
  1999. //
  2000. this.rb_LeftSquare.AutoSize = true;
  2001. this.rb_LeftSquare.Location = new System.Drawing.Point(115, 22);
  2002. this.rb_LeftSquare.Name = "rb_LeftSquare";
  2003. this.rb_LeftSquare.Size = new System.Drawing.Size(14, 13);
  2004. this.rb_LeftSquare.TabIndex = 2;
  2005. this.rb_LeftSquare.UseVisualStyleBackColor = true;
  2006. //
  2007. // rb_LeftCircle
  2008. //
  2009. this.rb_LeftCircle.AutoSize = true;
  2010. this.rb_LeftCircle.Checked = true;
  2011. this.rb_LeftCircle.Location = new System.Drawing.Point(62, 22);
  2012. this.rb_LeftCircle.Name = "rb_LeftCircle";
  2013. this.rb_LeftCircle.Size = new System.Drawing.Size(14, 13);
  2014. this.rb_LeftCircle.TabIndex = 1;
  2015. this.rb_LeftCircle.TabStop = true;
  2016. this.rb_LeftCircle.UseVisualStyleBackColor = true;
  2017. this.rb_LeftCircle.CheckedChanged += new System.EventHandler(this.rb_LeftCircle_CheckedChanged);
  2018. //
  2019. // label22
  2020. //
  2021. this.label22.AutoSize = true;
  2022. this.label22.Location = new System.Drawing.Point(25, 24);
  2023. this.label22.Name = "label22";
  2024. this.label22.Size = new System.Drawing.Size(0, 12);
  2025. this.label22.TabIndex = 0;
  2026. //
  2027. // groupBox9
  2028. //
  2029. this.groupBox9.Controls.Add(this.dataGridView3);
  2030. this.groupBox9.Controls.Add(this.dataGridView1);
  2031. this.groupBox9.Location = new System.Drawing.Point(156, 570);
  2032. this.groupBox9.Name = "groupBox9";
  2033. this.groupBox9.Size = new System.Drawing.Size(351, 123);
  2034. this.groupBox9.TabIndex = 20;
  2035. this.groupBox9.TabStop = false;
  2036. //
  2037. // dataGridView3
  2038. //
  2039. this.dataGridView3.AllowUserToAddRows = false;
  2040. this.dataGridView3.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill;
  2041. this.dataGridView3.BackgroundColor = System.Drawing.SystemColors.ControlLightLight;
  2042. dataGridViewCellStyle20.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
  2043. dataGridViewCellStyle20.BackColor = System.Drawing.SystemColors.Control;
  2044. dataGridViewCellStyle20.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
  2045. dataGridViewCellStyle20.ForeColor = System.Drawing.SystemColors.WindowText;
  2046. dataGridViewCellStyle20.SelectionBackColor = System.Drawing.SystemColors.Highlight;
  2047. dataGridViewCellStyle20.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
  2048. dataGridViewCellStyle20.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
  2049. this.dataGridView3.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle20;
  2050. this.dataGridView3.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
  2051. this.dataGridView3.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
  2052. this.dataGridViewTextBoxColumn5,
  2053. this.dataGridViewTextBoxColumn6,
  2054. this.dataGridViewTextBoxColumn7,
  2055. this.dataGridViewTextBoxColumn8,
  2056. this.dataGridViewTextBoxColumn9});
  2057. this.dataGridView3.Location = new System.Drawing.Point(8, 20);
  2058. this.dataGridView3.MultiSelect = false;
  2059. this.dataGridView3.Name = "dataGridView3";
  2060. this.dataGridView3.ReadOnly = true;
  2061. this.dataGridView3.RowHeadersVisible = false;
  2062. this.dataGridView3.RowTemplate.Height = 23;
  2063. this.dataGridView3.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
  2064. this.dataGridView3.Size = new System.Drawing.Size(337, 94);
  2065. this.dataGridView3.TabIndex = 1;
  2066. this.dataGridView3.Visible = false;
  2067. //
  2068. // dataGridViewTextBoxColumn5
  2069. //
  2070. dataGridViewCellStyle21.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
  2071. this.dataGridViewTextBoxColumn5.DefaultCellStyle = dataGridViewCellStyle21;
  2072. this.dataGridViewTextBoxColumn5.Name = "dataGridViewTextBoxColumn5";
  2073. this.dataGridViewTextBoxColumn5.ReadOnly = true;
  2074. //
  2075. // dataGridViewTextBoxColumn6
  2076. //
  2077. dataGridViewCellStyle22.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleRight;
  2078. this.dataGridViewTextBoxColumn6.DefaultCellStyle = dataGridViewCellStyle22;
  2079. this.dataGridViewTextBoxColumn6.HeaderText = "NL⊥";
  2080. this.dataGridViewTextBoxColumn6.Name = "dataGridViewTextBoxColumn6";
  2081. this.dataGridViewTextBoxColumn6.ReadOnly = true;
  2082. //
  2083. // dataGridViewTextBoxColumn7
  2084. //
  2085. dataGridViewCellStyle23.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleRight;
  2086. this.dataGridViewTextBoxColumn7.DefaultCellStyle = dataGridViewCellStyle23;
  2087. this.dataGridViewTextBoxColumn7.HeaderText = "NL//";
  2088. this.dataGridViewTextBoxColumn7.Name = "dataGridViewTextBoxColumn7";
  2089. this.dataGridViewTextBoxColumn7.ReadOnly = true;
  2090. //
  2091. // dataGridViewTextBoxColumn8
  2092. //
  2093. dataGridViewCellStyle24.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleRight;
  2094. this.dataGridViewTextBoxColumn8.DefaultCellStyle = dataGridViewCellStyle24;
  2095. this.dataGridViewTextBoxColumn8.HeaderText = "PL⊥";
  2096. this.dataGridViewTextBoxColumn8.Name = "dataGridViewTextBoxColumn8";
  2097. this.dataGridViewTextBoxColumn8.ReadOnly = true;
  2098. //
  2099. // dataGridViewTextBoxColumn9
  2100. //
  2101. dataGridViewCellStyle25.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleRight;
  2102. this.dataGridViewTextBoxColumn9.DefaultCellStyle = dataGridViewCellStyle25;
  2103. this.dataGridViewTextBoxColumn9.HeaderText = "PL//";
  2104. this.dataGridViewTextBoxColumn9.Name = "dataGridViewTextBoxColumn9";
  2105. this.dataGridViewTextBoxColumn9.ReadOnly = true;
  2106. //
  2107. // dataGridView1
  2108. //
  2109. this.dataGridView1.AllowUserToAddRows = false;
  2110. this.dataGridView1.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill;
  2111. this.dataGridView1.BackgroundColor = System.Drawing.SystemColors.ControlLightLight;
  2112. dataGridViewCellStyle26.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
  2113. dataGridViewCellStyle26.BackColor = System.Drawing.SystemColors.Control;
  2114. dataGridViewCellStyle26.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
  2115. dataGridViewCellStyle26.ForeColor = System.Drawing.SystemColors.WindowText;
  2116. dataGridViewCellStyle26.SelectionBackColor = System.Drawing.SystemColors.Highlight;
  2117. dataGridViewCellStyle26.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
  2118. dataGridViewCellStyle26.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
  2119. this.dataGridView1.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle26;
  2120. this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
  2121. this.dataGridView1.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
  2122. this.Column11,
  2123. this.dataGridViewTextBoxColumn1,
  2124. this.dataGridViewTextBoxColumn2,
  2125. this.dataGridViewTextBoxColumn3,
  2126. this.dataGridViewTextBoxColumn4});
  2127. this.dataGridView1.Location = new System.Drawing.Point(8, 20);
  2128. this.dataGridView1.MultiSelect = false;
  2129. this.dataGridView1.Name = "dataGridView1";
  2130. this.dataGridView1.ReadOnly = true;
  2131. this.dataGridView1.RowHeadersVisible = false;
  2132. this.dataGridView1.RowTemplate.Height = 23;
  2133. this.dataGridView1.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
  2134. this.dataGridView1.Size = new System.Drawing.Size(337, 94);
  2135. this.dataGridView1.TabIndex = 0;
  2136. this.dataGridView1.SelectionChanged += new System.EventHandler(this.dataGridView1_SelectionChanged);
  2137. //
  2138. // Column11
  2139. //
  2140. dataGridViewCellStyle27.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
  2141. this.Column11.DefaultCellStyle = dataGridViewCellStyle27;
  2142. this.Column11.Name = "Column11";
  2143. this.Column11.ReadOnly = true;
  2144. //
  2145. // dataGridViewTextBoxColumn1
  2146. //
  2147. dataGridViewCellStyle28.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleRight;
  2148. this.dataGridViewTextBoxColumn1.DefaultCellStyle = dataGridViewCellStyle28;
  2149. this.dataGridViewTextBoxColumn1.HeaderText = "NL⊥";
  2150. this.dataGridViewTextBoxColumn1.Name = "dataGridViewTextBoxColumn1";
  2151. this.dataGridViewTextBoxColumn1.ReadOnly = true;
  2152. //
  2153. // dataGridViewTextBoxColumn2
  2154. //
  2155. dataGridViewCellStyle29.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleRight;
  2156. this.dataGridViewTextBoxColumn2.DefaultCellStyle = dataGridViewCellStyle29;
  2157. this.dataGridViewTextBoxColumn2.HeaderText = "NL//";
  2158. this.dataGridViewTextBoxColumn2.Name = "dataGridViewTextBoxColumn2";
  2159. this.dataGridViewTextBoxColumn2.ReadOnly = true;
  2160. //
  2161. // dataGridViewTextBoxColumn3
  2162. //
  2163. dataGridViewCellStyle30.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleRight;
  2164. this.dataGridViewTextBoxColumn3.DefaultCellStyle = dataGridViewCellStyle30;
  2165. this.dataGridViewTextBoxColumn3.HeaderText = "PL⊥";
  2166. this.dataGridViewTextBoxColumn3.Name = "dataGridViewTextBoxColumn3";
  2167. this.dataGridViewTextBoxColumn3.ReadOnly = true;
  2168. //
  2169. // dataGridViewTextBoxColumn4
  2170. //
  2171. dataGridViewCellStyle31.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleRight;
  2172. this.dataGridViewTextBoxColumn4.DefaultCellStyle = dataGridViewCellStyle31;
  2173. this.dataGridViewTextBoxColumn4.HeaderText = "PL//";
  2174. this.dataGridViewTextBoxColumn4.Name = "dataGridViewTextBoxColumn4";
  2175. this.dataGridViewTextBoxColumn4.ReadOnly = true;
  2176. //
  2177. // groupBox12
  2178. //
  2179. this.groupBox12.Controls.Add(this.checkBox5);
  2180. this.groupBox12.Controls.Add(this.checkBox4);
  2181. this.groupBox12.Location = new System.Drawing.Point(157, 521);
  2182. this.groupBox12.Name = "groupBox12";
  2183. this.groupBox12.Size = new System.Drawing.Size(351, 43);
  2184. this.groupBox12.TabIndex = 21;
  2185. this.groupBox12.TabStop = false;
  2186. //
  2187. // checkBox5
  2188. //
  2189. this.checkBox5.AutoSize = true;
  2190. this.checkBox5.Location = new System.Drawing.Point(125, 18);
  2191. this.checkBox5.Name = "checkBox5";
  2192. this.checkBox5.Size = new System.Drawing.Size(15, 14);
  2193. this.checkBox5.TabIndex = 1;
  2194. this.checkBox5.UseVisualStyleBackColor = true;
  2195. this.checkBox5.CheckedChanged += new System.EventHandler(this.checkBox5_CheckedChanged);
  2196. //
  2197. // checkBox4
  2198. //
  2199. this.checkBox4.AutoSize = true;
  2200. this.checkBox4.Location = new System.Drawing.Point(15, 18);
  2201. this.checkBox4.Name = "checkBox4";
  2202. this.checkBox4.Size = new System.Drawing.Size(15, 14);
  2203. this.checkBox4.TabIndex = 0;
  2204. this.checkBox4.UseVisualStyleBackColor = true;
  2205. this.checkBox4.CheckedChanged += new System.EventHandler(this.checkBox4_CheckedChanged);
  2206. //
  2207. // MicrostructureBandDialog
  2208. //
  2209. this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
  2210. this.ClientSize = new System.Drawing.Size(1107, 942);
  2211. this.Controls.Add(this.groupBox12);
  2212. this.Controls.Add(this.groupBox9);
  2213. this.Controls.Add(this.groupBox10);
  2214. this.Controls.Add(this.groupBox4);
  2215. this.Controls.Add(this.groupBox7);
  2216. this.Controls.Add(this.groupBox8);
  2217. this.Controls.Add(this.groupBox2);
  2218. this.Controls.Add(this.groupBox1);
  2219. this.Name = "MicrostructureBandDialog";
  2220. this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.InclusionsStandardDialog_FormClosing);
  2221. this.Shown += new System.EventHandler(this.ShownChoiseItemAndInitData);
  2222. this.Load += new System.EventHandler(this.MicrostructureBandDialog_Load);
  2223. this.Controls.SetChildIndex(this.groupBox1, 0);
  2224. this.Controls.SetChildIndex(this.groupBox2, 0);
  2225. this.Controls.SetChildIndex(this.groupBox8, 0);
  2226. this.Controls.SetChildIndex(this.groupBox7, 0);
  2227. this.Controls.SetChildIndex(this.groupBox4, 0);
  2228. this.Controls.SetChildIndex(this.groupBox10, 0);
  2229. this.Controls.SetChildIndex(this.groupBox9, 0);
  2230. this.Controls.SetChildIndex(this.groupBox12, 0);
  2231. this.groupBox1.ResumeLayout(false);
  2232. this.groupBox2.ResumeLayout(false);
  2233. this.groupBox8.ResumeLayout(false);
  2234. this.groupBox8.PerformLayout();
  2235. ((System.ComponentModel.ISupportInitialize)(this.dataGridView2)).EndInit();
  2236. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).EndInit();
  2237. ((System.ComponentModel.ISupportInitialize)(this.dataGridView4)).EndInit();
  2238. this.groupBox4.ResumeLayout(false);
  2239. this.groupBox4.PerformLayout();
  2240. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown4)).EndInit();
  2241. this.groupBox10.ResumeLayout(false);
  2242. this.groupBox10.PerformLayout();
  2243. this.groupBox11.ResumeLayout(false);
  2244. this.groupBox11.PerformLayout();
  2245. this.groupBox9.ResumeLayout(false);
  2246. ((System.ComponentModel.ISupportInitialize)(this.dataGridView3)).EndInit();
  2247. ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit();
  2248. this.groupBox12.ResumeLayout(false);
  2249. this.groupBox12.PerformLayout();
  2250. this.ResumeLayout(false);
  2251. }
  2252. #endregion
  2253. #region 公共按钮
  2254. private void InitCommonButtonEvent()
  2255. {
  2256. this.commonControlButtons.zoomInButton.Click += new EventHandler(zoomInButton_Click);
  2257. this.commonControlButtons.zoomOutButton.Click += new EventHandler(zoomOutButton_Click);
  2258. this.commonControlButtons.zoomToWindowButton.Click += new EventHandler(zoomToWindowButton_Click);
  2259. this.commonControlButtons.actualSizeButton.Click += new EventHandler(actualSizeButton_Click);
  2260. this.commonControlButtons.pointerButton.Click += new EventHandler(pointerButton_Click);
  2261. this.commonControlButtons.mobileModeButton.Click += new EventHandler(mobileModeButton_Click);
  2262. }
  2263. private void zoomInButton_Click(object sender, EventArgs e)
  2264. {
  2265. this.documentWorkspace.ZoomIn();
  2266. }
  2267. private void zoomOutButton_Click(object sender, EventArgs e)
  2268. {
  2269. this.documentWorkspace.ZoomOut();
  2270. }
  2271. private void zoomToWindowButton_Click(object sender, EventArgs e)
  2272. {
  2273. this.documentWorkspace.ZoomBasis = ZoomBasis.FitToWindow;
  2274. }
  2275. private void actualSizeButton_Click(object sender, EventArgs e)
  2276. {
  2277. this.documentWorkspace.ZoomBasis = ZoomBasis.ScaleFactor;
  2278. this.documentWorkspace.ScaleFactor = ScaleFactor.OneToOne;
  2279. }
  2280. private void pointerButton_Click(object sender, EventArgs e)
  2281. {
  2282. this.documentWorkspace.ActiveTool = Annotation.Enum.DrawToolType.Pointer;
  2283. }
  2284. private void mobileModeButton_Click(object sender, EventArgs e)
  2285. {
  2286. this.documentWorkspace.ActiveTool = Annotation.Enum.DrawToolType.MoveMode;
  2287. }
  2288. #endregion
  2289. private void colorsFormUserPrimaryColorChanged(object sender, ColorEventArgs ce)
  2290. {
  2291. }
  2292. private void panel1_Click(object sender, EventArgs e)
  2293. {
  2294. this.colorsForm1.UserPrimaryColor = ColorBgra.FromColor(this.panel1.BackColor);
  2295. this.colorsForm1.setSaveBtn_Click(new System.EventHandler(this.panel1Changed));
  2296. this.colorsForm1.ShowDialog();
  2297. }
  2298. private void panel1Changed(object sender, EventArgs e)
  2299. {
  2300. this.panel1.BackColor = this.colorsForm1.UserPrimaryColor.ToColor();
  2301. this.colorsForm1.Close();
  2302. }
  2303. private void panel4_Click(object sender, EventArgs e)
  2304. {
  2305. this.colorsForm4.UserPrimaryColor = ColorBgra.FromColor(this.panel4.BackColor);
  2306. this.colorsForm4.setSaveBtn_Click(new System.EventHandler(this.panel4Changed));
  2307. this.colorsForm4.ShowDialog();
  2308. }
  2309. private void panel4Changed(object sender, EventArgs e)
  2310. {
  2311. this.panel4.BackColor = this.colorsForm4.UserPrimaryColor.ToColor();
  2312. this.colorsForm4.Close();
  2313. }
  2314. private void listView1_MouseDown(object sender, MouseEventArgs e)
  2315. {
  2316. this.changeCount = 0;
  2317. }
  2318. /// <summary>
  2319. /// 切换图片
  2320. /// </summary>
  2321. /// <param name="sender"></param>
  2322. /// <param name="e"></param>
  2323. private void listView1_SelectedIndexChanged(object sender, EventArgs e)
  2324. {
  2325. SelectedIndexChanged(sender, e);
  2326. }
  2327. /// <summary>
  2328. /// 切换图片
  2329. /// </summary>
  2330. private void SelectedIndexChanged(object sender, EventArgs e)
  2331. {
  2332. if (this.listView1.FocusedItem != null && this.listView1.FocusedItem.Selected)
  2333. {
  2334. this.unitLength = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].GetRuler(MeasurementUnit.Micron);
  2335. existViewFlag = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].GraphicsList.IsExsitView();
  2336. this.imageMat = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].CompositionSurface.CreatedAliasedMat();
  2337. if (!existViewFlag)
  2338. mat = this.imageMat.Clone();
  2339. else
  2340. mat = PaintDotNet.Camera.Tools.ToMat(this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].GetFullSizeWithRegion());
  2341. //二值化集成4
  2342. binaryClass.listView1_SelectedIndexChanged(this.imageMat.Clone());
  2343. if (bcOriginChecked())
  2344. {
  2345. this.documentWorkspace.PhaseModels[0].choise = false;
  2346. this.documentWorkspace.PhaseModels[1].choise = false;
  2347. this.documentWorkspace.Refresh();
  2348. }
  2349. this.dataGridView1.Rows.Clear();
  2350. this.dataGridView3.Rows.Clear();
  2351. this.p1RectangleFs.Clear();
  2352. this.vPointCount = 0;
  2353. this.hPointCount = 0;
  2354. if (this.wholePicture)
  2355. RefreshGridIntersections(false);
  2356. else
  2357. RefreshDrawRegion(PointF.Empty, false);
  2358. if (this.button6.Visible)
  2359. Init();
  2360. if (!this.button6.Visible && this.documentWorkspace.phaseModels.Count != 0 && this.checkBox4.Checked)
  2361. {
  2362. GetNumberOfGrains();
  2363. RefreshResultsData();
  2364. }
  2365. this.documentWorkspace.Refresh();
  2366. }
  2367. }
  2368. private void Init()
  2369. {
  2370. this.init = false;
  2371. this.checkBox4.Checked = false;
  2372. this.commonControlButtons.Visible = true;
  2373. this.switchImg = false;
  2374. this.selectPicture = true;
  2375. this.dataGridView1.Rows.Clear();
  2376. this.dataGridView3.Rows.Clear();
  2377. this.init = true;
  2378. }
  2379. /// <summary>
  2380. /// 画布绘制
  2381. /// </summary>
  2382. /// <param name="sender"></param>
  2383. /// <param name="e"></param>
  2384. private void Panel_Paint(object sender, PaintEventArgs e)
  2385. {
  2386. if (this.documentWorkspace.CompositionSurface != null)
  2387. {
  2388. //
  2389. // 以下是计算绘制图片的位置和大小并绘制图片
  2390. //
  2391. Rectangle rc = this.documentWorkspace.panel.ClientRectangle;
  2392. int width = (int)(this.documentWorkspace.CompositionSurface.Width * this.documentWorkspace.ScaleFactor.Ratio);
  2393. int height = (int)(this.documentWorkspace.CompositionSurface.Height * this.documentWorkspace.ScaleFactor.Ratio);
  2394. int x = (rc.Width < width) ? this.documentWorkspace.panel.AutoScrollPosition.X : (rc.Width - width) / 2;
  2395. int y = (rc.Height < height) ? this.documentWorkspace.panel.AutoScrollPosition.Y : (rc.Height - height) / 2;
  2396. //
  2397. // 以下是绘制网格、标注、测量、视场等开始
  2398. //
  2399. e.Graphics.TranslateTransform(x, y);
  2400. e.Graphics.ScaleTransform((float)this.documentWorkspace.ScaleFactor.Ratio, (float)this.documentWorkspace.ScaleFactor.Ratio);
  2401. Draw(e.Graphics);
  2402. e.Graphics.ScaleTransform(1 / (float)this.documentWorkspace.ScaleFactor.Ratio, 1 / (float)this.documentWorkspace.ScaleFactor.Ratio);
  2403. e.Graphics.TranslateTransform(-x, -y);
  2404. }
  2405. }
  2406. /// <summary>
  2407. /// 绘制
  2408. /// </summary>
  2409. /// <param name="graphics"></param>
  2410. private void Draw(Graphics graphics)
  2411. {
  2412. Pen linePen = new Pen(Color.FromArgb(this.gridColor), this.gridWidth);
  2413. if (this.selected && !this.wholePicture)
  2414. linePen.DashStyle = System.Drawing.Drawing2D.DashStyle.DashDotDot;
  2415. if (!this.checkBox5.Checked)
  2416. linePen.DashStyle = System.Drawing.Drawing2D.DashStyle.Solid;
  2417. float hGridSpacingDraw;
  2418. float vGridSpacingDraw;
  2419. float blankDraw;
  2420. if (this.wholePicture)
  2421. {
  2422. hGridSpacingDraw = (float)(this.documentWorkspace.CompositionSurface.Height - 2 * this.blank) / (this.hNumber - 1);
  2423. vGridSpacingDraw = (float)(this.documentWorkspace.CompositionSurface.Width - 2 * this.blank) / (this.vNumber - 1);
  2424. blankDraw = this.blank;
  2425. if (this.hNumber > 0)
  2426. {
  2427. if (this.hNumber % 2 == 0)
  2428. {
  2429. float Spacing = hGridSpacingDraw / 2;
  2430. for (int i = 0; i < (float)this.hNumber / 2; i++)
  2431. {
  2432. if (this.documentWorkspace.CompositionSurface.Height > 2 * this.blank && this.documentWorkspace.CompositionSurface.Width > 2 * this.blank)
  2433. {
  2434. if ((float)this.documentWorkspace.CompositionSurface.Height / 2 - Math.Round(Spacing, 2) >= blankDraw)
  2435. {
  2436. graphics.DrawLine(linePen, new PointF(blankDraw, (float)this.documentWorkspace.CompositionSurface.Height / 2 - (float)Math.Round(Spacing, 2))
  2437. , new PointF((float)(this.documentWorkspace.CompositionSurface.Width - blankDraw), (float)this.documentWorkspace.CompositionSurface.Height / 2 - Spacing));
  2438. }
  2439. if ((float)this.documentWorkspace.CompositionSurface.Height / 2 + Math.Round(Spacing, 2) <= this.documentWorkspace.CompositionSurface.Height - blankDraw)
  2440. {
  2441. graphics.DrawLine(linePen, new PointF(blankDraw, (float)this.documentWorkspace.CompositionSurface.Height / 2 + (float)Math.Round(Spacing, 2))
  2442. , new PointF((float)(this.documentWorkspace.CompositionSurface.Width - blankDraw), (float)this.documentWorkspace.CompositionSurface.Height / 2 + Spacing));
  2443. }
  2444. }
  2445. Spacing += hGridSpacingDraw;
  2446. }
  2447. }
  2448. else
  2449. {
  2450. if ((float)this.documentWorkspace.CompositionSurface.Width > 2 * blankDraw)
  2451. {
  2452. if (this.hNumber == 1)
  2453. graphics.DrawLine(linePen, new PointF(blankDraw, (float)this.documentWorkspace.CompositionSurface.Height / 2)
  2454. , new PointF((float)(this.documentWorkspace.CompositionSurface.Width - blankDraw), (float)this.documentWorkspace.CompositionSurface.Height / 2));
  2455. else
  2456. {
  2457. float Spacing = hGridSpacingDraw;
  2458. for (int i = 0; i < (this.hNumber - 1) / 2; i++)
  2459. {
  2460. if (this.documentWorkspace.CompositionSurface.Height > 2 * this.blank && this.documentWorkspace.CompositionSurface.Width > 2 * this.blank)
  2461. {
  2462. if (i == 0)
  2463. graphics.DrawLine(linePen, new PointF(blankDraw, (float)this.documentWorkspace.CompositionSurface.Height / 2)
  2464. , new PointF((float)(this.documentWorkspace.CompositionSurface.Width - blankDraw), (float)this.documentWorkspace.CompositionSurface.Height / 2));
  2465. if ((float)this.documentWorkspace.CompositionSurface.Height / 2 - Math.Round(Spacing, 2) >= blankDraw)
  2466. {
  2467. graphics.DrawLine(linePen, new PointF(blankDraw, (float)this.documentWorkspace.CompositionSurface.Height / 2 - (float)Math.Round(Spacing, 2))
  2468. , new PointF((float)(this.documentWorkspace.CompositionSurface.Width - blankDraw), (float)this.documentWorkspace.CompositionSurface.Height / 2 - Spacing));
  2469. }
  2470. if ((float)this.documentWorkspace.CompositionSurface.Height / 2 + Math.Round(Spacing, 2) <= this.documentWorkspace.CompositionSurface.Height - blankDraw)
  2471. {
  2472. graphics.DrawLine(linePen, new PointF(blankDraw, (float)this.documentWorkspace.CompositionSurface.Height / 2 + (float)Math.Round(Spacing, 2))
  2473. , new PointF((float)(this.documentWorkspace.CompositionSurface.Width - blankDraw), (float)this.documentWorkspace.CompositionSurface.Height / 2 + Spacing));
  2474. }
  2475. }
  2476. Spacing += hGridSpacingDraw;
  2477. }
  2478. }
  2479. }
  2480. }
  2481. }
  2482. if (this.vNumber > 0)
  2483. {
  2484. if (this.vNumber % 2 == 0)
  2485. {
  2486. float Spacing = vGridSpacingDraw / 2;
  2487. for (int i = 0; i < (float)this.vNumber / 2; i++)
  2488. {
  2489. if (this.documentWorkspace.CompositionSurface.Height > 2 * this.blank && this.documentWorkspace.CompositionSurface.Width > 2 * this.blank)
  2490. {
  2491. if ((float)this.documentWorkspace.CompositionSurface.Width / 2 - Math.Round(Spacing, 2) >= 0
  2492. && (float)this.documentWorkspace.CompositionSurface.Width / 2 - Math.Round(Spacing, 2) >= blankDraw)
  2493. {
  2494. graphics.DrawLine(linePen, new PointF((float)this.documentWorkspace.CompositionSurface.Width / 2 - (float)Math.Round(Spacing, 2), blankDraw)
  2495. , new PointF((float)this.documentWorkspace.CompositionSurface.Width / 2 - (float)Math.Round(Spacing, 2), (float)(this.documentWorkspace.CompositionSurface.Height - blankDraw)));
  2496. }
  2497. if ((float)this.documentWorkspace.CompositionSurface.Width / 2 + Math.Round(Spacing, 2) <= this.documentWorkspace.CompositionSurface.Width
  2498. && (float)this.documentWorkspace.CompositionSurface.Width / 2 + Math.Round(Spacing, 2) <= this.documentWorkspace.CompositionSurface.Width - blankDraw)
  2499. {
  2500. graphics.DrawLine(linePen, new PointF((float)this.documentWorkspace.CompositionSurface.Width / 2 + (float)Math.Round(Spacing, 2), blankDraw)
  2501. , new PointF((float)this.documentWorkspace.CompositionSurface.Width / 2 + (float)Math.Round(Spacing, 2), (float)(this.documentWorkspace.CompositionSurface.Height - blankDraw)));
  2502. }
  2503. }
  2504. Spacing += vGridSpacingDraw;
  2505. }
  2506. }
  2507. else
  2508. {
  2509. if (this.documentWorkspace.CompositionSurface.Height > 2 * blankDraw)
  2510. {
  2511. if (this.vNumber == 1)
  2512. graphics.DrawLine(linePen, new PointF((float)this.documentWorkspace.CompositionSurface.Width / 2, blankDraw)
  2513. , new PointF((float)this.documentWorkspace.CompositionSurface.Width / 2, (float)(this.documentWorkspace.CompositionSurface.Height - blankDraw)));
  2514. else
  2515. {
  2516. float Spacing = vGridSpacingDraw;
  2517. for (int i = 0; i < (this.vNumber - 1) / 2; i++)
  2518. {
  2519. if (this.documentWorkspace.CompositionSurface.Height > 2 * this.blank && this.documentWorkspace.CompositionSurface.Width > 2 * this.blank)
  2520. {
  2521. if (i == 0)
  2522. graphics.DrawLine(linePen, new PointF((float)this.documentWorkspace.CompositionSurface.Width / 2, blankDraw)
  2523. , new PointF((float)this.documentWorkspace.CompositionSurface.Width / 2, (float)(this.documentWorkspace.CompositionSurface.Height - blankDraw)));
  2524. if ((float)this.documentWorkspace.CompositionSurface.Width / 2 + Math.Round(Spacing, 2) <= this.documentWorkspace.CompositionSurface.Width
  2525. && this.documentWorkspace.CompositionSurface.Width / 2 + Math.Round(Spacing, 2) <= this.documentWorkspace.CompositionSurface.Width - blankDraw)
  2526. {
  2527. graphics.DrawLine(linePen, new PointF((float)this.documentWorkspace.CompositionSurface.Width / 2 + (float)Math.Round(Spacing, 2), blankDraw)
  2528. , new PointF((float)this.documentWorkspace.CompositionSurface.Width / 2 + (float)Math.Round(Spacing, 2), (float)(this.documentWorkspace.CompositionSurface.Height - blankDraw)));
  2529. }
  2530. if ((float)this.documentWorkspace.CompositionSurface.Width / 2 - Math.Round(Spacing, 2) >= 0 && (float)this.documentWorkspace.CompositionSurface.Width / 2 - Spacing >= blankDraw)
  2531. {
  2532. graphics.DrawLine(linePen, new PointF((float)this.documentWorkspace.CompositionSurface.Width / 2 - (float)Math.Round(Spacing, 2), blankDraw)
  2533. , new PointF((float)this.documentWorkspace.CompositionSurface.Width / 2 - (float)Math.Round(Spacing, 2), (float)(this.documentWorkspace.CompositionSurface.Height - blankDraw)));
  2534. }
  2535. }
  2536. Spacing += vGridSpacingDraw;
  2537. }
  2538. }
  2539. }
  2540. }
  2541. }
  2542. }
  2543. else
  2544. {
  2545. hGridSpacingDraw = (float)(this.gridSpacing / unitLength);
  2546. vGridSpacingDraw = (float)(this.gridSpacing / unitLength);
  2547. if (this.hNumber > 0)
  2548. {
  2549. if (this.hNumber % 2 == 0)
  2550. {
  2551. float Spacing = hGridSpacingDraw / 2;
  2552. for (int i = 0; i < (float)this.hNumber / 2; i++)
  2553. {
  2554. if ((float)this.drawRectangleF.Top + (float)this.drawRectangleF.Height / 2 - Spacing >= (float)this.drawRectangleF.Top)
  2555. {
  2556. graphics.DrawLine(linePen, new PointF((float)this.drawRectangleF.Left, (float)this.drawRectangleF.Top + (float)this.drawRectangleF.Height / 2 - Spacing)
  2557. , new PointF((float)(this.drawRectangleF.Right), (float)this.drawRectangleF.Top + (float)this.drawRectangleF.Height / 2 - Spacing));
  2558. }
  2559. if ((float)this.drawRectangleF.Top + (float)this.drawRectangleF.Height / 2 + Spacing <= this.drawRectangleF.Bottom)
  2560. {
  2561. graphics.DrawLine(linePen, new PointF((float)this.drawRectangleF.Left, (float)this.drawRectangleF.Top + (float)this.drawRectangleF.Height / 2 + Spacing)
  2562. , new PointF((float)this.drawRectangleF.Right, (float)this.drawRectangleF.Top + (float)this.drawRectangleF.Height / 2 + Spacing));
  2563. }
  2564. Spacing += hGridSpacingDraw;
  2565. }
  2566. }
  2567. else
  2568. {
  2569. if (this.hNumber == 1)
  2570. graphics.DrawLine(linePen, new PointF((float)this.drawRectangleF.Left, (float)this.drawRectangleF.Top + (float)this.drawRectangleF.Height / 2)
  2571. , new PointF((float)this.drawRectangleF.Right, (float)this.drawRectangleF.Top + (float)this.drawRectangleF.Height / 2));
  2572. else
  2573. {
  2574. float Spacing = hGridSpacingDraw;
  2575. for (int i = 0; i < (this.hNumber - 1) / 2; i++)
  2576. {
  2577. if (i == 0)
  2578. graphics.DrawLine(linePen, new PointF((float)this.drawRectangleF.Left, (float)this.drawRectangleF.Top + (float)this.drawRectangleF.Height / 2)
  2579. , new PointF((float)this.drawRectangleF.Right, (float)this.drawRectangleF.Top + (float)this.drawRectangleF.Height / 2));
  2580. if ((float)this.drawRectangleF.Top + (float)this.drawRectangleF.Height / 2 - Spacing >= this.drawRectangleF.Top)
  2581. {
  2582. graphics.DrawLine(linePen, new PointF((float)this.drawRectangleF.Left, (float)this.drawRectangleF.Top + (float)this.drawRectangleF.Height / 2 - Spacing)
  2583. , new PointF((float)this.drawRectangleF.Right, (float)this.drawRectangleF.Top + (float)this.drawRectangleF.Height / 2 - Spacing));
  2584. }
  2585. if ((float)this.drawRectangleF.Top + (float)this.drawRectangleF.Height / 2 + Spacing <= this.drawRectangleF.Bottom)
  2586. {
  2587. graphics.DrawLine(linePen, new PointF((float)this.drawRectangleF.Left, (float)this.drawRectangleF.Top + (float)this.drawRectangleF.Height / 2 + Spacing)
  2588. , new PointF((float)this.drawRectangleF.Right, (float)this.drawRectangleF.Top + (float)this.drawRectangleF.Height / 2 + Spacing));
  2589. }
  2590. Spacing += hGridSpacingDraw;
  2591. }
  2592. }
  2593. }
  2594. }
  2595. if (this.vNumber > 0)
  2596. {
  2597. if (this.vNumber % 2 == 0)
  2598. {
  2599. float Spacing = vGridSpacingDraw / 2;
  2600. for (int i = 0; i < (float)this.vNumber / 2; i++)
  2601. {
  2602. //if ((float)this.drawRectangleF.Left + (float)this.drawRectangleF.Width / 2 - Spacing >= 0)
  2603. {
  2604. graphics.DrawLine(linePen, new PointF((float)this.drawRectangleF.Left + (float)this.drawRectangleF.Width / 2 - Spacing, (float)this.drawRectangleF.Top)
  2605. , new PointF((float)this.drawRectangleF.Left + (float)this.drawRectangleF.Width / 2 - Spacing, (float)this.drawRectangleF.Bottom));
  2606. }
  2607. if ((float)this.drawRectangleF.Left + (float)this.drawRectangleF.Width / 2 + Spacing <= this.drawRectangleF.Right)
  2608. {
  2609. graphics.DrawLine(linePen, new PointF((float)this.drawRectangleF.Left + (float)this.drawRectangleF.Width / 2 + Spacing, (float)this.drawRectangleF.Top)
  2610. , new PointF((float)this.drawRectangleF.Left + (float)this.drawRectangleF.Width / 2 + Spacing, (float)this.drawRectangleF.Bottom));
  2611. }
  2612. Spacing += vGridSpacingDraw;
  2613. }
  2614. }
  2615. else
  2616. {
  2617. if (this.vNumber == 1)
  2618. graphics.DrawLine(linePen, new PointF((float)this.drawRectangleF.Left + (float)this.drawRectangleF.Width / 2, (float)this.drawRectangleF.Top)
  2619. , new PointF((float)this.drawRectangleF.Left + (float)this.drawRectangleF.Width / 2, (float)this.drawRectangleF.Bottom));
  2620. else
  2621. {
  2622. float Spacing = vGridSpacingDraw;
  2623. for (int i = 0; i < (this.vNumber - 1) / 2; i++)
  2624. {
  2625. if (i == 0)
  2626. graphics.DrawLine(linePen, new PointF((float)this.drawRectangleF.Left + (float)this.drawRectangleF.Width / 2, (float)this.drawRectangleF.Top)
  2627. , new PointF((float)this.drawRectangleF.Left + (float)this.drawRectangleF.Width / 2, (float)this.drawRectangleF.Bottom));
  2628. if ((float)this.drawRectangleF.Left + (float)this.drawRectangleF.Width / 2 + Spacing <= this.drawRectangleF.Right)
  2629. {
  2630. graphics.DrawLine(linePen, new PointF((float)this.drawRectangleF.Left + (float)this.drawRectangleF.Width / 2 + Spacing, (float)this.drawRectangleF.Top)
  2631. , new PointF((float)this.drawRectangleF.Left + (float)this.drawRectangleF.Width / 2 + Spacing, (float)this.drawRectangleF.Bottom));
  2632. }
  2633. if ((float)this.drawRectangleF.Left + (float)this.drawRectangleF.Width / 2 - Spacing >= this.drawRectangleF.Left)
  2634. {
  2635. graphics.DrawLine(linePen, new PointF((float)this.drawRectangleF.Left + (float)this.drawRectangleF.Width / 2 - Spacing, (float)this.drawRectangleF.Top)
  2636. , new PointF((float)this.drawRectangleF.Left + (float)this.drawRectangleF.Width / 2 - Spacing, (float)this.drawRectangleF.Bottom));
  2637. }
  2638. Spacing += vGridSpacingDraw;
  2639. }
  2640. }
  2641. }
  2642. }
  2643. }
  2644. if (this.p1RectangleFs.Count > 0)
  2645. {
  2646. // 1截点
  2647. foreach (var pointRectangleF in this.p1RectangleFs)
  2648. {
  2649. // 绘制点
  2650. PointF pointF = new PointF(pointRectangleF.X + pointRectangleF.Width / 2, pointRectangleF.Y + pointRectangleF.Height / 2);
  2651. float size = (float)(Convert.ToInt32(this.txt_LeftSize.Text) / unitLength);
  2652. // 圆形
  2653. if (this.rb_LeftCircle.Checked)
  2654. {
  2655. // 实心
  2656. if (this.rb_leftFill.Checked)
  2657. graphics.FillEllipse(new SolidBrush(this.panel1.BackColor), pointF.X - (float)size / 2, pointF.Y - (float)size / 2
  2658. , size, size);
  2659. // 空心
  2660. else
  2661. graphics.DrawEllipse(new Pen(this.panel1.BackColor, Convert.ToInt32(this.txt_LeftLineWeight.Text))
  2662. , pointF.X - (float)size / 2, pointF.Y - (float)size / 2, size, size);
  2663. }
  2664. // 方形
  2665. else
  2666. {
  2667. // 实心
  2668. if (this.rb_leftFill.Checked)
  2669. graphics.FillRectangle(new SolidBrush(this.panel1.BackColor)
  2670. , pointF.X - (float)size / 2, pointF.Y - (float)size / 2, size, size);
  2671. // 空心
  2672. else
  2673. graphics.DrawRectangle(new Pen(this.panel1.BackColor, Convert.ToInt32(this.txt_LeftLineWeight.Text))
  2674. , pointF.X - (float)size / 2, pointF.Y - (float)size / 2, size, size);
  2675. }
  2676. }
  2677. }
  2678. }
  2679. private void textBox2_KeyPress(object sender, KeyPressEventArgs e)
  2680. {
  2681. if (((int)e.KeyChar < 48 || (int)e.KeyChar > 57) && (int)e.KeyChar != 8)
  2682. e.Handled = true;
  2683. }
  2684. private void textBox3_KeyPress(object sender, KeyPressEventArgs e)
  2685. {
  2686. if (((int)e.KeyChar < 48 || (int)e.KeyChar > 57) && (int)e.KeyChar != 8)
  2687. e.Handled = true;
  2688. }
  2689. private void textBox4_KeyPress(object sender, KeyPressEventArgs e)
  2690. {
  2691. if (((int)e.KeyChar < 48 || (int)e.KeyChar > 57) && (int)e.KeyChar != 8)
  2692. e.Handled = true;
  2693. }
  2694. private void textBox5_KeyPress(object sender, KeyPressEventArgs e)
  2695. {
  2696. if (((int)e.KeyChar < 48 || (int)e.KeyChar > 57) && (int)e.KeyChar != 8)
  2697. e.Handled = true;
  2698. }
  2699. private void textBoxLeftSize_KeyPress(object sender, KeyPressEventArgs e)
  2700. {
  2701. if (((int)e.KeyChar < 48 || (int)e.KeyChar > 57) && (int)e.KeyChar != 8)
  2702. e.Handled = true;
  2703. }
  2704. private void textBoxLeftWidth_KeyPress(object sender, KeyPressEventArgs e)
  2705. {
  2706. if (((int)e.KeyChar < 48 || (int)e.KeyChar > 57) && (int)e.KeyChar != 8)
  2707. e.Handled = true;
  2708. }
  2709. private void textBoxRightSize_KeyPress(object sender, KeyPressEventArgs e)
  2710. {
  2711. if (((int)e.KeyChar < 48 || (int)e.KeyChar > 57) && (int)e.KeyChar != 8)
  2712. e.Handled = true;
  2713. }
  2714. private void textBoxRightWidth_KeyPress(object sender, KeyPressEventArgs e)
  2715. {
  2716. if (((int)e.KeyChar < 48 || (int)e.KeyChar > 57) && (int)e.KeyChar != 8)
  2717. e.Handled = true;
  2718. }
  2719. /// <summary>
  2720. /// 水平线值
  2721. /// </summary>
  2722. private string hText;
  2723. /// <summary>
  2724. /// 垂直线值
  2725. /// </summary>
  2726. private string vText;
  2727. /// <summary>
  2728. /// 线宽值
  2729. /// </summary>
  2730. private string wText;
  2731. /// <summary>
  2732. /// 间距值
  2733. /// </summary>
  2734. private string sText;
  2735. /// <summary>
  2736. /// 水平线数量改变
  2737. /// </summary>
  2738. /// <param name="sender"></param>
  2739. /// <param name="e"></param>
  2740. private void textBox2_TextChanged(object sender, EventArgs e)
  2741. {
  2742. PointF pointF = new PointF(this.drawRectangleF.X, this.drawRectangleF.Y);
  2743. if (string.IsNullOrEmpty(this.textBox2.Text) || this.textBox2.Text.Equals("0"))
  2744. this.textBox2.Text = "1";
  2745. if (this.textBox2.Text.Length > 1 && this.textBox2.Text.Substring(0, 1).Equals("0"))
  2746. this.textBox2.Text = this.textBox2.Text.Substring(1, (this.textBox2.Text.Length - 1));
  2747. if (Convert.ToInt32(this.textBox2.Text) > 100000)
  2748. this.textBox2.Text = "100000";
  2749. if (Convert.ToInt32(this.textBox2.Text) > 0)
  2750. this.hNumber = Convert.ToInt32(this.textBox2.Text) + 1;
  2751. else
  2752. this.hNumber = 1;
  2753. if (selectPicture)
  2754. {
  2755. if (this.wholePicture)
  2756. RefreshGridIntersections(false);
  2757. else
  2758. RefreshDrawRegion(pointF, false);
  2759. }
  2760. if (this.exceed)
  2761. this.textBox2.Text = this.hText;
  2762. this.p1RectangleFs.Clear();
  2763. this.vPointCount = 0;
  2764. this.hPointCount = 0;
  2765. this.hText = this.textBox2.Text;
  2766. this.documentWorkspace.Refresh();
  2767. }
  2768. /// <summary>
  2769. /// 垂线数量改变
  2770. /// </summary>
  2771. /// <param name="sender"></param>
  2772. /// <param name="e"></param>
  2773. private void textBox3_TextChanged(object sender, EventArgs e)
  2774. {
  2775. PointF pointF = new PointF(this.drawRectangleF.X, this.drawRectangleF.Y);
  2776. if (string.IsNullOrEmpty(this.textBox3.Text) || this.textBox3.Text.Equals("0"))
  2777. this.textBox3.Text = "1";
  2778. if (this.textBox3.Text.Length > 1 && this.textBox3.Text.Substring(0, 1).Equals("0"))
  2779. this.textBox3.Text = this.textBox3.Text.Substring(1, (this.textBox3.Text.Length - 1));
  2780. if (Convert.ToInt32(this.textBox3.Text) > 100000)
  2781. this.textBox3.Text = "100000";
  2782. if (Convert.ToInt32(this.textBox3.Text) > 0)
  2783. this.vNumber = Convert.ToInt32(this.textBox3.Text) + 1;
  2784. else
  2785. this.vNumber = 1;
  2786. if (selectPicture)
  2787. {
  2788. if (this.wholePicture)
  2789. RefreshGridIntersections(false);
  2790. else
  2791. RefreshDrawRegion(pointF, false);
  2792. }
  2793. if (this.exceed)
  2794. this.textBox3.Text = this.vText;
  2795. this.p1RectangleFs.Clear();
  2796. this.vPointCount = 0;
  2797. this.hPointCount = 0;
  2798. this.vText = this.textBox3.Text;
  2799. this.documentWorkspace.Refresh();
  2800. }
  2801. /// <summary>
  2802. /// 网格线宽改变
  2803. /// </summary>
  2804. /// <param name="sender"></param>
  2805. /// <param name="e"></param>
  2806. private void textBox4_TextChanged(object sender, EventArgs e)
  2807. {
  2808. PointF pointF = new PointF(this.drawRectangleF.X, this.drawRectangleF.Y);
  2809. if (string.IsNullOrEmpty(this.textBox4.Text))
  2810. this.textBox4.Text = "0";
  2811. if (this.textBox4.Text.Length > 1 && this.textBox4.Text.Substring(0, 1).Equals("0"))
  2812. this.textBox4.Text = this.textBox4.Text.Substring(1, (this.textBox4.Text.Length - 1));
  2813. if (Convert.ToInt32(this.textBox4.Text) > 100000)
  2814. this.textBox4.Text = "100000";
  2815. this.gridWidth = Convert.ToInt32(this.textBox4.Text);
  2816. if (selectPicture)
  2817. {
  2818. if (this.wholePicture)
  2819. RefreshGridIntersections(false);
  2820. else
  2821. RefreshDrawRegion(pointF, false);
  2822. }
  2823. if (this.exceed)
  2824. this.textBox4.Text = this.wText;
  2825. this.wText = this.textBox4.Text;
  2826. this.documentWorkspace.Refresh();
  2827. }
  2828. /// <summary>
  2829. /// 网格间距改变
  2830. /// </summary>
  2831. /// <param name="sender"></param>
  2832. /// <param name="e"></param>
  2833. private void textBox5_TextChanged(object sender, EventArgs e)
  2834. {
  2835. PointF pointF = new PointF(this.drawRectangleF.X, this.drawRectangleF.Y);
  2836. if (string.IsNullOrEmpty(this.textBox5.Text))
  2837. this.textBox5.Text = "0";
  2838. if (this.textBox5.Text.Length > 1 && this.textBox5.Text.Substring(0, 1).Equals("0"))
  2839. this.textBox5.Text = this.textBox5.Text.Substring(1, (this.textBox5.Text.Length - 1));
  2840. if (Convert.ToInt32(this.textBox5.Text) > 100000)
  2841. this.textBox5.Text = "100000";
  2842. this.gridSpacing = Convert.ToInt32(this.textBox5.Text);
  2843. if (selectPicture)
  2844. {
  2845. if (this.wholePicture)
  2846. RefreshGridIntersections(false);
  2847. else
  2848. RefreshDrawRegion(pointF, false);
  2849. }
  2850. if (this.exceed)
  2851. this.textBox5.Text = this.sText;
  2852. this.p1RectangleFs.Clear();
  2853. this.vPointCount = 0;
  2854. this.hPointCount = 0;
  2855. this.sText = this.textBox5.Text;
  2856. this.documentWorkspace.Refresh();
  2857. }
  2858. /// <summary>
  2859. /// 网格颜色改变
  2860. /// </summary>
  2861. /// <param name="sender"></param>
  2862. /// <param name="e"></param>
  2863. private void panel4_BackColorChanged(object sender, EventArgs e)
  2864. {
  2865. this.gridColor = Convert.ToInt32(this.panel4.BackColor.ToArgb());
  2866. this.documentWorkspace.Refresh();
  2867. }
  2868. /// <summary>
  2869. /// 是否全图
  2870. /// </summary>
  2871. /// <param name="sender"></param>
  2872. /// <param name="e"></param>
  2873. private void checkBox2_CheckedChanged(object sender, EventArgs e)
  2874. {
  2875. PointF pointF = new PointF(this.drawRectangleF.X, this.drawRectangleF.Y);
  2876. if (this.checkBox2.Checked)
  2877. {
  2878. this.label10.Visible = false;
  2879. this.textBox5.Visible = false;
  2880. this.label12.Visible = true;
  2881. this.numericUpDown4.Visible = true;
  2882. }
  2883. else
  2884. {
  2885. this.label10.Visible = true;
  2886. this.textBox5.Visible = true;
  2887. this.label12.Visible = false;
  2888. this.numericUpDown4.Visible = false;
  2889. }
  2890. this.wholePicture = this.checkBox2.Checked;
  2891. if (selectPicture)
  2892. {
  2893. if (this.wholePicture)
  2894. RefreshGridIntersections(false);
  2895. else
  2896. RefreshDrawRegion(pointF, false);
  2897. }
  2898. this.p1RectangleFs.Clear();
  2899. this.vPointCount = 0;
  2900. this.hPointCount = 0;
  2901. this.documentWorkspace.Refresh();
  2902. }
  2903. /// <summary>
  2904. /// 余白改变
  2905. /// </summary>
  2906. /// <param name="sender"></param>
  2907. /// <param name="e"></param>
  2908. private void numericUpDown4_ValueChanged(object sender, EventArgs e)
  2909. {
  2910. PointF pointF = new PointF(this.drawRectangleF.X, this.drawRectangleF.Y);
  2911. this.blank =(float)(Convert.ToInt32(this.numericUpDown4.Value)/ unitLength);
  2912. if (selectPicture)
  2913. {
  2914. if (this.wholePicture)
  2915. RefreshGridIntersections(false);
  2916. else
  2917. RefreshDrawRegion(pointF, false);
  2918. }
  2919. this.p1RectangleFs.Clear();
  2920. this.vPointCount = 0;
  2921. this.hPointCount = 0;
  2922. this.documentWorkspace.Refresh();
  2923. }
  2924. /// <summary>
  2925. /// 另存为按钮
  2926. /// </summary>
  2927. /// <param name="sender"></param>
  2928. /// <param name="e"></param>
  2929. private void button4_Click(object sender, EventArgs e)
  2930. {
  2931. List<string> items;
  2932. if (this.comboBox1.Items != null && this.comboBox1.Items.Count > 0)
  2933. {
  2934. items = new List<string>(this.comboBox1.Items.Count);
  2935. foreach (var item in this.comboBox1.Items)
  2936. {
  2937. items.Add(item.ToString());
  2938. }
  2939. }
  2940. else
  2941. {
  2942. items = null;
  2943. }
  2944. MicrostructureBandSaveDialog microstructureBandSaveDialog = new MicrostructureBandSaveDialog(items);
  2945. microstructureBandSaveDialog.StartPosition = FormStartPosition.CenterScreen;
  2946. microstructureBandSaveDialog.ShowDialog(this);
  2947. }
  2948. /// <summary>
  2949. /// 切换网格
  2950. /// </summary>
  2951. /// <param name="sender"></param>
  2952. /// <param name="e"></param>
  2953. private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
  2954. {
  2955. if (this.comboBox1.SelectedIndex > -1)
  2956. {
  2957. if (microstructureBandModel.GridStyleList != null)
  2958. {
  2959. foreach (var GridStyle in microstructureBandModel.GridStyleList)
  2960. {
  2961. if (GridStyle.gridName.Equals(this.comboBox1.SelectedItem))
  2962. {
  2963. this.textBox2.Text = GridStyle.hNumber.ToString();
  2964. this.textBox3.Text = GridStyle.vNumber.ToString();
  2965. this.textBox4.Text = GridStyle.gridWidth.ToString();
  2966. this.textBox5.Text = GridStyle.gridSpacing.ToString();
  2967. this.panel4.BackColor = Color.FromArgb(GridStyle.gridColor);
  2968. this.checkBox2.Checked = GridStyle.wholePicture;
  2969. this.numericUpDown4.Value = GridStyle.blank;
  2970. }
  2971. }
  2972. }
  2973. if (this.checkBox2.Checked)
  2974. {
  2975. this.label10.Visible = false;
  2976. this.textBox5.Visible = false;
  2977. this.label12.Visible = true;
  2978. this.numericUpDown4.Visible = true;
  2979. }
  2980. else
  2981. {
  2982. this.label10.Visible = true;
  2983. this.textBox5.Visible = true;
  2984. this.label12.Visible = false;
  2985. this.numericUpDown4.Visible = false;
  2986. }
  2987. this.p1RectangleFs.Clear();
  2988. this.vPointCount = 0;
  2989. this.hPointCount = 0;
  2990. }
  2991. }
  2992. /// <summary>
  2993. /// 截点1形状改变
  2994. /// </summary>
  2995. /// <param name="sender"></param>
  2996. /// <param name="e"></param>
  2997. private void rb_LeftCircle_CheckedChanged(object sender, EventArgs e)
  2998. {
  2999. this.documentWorkspace.Refresh();
  3000. }
  3001. /// <summary>
  3002. /// 截点1样式改变
  3003. /// </summary>
  3004. /// <param name="sender"></param>
  3005. /// <param name="e"></param>
  3006. private void rb_leftFill_CheckedChanged(object sender, EventArgs e)
  3007. {
  3008. if (this.rb_leftFill.Checked)
  3009. {
  3010. this.label20.Visible = false;
  3011. this.txt_LeftLineWeight.Visible = false;
  3012. }
  3013. else
  3014. {
  3015. this.label20.Visible = true;
  3016. this.txt_LeftLineWeight.Visible = true;
  3017. }
  3018. this.documentWorkspace.Refresh();
  3019. }
  3020. /// <summary>
  3021. /// 截点1大小改变
  3022. /// </summary>
  3023. /// <param name="sender"></param>
  3024. /// <param name="e"></param>
  3025. private void txt_LeftSize_TextChanged(object sender, EventArgs e)
  3026. {
  3027. if (string.IsNullOrEmpty(this.txt_LeftSize.Text))
  3028. this.txt_LeftSize.Text = "0";
  3029. if (this.txt_LeftSize.Text.Length > 1 && this.txt_LeftSize.Text.Substring(0, 1).Equals("0"))
  3030. this.txt_LeftSize.Text = this.txt_LeftSize.Text.Substring(1, (this.txt_LeftSize.Text.Length - 1));
  3031. if (Convert.ToInt32(this.txt_LeftSize.Text) > 100000)
  3032. this.txt_LeftSize.Text = "100000";
  3033. if (p1RectangleFs.Count > 0)
  3034. {
  3035. for (int i = 0; i < this.p1RectangleFs.Count; i++)
  3036. {
  3037. RectangleF pointRectangleF = this.p1RectangleFs[i];
  3038. // 绘制点
  3039. PointF pointF = new PointF(pointRectangleF.X + pointRectangleF.Width / 2, pointRectangleF.Y + pointRectangleF.Height / 2);
  3040. float size = (float)(Convert.ToInt32(this.txt_LeftSize.Text) / unitLength);
  3041. RectangleF rectangleF = new RectangleF(pointF.X - (float)size / 2, pointF.Y - (float)size / 2, size, size);
  3042. this.p1RectangleFs[i] = rectangleF;
  3043. }
  3044. }
  3045. this.documentWorkspace.Refresh();
  3046. }
  3047. /// <summary>
  3048. /// 截点1线宽改变
  3049. /// </summary>
  3050. /// <param name="sender"></param>
  3051. /// <param name="e"></param>
  3052. private void txt_LeftLineWeight_TextChanged(object sender, EventArgs e)
  3053. {
  3054. if (string.IsNullOrEmpty(this.txt_LeftLineWeight.Text))
  3055. this.txt_LeftLineWeight.Text = "0";
  3056. if (this.txt_LeftLineWeight.Text.Length > 1 && this.txt_LeftLineWeight.Text.Substring(0, 1).Equals("0"))
  3057. this.txt_LeftLineWeight.Text = this.txt_LeftLineWeight.Text.Substring(1, (this.txt_LeftLineWeight.Text.Length - 1));
  3058. if (Convert.ToInt32(this.txt_LeftLineWeight.Text) > 100000)
  3059. this.txt_LeftLineWeight.Text = "100000";
  3060. this.documentWorkspace.Refresh();
  3061. }
  3062. /// <summary>
  3063. /// 开始测量
  3064. /// </summary>
  3065. /// <param name="sender"></param>
  3066. /// <param name="e"></param>
  3067. private void button6_Click(object sender, EventArgs e)
  3068. {
  3069. //if (this.listView1.SelectedItems.Count > 0)
  3070. //{
  3071. this.startText = true;
  3072. this.button6.Visible = false;
  3073. this.button7.Visible = true;
  3074. this.comboBox1.Enabled = false;
  3075. this.button3.Enabled = false;
  3076. this.button4.Enabled = false;
  3077. this.button5.Enabled = false;
  3078. this.groupBox4.Enabled = false;
  3079. this.button7.Focus();
  3080. if (this.dataGridView1.Rows.Count > 0)
  3081. {
  3082. this.dataGridView1.Rows.Clear();
  3083. this.dataGridView3.Rows.Clear();
  3084. this.p1RectangleFs.Clear();
  3085. this.vPointCount = 0;
  3086. this.hPointCount = 0;
  3087. this.documentWorkspace.Refresh();
  3088. }
  3089. if (!this.button6.Visible && this.listView1.FocusedItem != null && this.documentWorkspace.phaseModels.Count != 0 && this.checkBox4.Checked)
  3090. {
  3091. GetNumberOfGrains();
  3092. RefreshResultsData();
  3093. }
  3094. //}
  3095. //else
  3096. //{
  3097. // MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectapicture.text")+"!");
  3098. //}
  3099. this.documentWorkspace.Refresh();
  3100. }
  3101. /// <summary>
  3102. /// 停止测量
  3103. /// </summary>
  3104. /// <param name="sender"></param>
  3105. /// <param name="e"></param>
  3106. private void button7_Click(object sender, EventArgs e)
  3107. {
  3108. this.button6.Visible = true;
  3109. this.button7.Visible = false;
  3110. this.comboBox1.Enabled = true;
  3111. this.button3.Enabled = true;
  3112. this.button4.Enabled = true;
  3113. this.button5.Enabled = true;
  3114. this.groupBox4.Enabled = true;
  3115. this.button6.Focus();
  3116. }
  3117. /// <summary>
  3118. /// 截点颜色改变
  3119. /// </summary>
  3120. /// <param name="sender"></param>
  3121. /// <param name="e"></param>
  3122. private void panel1_BackColorChanged(object sender, EventArgs e)
  3123. {
  3124. this.documentWorkspace.Refresh();
  3125. }
  3126. /// <summary>
  3127. /// 保存按钮
  3128. /// </summary>
  3129. /// <param name="sender"></param>
  3130. /// <param name="e"></param>
  3131. private void button3_Click(object sender, EventArgs e)
  3132. {
  3133. if (this.comboBox1.Items.Count == 0)
  3134. {
  3135. MicrostructureBandSaveDialog microstructureBandSaveDialog = new MicrostructureBandSaveDialog(null);
  3136. microstructureBandSaveDialog.StartPosition = FormStartPosition.CenterScreen;
  3137. microstructureBandSaveDialog.ShowDialog(this);
  3138. }
  3139. else
  3140. {
  3141. RefreshGridItems(null);
  3142. }
  3143. }
  3144. /// <summary>
  3145. /// 删除选中网格
  3146. /// </summary>
  3147. /// <param name="sender"></param>
  3148. /// <param name="e"></param>
  3149. private void button5_Click(object sender, EventArgs e)
  3150. {
  3151. if (this.comboBox1.SelectedIndex > -1 && this.comboBox1.DataSource != null)
  3152. {
  3153. DialogResult dr = MessageBox.Show(PdnResources.GetString("Menu.Areyousuretodeletethegrid.text")+"?", PdnResources.GetString("Menu.hint.text"), MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
  3154. if (dr == DialogResult.OK)
  3155. {
  3156. int index = this.comboBox1.SelectedIndex;
  3157. if (this.microstructureBandModel.GridStyleList != null)
  3158. {
  3159. foreach (var GridStyle in this.microstructureBandModel.GridStyleList)
  3160. {
  3161. if (GridStyle.gridName.Equals(this.comboBox1.SelectedItem))
  3162. {
  3163. this.microstructureBandModel.GridStyleList.Remove(GridStyle);
  3164. break;
  3165. }
  3166. }
  3167. }
  3168. ArrayList arrayList = new ArrayList();
  3169. foreach (var GridStyle in microstructureBandModel.GridStyleList)
  3170. {
  3171. arrayList.Add(GridStyle.gridName);
  3172. }
  3173. this.comboBox1.DataSource = null;
  3174. this.comboBox1.DataSource = arrayList;
  3175. if (this.comboBox1.Items.Count > 0)
  3176. {
  3177. if (index == 0)
  3178. this.comboBox1.SelectedIndex = index;
  3179. else
  3180. this.comboBox1.SelectedIndex = index - 1;
  3181. }
  3182. else
  3183. {
  3184. this.textBox2.Text = "0";
  3185. this.textBox3.Text = "0";
  3186. this.textBox4.Text = "0";
  3187. this.textBox5.Text = "0";
  3188. this.numericUpDown4.Value = 0;
  3189. this.checkBox2.Checked = false;
  3190. this.label10.Visible = true;
  3191. this.textBox5.Visible = true;
  3192. this.label12.Visible = false;
  3193. this.numericUpDown4.Visible = false;
  3194. this.dataGridView1.Rows.Clear();
  3195. this.dataGridView3.Rows.Clear();
  3196. }
  3197. //以下保存xml文件信息
  3198. string stageModelXml = XmlSerializeHelper.XmlSerialize<MicrostructureBandModel>(microstructureBandModel);
  3199. string filePath = Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\MicrostructureBandModel.xml";
  3200. FileOperationHelper.WriteStringToFile(stageModelXml, filePath, FileMode.Create);
  3201. }
  3202. }
  3203. else
  3204. {
  3205. MessageBox.Show(PdnResources.GetString("Menu.Nogrid.text")+"!");
  3206. }
  3207. }
  3208. /// <summary>
  3209. /// 鼠标按下
  3210. /// </summary>
  3211. /// <param name="drawArea"></param>
  3212. /// <param name="e"></param>
  3213. private void OnMouseDown(object sender, MouseEventArgs e)
  3214. {
  3215. // 换算后的点
  3216. PointF point1 = documentWorkspace.GetScalePoint(e.Location);
  3217. if (!this.wholePicture && this.checkBox5.Checked)
  3218. {
  3219. if (e.Button == MouseButtons.Left)
  3220. {
  3221. if (this.drawRectangleF.Contains(point1))
  3222. {
  3223. canMove = true;
  3224. oldLocation = point1;
  3225. selected = true;
  3226. this.documentWorkspace.panel.Focus();
  3227. }
  3228. else
  3229. selected = false;
  3230. }
  3231. }
  3232. if (this.checkBox5.Checked)
  3233. return;
  3234. if (this.button6.Visible)
  3235. {
  3236. MessageBox.Show(PdnResources.GetString("Menu.Pleasestartmeasuring.text")+"!");
  3237. return;
  3238. }
  3239. if (this.documentWorkspace.phaseModels.Count == 0 || (this.documentWorkspace.phaseModels.Count != 0 && this.documentWorkspace.phaseModels[0].mat == null))
  3240. {
  3241. MessageBox.Show(PdnResources.GetString("Menu.Pleaseperformbinarizationoperationfirst.text")+"!");
  3242. return;
  3243. }
  3244. bool canAdd1 = true;
  3245. if (p1RectangleFs.Count > 0)
  3246. {
  3247. bool deleteP = false;
  3248. PointF deletePoint = new PointF();
  3249. foreach (var rectangleF in p1RectangleFs)
  3250. {
  3251. if (rectangleF.Contains(point1))
  3252. {
  3253. canAdd1 = false;
  3254. deletePoint = new PointF(rectangleF.X + rectangleF.Width / 2, rectangleF.Y + rectangleF.Height / 2);
  3255. if (e.Button == MouseButtons.Left && e.Clicks == 2)
  3256. {
  3257. deleteP = true;
  3258. p1RectangleFs.Remove(rectangleF);
  3259. this.saveSuccess = true;
  3260. break;
  3261. }
  3262. }
  3263. }
  3264. if (deleteP)
  3265. {
  3266. foreach (RectangleF rectangleF in this.vRectangleFs)
  3267. {
  3268. if (rectangleF.Contains(deletePoint))
  3269. {
  3270. this.vPointCount--;
  3271. RefreshResultsData();
  3272. return;
  3273. }
  3274. }
  3275. foreach (RectangleF rectangleF in this.hRectangleFs)
  3276. {
  3277. if (rectangleF.Contains(deletePoint))
  3278. {
  3279. this.hPointCount--;
  3280. RefreshResultsData();
  3281. return;
  3282. }
  3283. }
  3284. }
  3285. }
  3286. if (e.Button == MouseButtons.Left)
  3287. {
  3288. float size = (float)(Convert.ToInt32(this.txt_LeftSize.Text) / unitLength);
  3289. foreach (RectangleF rectangleF in this.vRectangleFs)
  3290. {
  3291. if (canAdd1)
  3292. {
  3293. if (rectangleF.Contains(point1))
  3294. {
  3295. p1RectangleFs.Add(new RectangleF(rectangleF.X + (float)rectangleF.Width / 2 - (float)(size / 2)
  3296. , point1.Y - (float)(size / 2)
  3297. , size, size));
  3298. this.saveSuccess = true;
  3299. this.vPointCount++;
  3300. RefreshResultsData();
  3301. return;
  3302. }
  3303. }
  3304. }
  3305. foreach (RectangleF rectangleF in this.hRectangleFs)
  3306. {
  3307. if (canAdd1)
  3308. {
  3309. if (rectangleF.Contains(point1))
  3310. {
  3311. p1RectangleFs.Add(new RectangleF(point1.X - (float)(size / 2)
  3312. , rectangleF.Y + (float)rectangleF.Height / 2 - (float)(size / 2)
  3313. , size, size));
  3314. this.saveSuccess = true;
  3315. this.hPointCount++;
  3316. RefreshResultsData();
  3317. return;
  3318. }
  3319. }
  3320. }
  3321. }
  3322. }
  3323. /// <summary>
  3324. /// 移动
  3325. /// </summary>
  3326. /// <param name="sender"></param>
  3327. /// <param name="e"></param>
  3328. private void onMouseMove(object sender, MouseEventArgs e)
  3329. {
  3330. if (!this.wholePicture && this.checkBox5.Checked)
  3331. {
  3332. // 换算后的点
  3333. PointF point1 = documentWorkspace.GetScalePoint(e.Location);
  3334. if (e.Button == MouseButtons.Left && canMove)
  3335. {
  3336. // 矩形偏移
  3337. this.drawRectangleF.Offset(point1.X - this.oldLocation.X, point1.Y - this.oldLocation.Y);
  3338. if (this.p1RectangleFs.Count > 0)
  3339. {
  3340. for (int i = 0; i < this.p1RectangleFs.Count; i++)
  3341. {
  3342. RectangleF rectangleF1 = this.p1RectangleFs[i];
  3343. rectangleF1.Offset(point1.X - this.oldLocation.X, point1.Y - this.oldLocation.Y);
  3344. this.p1RectangleFs[i] = rectangleF1;
  3345. }
  3346. }
  3347. this.oldLocation = point1;
  3348. RefreshDrawRegion(this.drawRectangleF.Location, true);
  3349. if (checkBox4.Checked)
  3350. {
  3351. GetNumberOfGrains();
  3352. RefreshResultsData();
  3353. }
  3354. this.documentWorkspace.Refresh();
  3355. }
  3356. }
  3357. }
  3358. /// <summary>
  3359. /// 鼠标抬起
  3360. /// </summary>
  3361. /// <param name="sender"></param>
  3362. /// <param name="e"></param>
  3363. private void OnMouseUp(object sender, MouseEventArgs e)
  3364. {
  3365. canMove = false;
  3366. }
  3367. /// <summary>
  3368. /// 键盘事件
  3369. /// </summary>
  3370. /// <param name="sender"></param>
  3371. /// <param name="e"></param>
  3372. private void onPreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
  3373. {
  3374. if (this.selected && (e.KeyCode == Keys.Up || e.KeyCode == Keys.Down || e.KeyCode == Keys.Left || e.KeyCode == Keys.Right))
  3375. {
  3376. PointF pointF = this.drawRectangleF.Location;
  3377. if (e.KeyCode == Keys.Up)
  3378. pointF.Y -= 5;
  3379. else if (e.KeyCode == Keys.Down)
  3380. pointF.Y += 5;
  3381. else if (e.KeyCode == Keys.Left)
  3382. pointF.X -= 5;
  3383. else if (e.KeyCode == Keys.Right)
  3384. pointF.X += 5;
  3385. this.drawRectangleF.Location = pointF;
  3386. if (this.p1RectangleFs.Count > 0)
  3387. {
  3388. RectangleF rectangleF = new RectangleF();
  3389. PointF pointF1 = new PointF();
  3390. for (int i = 0; i < this.p1RectangleFs.Count; i++)
  3391. {
  3392. rectangleF = this.p1RectangleFs[i];
  3393. pointF1 = this.p1RectangleFs[i].Location;
  3394. if (e.KeyCode == Keys.Up)
  3395. pointF1.Y -= 5;
  3396. else if (e.KeyCode == Keys.Down)
  3397. pointF1.Y += 5;
  3398. else if (e.KeyCode == Keys.Left)
  3399. pointF1.X -= 5;
  3400. else if (e.KeyCode == Keys.Right)
  3401. pointF1.X += 5;
  3402. rectangleF.Location = pointF1;
  3403. this.p1RectangleFs[i] = rectangleF;
  3404. }
  3405. }
  3406. }
  3407. RefreshDrawRegion(this.drawRectangleF.Location, true);
  3408. GetNumberOfGrains();
  3409. RefreshResultsData();
  3410. this.documentWorkspace.Refresh();
  3411. }
  3412. private void dataGridView1_SelectionChanged(object sender, EventArgs e)
  3413. {
  3414. this.documentWorkspace.Refresh();
  3415. }
  3416. /// <summary>
  3417. /// 取消全部显示
  3418. /// </summary>
  3419. /// <param name="sender"></param>
  3420. /// <param name="e"></param>
  3421. private void button16_Click(object sender, EventArgs e)
  3422. {
  3423. this.allShow = false;
  3424. this.button11.Visible = true;
  3425. this.button16.Visible = false;
  3426. if (this.listView2.Items.Count > 0)
  3427. {
  3428. if (this.listView2.SelectedItems.Count > 0)
  3429. {
  3430. List<int> dataTableIndex = new List<int>();
  3431. if (this.pictureDataTables.Count == 0)
  3432. return;
  3433. for (int i = 0; i < this.pictureDataTables.Count; i++)
  3434. {
  3435. foreach (ListViewItem item in this.listView2.SelectedItems)
  3436. {
  3437. if (this.pictureDataTables[i].TableName.Equals(item.Tag))
  3438. dataTableIndex.Add(i);
  3439. }
  3440. }
  3441. this.dataGridView2.Rows.Clear();
  3442. foreach (int item in dataTableIndex)
  3443. {
  3444. if (this.pictureDataTables[item].Rows.Count > 0)
  3445. {
  3446. for (int r = 0; r < this.pictureDataTables[item].Rows.Count; r++)
  3447. {
  3448. DataGridViewRow dgvr = new DataGridViewRow();
  3449. dgvr.Tag = this.pictureDataTables[item].TableName;
  3450. foreach (DataGridViewColumn Column in this.dataGridView2.Columns)
  3451. {
  3452. dgvr.Cells.Add(Column.CellTemplate.Clone() as DataGridViewCell);
  3453. }
  3454. for (int c = 0; c < this.pictureDataTables[item].Columns.Count; c++)
  3455. {
  3456. if (c > 1)
  3457. dgvr.Cells[c].Value = Math.Round((double)Convert.ToDecimal(this.pictureDataTables[item].Rows[r][c]), Convert.ToInt32(this.numericUpDown1.Value)).ToString();
  3458. else
  3459. dgvr.Cells[c].Value = this.pictureDataTables[item].Rows[r][c].ToString();
  3460. }
  3461. this.dataGridView2.Rows.Add(dgvr);
  3462. }
  3463. }
  3464. }
  3465. }
  3466. else
  3467. {
  3468. this.listView2.Items[0].Selected = true;
  3469. if (this.pictureDataTables.Count > 0
  3470. && this.pictureDataTables[this.pictureDataTables.Count - 1].Rows.Count > 0)
  3471. {
  3472. this.dataGridView2.Rows.Clear();
  3473. for (int r = 0; r < this.pictureDataTables[this.pictureDataTables.Count - 1].Rows.Count; r++)
  3474. {
  3475. DataGridViewRow dgvr = new DataGridViewRow();
  3476. dgvr.Tag = this.pictureDataTables[this.pictureDataTables.Count - 1].TableName;
  3477. foreach (DataGridViewColumn Column in this.dataGridView2.Columns)
  3478. {
  3479. dgvr.Cells.Add(Column.CellTemplate.Clone() as DataGridViewCell);
  3480. }
  3481. for (int c = 0; c < this.pictureDataTables[this.pictureDataTables.Count - 1].Columns.Count; c++)
  3482. {
  3483. if (c > 1)
  3484. dgvr.Cells[c].Value = Math.Round((double)Convert.ToDecimal(this.pictureDataTables[this.pictureDataTables.Count - 1].Rows[r][c]), Convert.ToInt32(this.numericUpDown1.Value)).ToString();
  3485. else
  3486. dgvr.Cells[c].Value = this.pictureDataTables[this.pictureDataTables.Count - 1].Rows[r][c].ToString();
  3487. }
  3488. this.dataGridView2.Rows.Add(dgvr);
  3489. }
  3490. }
  3491. }
  3492. ResultCalculation();
  3493. }
  3494. }
  3495. /// <summary>
  3496. /// 分析结果删除
  3497. /// </summary>
  3498. /// <param name="sender"></param>
  3499. /// <param name="e"></param>
  3500. private void button12_Click(object sender, EventArgs e)
  3501. {
  3502. if (this.listView2.Items.Count > 0)
  3503. {
  3504. if (this.listView2.SelectedItems.Count > 0)
  3505. {
  3506. DialogResult dr = MessageBox.Show(PdnResources.GetString("Menu.Areyousuretodeletethisanalysisresult.text")+"?", PdnResources.GetString("Menu.hint.text"), MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
  3507. if (dr == DialogResult.OK)
  3508. {
  3509. List<string> detaleName = new List<string>();
  3510. int selectIndex = this.listView2.SelectedItems[0].Index;
  3511. foreach (ListViewItem item in this.listView2.SelectedItems)
  3512. {
  3513. detaleName.Add(item.Tag.ToString());
  3514. this.listView2.Items.Remove(item);
  3515. }
  3516. foreach (string item in detaleName)
  3517. {
  3518. foreach (DataTable dataTable in this.pictureDataTables)
  3519. {
  3520. if (dataTable.TableName.Equals(item))
  3521. {
  3522. this.pictureDataTables.Remove(dataTable);
  3523. break;
  3524. }
  3525. }
  3526. if (bitDic.ContainsKey(item))
  3527. bitDic.Remove(item);
  3528. foreach (ExportProjectModel model in this.tempDataModel)
  3529. {
  3530. if (model.tagName.Equals(item))
  3531. {
  3532. this.tempDataModel.Remove(model);
  3533. break;
  3534. }
  3535. }
  3536. }
  3537. if (this.listView2.Items.Count > 0)
  3538. {
  3539. if (selectIndex == 0)
  3540. this.listView2.Items[0].Selected = true;
  3541. else
  3542. this.listView2.Items[selectIndex - 1].Selected = true;
  3543. RefreshDataGridView4();
  3544. }
  3545. else
  3546. {
  3547. this.dataGridView2.Rows.Clear();
  3548. }
  3549. ResultCalculation();
  3550. }
  3551. }
  3552. else
  3553. {
  3554. MessageBox.Show(PdnResources.GetString("Menu.Pleaseselecttheanalysisresulttodelete.text")+"!");
  3555. }
  3556. }
  3557. else
  3558. {
  3559. MessageBox.Show(PdnResources.GetString("Menu.Nodataintheanalysisresults.text")+"!");
  3560. }
  3561. }
  3562. /// <summary>
  3563. /// 刷新分析结果数据
  3564. /// </summary>
  3565. private void RefreshDataGridView4()
  3566. {
  3567. if (!this.allShow)
  3568. {
  3569. if (this.listView2.SelectedItems.Count > 0)
  3570. {
  3571. List<int> dataTableIndex = new List<int>();
  3572. for (int i = 0; i < this.pictureDataTables.Count; i++)
  3573. {
  3574. foreach (ListViewItem item in this.listView2.SelectedItems)
  3575. {
  3576. if (this.pictureDataTables[i].TableName.Equals(item.Tag))
  3577. dataTableIndex.Add(i);
  3578. }
  3579. }
  3580. if (this.pictureDataTables.Count == 0)
  3581. return;
  3582. this.dataGridView2.Rows.Clear();
  3583. foreach (int item in dataTableIndex)
  3584. {
  3585. if (this.pictureDataTables[item].Rows.Count > 0)
  3586. {
  3587. for (int r = 0; r < this.pictureDataTables[item].Rows.Count; r++)
  3588. {
  3589. DataGridViewRow dgvr = new DataGridViewRow();
  3590. dgvr.Tag = this.pictureDataTables[item].TableName;
  3591. foreach (DataGridViewColumn Column in this.dataGridView2.Columns)
  3592. {
  3593. dgvr.Cells.Add(Column.CellTemplate.Clone() as DataGridViewCell);
  3594. }
  3595. for (int c = 0; c < this.pictureDataTables[item].Columns.Count; c++)
  3596. {
  3597. if (c < 2)
  3598. dgvr.Cells[c].Value = this.pictureDataTables[item].Rows[r][c].ToString();
  3599. else
  3600. dgvr.Cells[c].Value = Math.Round((double)Convert.ToDecimal(this.pictureDataTables[item].Rows[r][c]), Convert.ToInt32(this.numericUpDown1.Value)).ToString();
  3601. }
  3602. this.dataGridView2.Rows.Add(dgvr);
  3603. }
  3604. }
  3605. }
  3606. }
  3607. }
  3608. else
  3609. {
  3610. this.dataGridView2.Rows.Clear();
  3611. DataTable dataTable = new DataTable();
  3612. for (int i = this.pictureDataTables.Count - 1; i >= 0; i--)
  3613. {
  3614. dataTable = this.pictureDataTables[i];
  3615. for (int r = 0; r < dataTable.Rows.Count; r++)
  3616. {
  3617. DataGridViewRow dgvr = new DataGridViewRow();
  3618. dgvr.Tag = dataTable.TableName;
  3619. foreach (DataGridViewColumn Column in this.dataGridView2.Columns)
  3620. {
  3621. dgvr.Cells.Add(Column.CellTemplate.Clone() as DataGridViewCell);
  3622. }
  3623. for (int c = 0; c < dataTable.Columns.Count; c++)
  3624. {
  3625. if (c < 2)
  3626. dgvr.Cells[c].Value = dataTable.Rows[r][c].ToString();
  3627. else
  3628. dgvr.Cells[c].Value = Math.Round((double)Convert.ToDecimal(dataTable.Rows[r][c]), Convert.ToInt32(this.numericUpDown1.Value)).ToString();
  3629. }
  3630. this.dataGridView2.Rows.Add(dgvr);
  3631. }
  3632. }
  3633. }
  3634. }
  3635. /// <summary>
  3636. /// 切换分析结果
  3637. /// </summary>
  3638. /// <param name="sender"></param>
  3639. /// <param name="e"></param>
  3640. private void listView2_SelectedIndexChanged(object sender, EventArgs e)
  3641. {
  3642. if (!this.allShow)
  3643. {
  3644. if (this.listView2.SelectedItems.Count > 0)
  3645. {
  3646. List<int> dataTableIndex = new List<int>();
  3647. if (this.pictureDataTables.Count == 0)
  3648. return;
  3649. for (int i = 0; i < this.pictureDataTables.Count; i++)
  3650. {
  3651. foreach (ListViewItem item in this.listView2.SelectedItems)
  3652. {
  3653. if (this.pictureDataTables[i].TableName.Equals(item.Tag))
  3654. dataTableIndex.Add(i);
  3655. }
  3656. }
  3657. this.dataGridView2.Rows.Clear();
  3658. foreach (int item in dataTableIndex)
  3659. {
  3660. if (this.pictureDataTables[item].Rows.Count > 0)
  3661. {
  3662. for (int r = 0; r < this.pictureDataTables[item].Rows.Count; r++)
  3663. {
  3664. DataGridViewRow dgvr = new DataGridViewRow();
  3665. dgvr.Tag = this.pictureDataTables[item].TableName;
  3666. foreach (DataGridViewColumn Column in this.dataGridView2.Columns)
  3667. {
  3668. dgvr.Cells.Add(Column.CellTemplate.Clone() as DataGridViewCell);
  3669. }
  3670. for (int c = 0; c < this.pictureDataTables[item].Columns.Count; c++)
  3671. {
  3672. if (c > 1)
  3673. dgvr.Cells[c].Value = Math.Round((double)Convert.ToDecimal(this.pictureDataTables[item].Rows[r][c]), Convert.ToInt32(this.numericUpDown1.Value)).ToString();
  3674. else
  3675. dgvr.Cells[c].Value = this.pictureDataTables[item].Rows[r][c].ToString();
  3676. }
  3677. this.dataGridView2.Rows.Add(dgvr);
  3678. }
  3679. }
  3680. }
  3681. }
  3682. }
  3683. ResultCalculation();
  3684. }
  3685. /// <summary>
  3686. /// 未选择分析结果
  3687. /// </summary>
  3688. /// <param name="sender"></param>
  3689. /// <param name="e"></param>
  3690. private void listView2_ItemSelectionChanged(object sender, ListViewItemSelectionChangedEventArgs e)
  3691. {
  3692. if (!this.allShow)
  3693. {
  3694. if (this.listView2.SelectedItems.Count == 0)
  3695. {
  3696. this.dataGridView2.Rows.Clear();
  3697. this.dataGridView4.Rows.Clear();
  3698. }
  3699. }
  3700. }
  3701. /// <summary>
  3702. /// 全部显示
  3703. /// </summary>
  3704. /// <param name="sender"></param>
  3705. /// <param name="e"></param>
  3706. private void button11_Click(object sender, EventArgs e)
  3707. {
  3708. this.allShow = true;
  3709. this.button11.Visible = false;
  3710. this.button16.Visible = true;
  3711. this.button16.Focus();
  3712. AllShow();
  3713. ResultCalculation();
  3714. }
  3715. private void AllShow()
  3716. {
  3717. this.dataGridView2.Rows.Clear();
  3718. DataTable dataTable = new DataTable();
  3719. for (int i = this.pictureDataTables.Count - 1; i >= 0; i--)
  3720. {
  3721. dataTable = this.pictureDataTables[i];
  3722. for (int r = 0; r < dataTable.Rows.Count; r++)
  3723. {
  3724. DataGridViewRow dgvr = new DataGridViewRow();
  3725. dgvr.Tag = dataTable.TableName;
  3726. foreach (DataGridViewColumn Column in this.dataGridView2.Columns)
  3727. {
  3728. dgvr.Cells.Add(Column.CellTemplate.Clone() as DataGridViewCell);
  3729. }
  3730. for (int c = 0; c < dataTable.Columns.Count; c++)
  3731. {
  3732. if (c > 1)
  3733. dgvr.Cells[c].Value = Math.Round((double)Convert.ToDecimal(dataTable.Rows[r][c]), Convert.ToInt32(this.numericUpDown1.Value)).ToString();
  3734. else
  3735. dgvr.Cells[c].Value = dataTable.Rows[r][c].ToString();
  3736. }
  3737. this.dataGridView2.Rows.Add(dgvr);
  3738. }
  3739. }
  3740. }
  3741. /// <summary>
  3742. /// 保存结果
  3743. /// </summary>
  3744. /// <param name="sender"></param>
  3745. /// <param name="e"></param>
  3746. private void button2_Click(object sender, EventArgs e)
  3747. {
  3748. SaveMeasurementResults();
  3749. }
  3750. /// <summary>
  3751. /// 保存结果
  3752. /// </summary>
  3753. private void SaveMeasurementResults()
  3754. {
  3755. if (this.listView1.SelectedItems.Count == 0)
  3756. {
  3757. MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectapicture.text")+"!");
  3758. return;
  3759. }
  3760. if (this.dataGridView1.Rows.Count == 0)
  3761. {
  3762. MessageBox.Show(PdnResources.GetString("Menu.Noresultdata,pleaseaddsection.text")+"!");
  3763. return;
  3764. }
  3765. string imgName = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].GetFriendlyName();
  3766. string tag = this.imageList1.Images.Keys[this.listView1.SelectedItems[0].Index];
  3767. DataTable dataTable1 = new DataTable();
  3768. bool replace = false;
  3769. int add = 0;
  3770. foreach (ListViewItem item in this.listView2.Items)
  3771. {
  3772. if (item.Tag.Equals(tag))
  3773. {
  3774. add++;
  3775. DialogResult dr = MessageBox.Show(PdnResources.GetString("Menu.Themeasurementdertoreplace.text")+"?", PdnResources.GetString("Menu.hint.text"), MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
  3776. if (dr == DialogResult.OK)
  3777. {
  3778. replace = true;
  3779. this.listView2.Items.Remove(item);
  3780. }
  3781. break;
  3782. }
  3783. }
  3784. if (replace || this.listView2.Items.Count == 0 || add == 0)
  3785. {
  3786. ListViewItem listViewItem = new ListViewItem();
  3787. listViewItem.SubItems[0].Text = imgName;
  3788. listViewItem.Tag = tag;
  3789. if (this.listView2.Items.Count == 0)
  3790. this.listView2.Items.Add(listViewItem);
  3791. else
  3792. this.listView2.Items.Insert(0, listViewItem);
  3793. dataTable1.TableName = tag;
  3794. this.dataGridView2.Rows.Clear();
  3795. foreach (DataGridViewRow Row in this.dataGridView1.Rows)
  3796. {
  3797. DataGridViewRow dgvr = new DataGridViewRow();
  3798. dgvr.Tag = tag;
  3799. foreach (DataGridViewColumn Column in this.dataGridView2.Columns)
  3800. {
  3801. dgvr.Cells.Add(Column.CellTemplate.Clone() as DataGridViewCell);
  3802. }
  3803. dgvr.Cells[0].Value = imgName;
  3804. dgvr.Cells[1].Value = Row.Cells[0].Value;
  3805. dgvr.Cells[2].Value = Row.Cells[1].Value;
  3806. dgvr.Cells[3].Value = Row.Cells[2].Value;
  3807. dgvr.Cells[4].Value = Row.Cells[3].Value;
  3808. dgvr.Cells[5].Value = Row.Cells[4].Value;
  3809. this.dataGridView2.Rows.Add(dgvr);
  3810. }
  3811. foreach (DataTable dataTable2 in pictureDataTables)
  3812. {
  3813. if (dataTable2.TableName.Equals(dataTable1.TableName))
  3814. {
  3815. pictureDataTables.Remove(dataTable2);
  3816. break;
  3817. }
  3818. }
  3819. foreach (DataGridViewColumn c in this.dataGridView2.Columns)
  3820. {
  3821. dataTable1.Columns.Add(c.HeaderText);
  3822. }
  3823. for (int r = 0; r < this.dataGridView3.Rows.Count; r++)
  3824. {
  3825. DataRow dataRow = dataTable1.NewRow();
  3826. for (int c = 0; c < this.dataGridView3.Rows[r].Cells.Count + 1; c++)
  3827. {
  3828. if (c == 0)
  3829. dataRow[this.dataGridView2.Columns[c].HeaderText] = imgName;
  3830. else
  3831. dataRow[this.dataGridView2.Columns[c].HeaderText] = this.dataGridView3.Rows[r].Cells[c - 1].Value;
  3832. }
  3833. dataTable1.Rows.Add(dataRow);
  3834. }
  3835. this.pictureDataTables.Add(dataTable1);
  3836. if (this.allShow)
  3837. AllShow();
  3838. this.listView2.Items[0].Selected = true;
  3839. this.saveSuccess = false;
  3840. switchImg = true;
  3841. if(this.documentWorkspace.PhaseModels[0].mat !=null)
  3842. {
  3843. //保存处理后的图片
  3844. double pantographRatio = (double)this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].GetRulerMultiple(MeasurementUnit.Micron);//标尺*放大倍数
  3845. List<Bitmap> tempBit = new List<Bitmap>();
  3846. Bitmap originalBit = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].CompositionSurface.CreateAliasedBitmap();
  3847. originalBit.Tag = pantographRatio;
  3848. tempBit.Add(originalBit);
  3849. Bitmap processedBit = BitmapConverter.ToBitmap(this.documentWorkspace.PhaseModels[0].mat);
  3850. Bitmap newBit = originalBit.Clone(new Rectangle(0, 0, originalBit.Width, originalBit.Height), originalBit.PixelFormat);
  3851. Graphics graphics = Graphics.FromImage(newBit);
  3852. graphics.DrawImage(processedBit, new PointF(0, 0));
  3853. Draw(graphics);
  3854. newBit.Tag = pantographRatio;
  3855. tempBit.Add(newBit);
  3856. if (bitDic.ContainsKey(tag))
  3857. bitDic[tag] = tempBit;
  3858. else
  3859. bitDic.Add(tag, tempBit);
  3860. }
  3861. double unitLength;
  3862. this.appWorkspace.getMeasureInfo().TryGetValue(MeasurementUnit.Millimeter, out unitLength);
  3863. decimal lv = 0;
  3864. decimal lh = 0;
  3865. if (this.vRectangleFs.Count > 0)
  3866. lv = ((decimal)this.vRectangleFs[0].Height - 6) * this.vNumber;
  3867. if (this.hRectangleFs.Count > 0)
  3868. lh = ((decimal)this.hRectangleFs[0].Width - 6) * this.hNumber;
  3869. //拼接中间数据
  3870. List<List<string>> dataList = new List<List<string>>();
  3871. List<string> columnName = new List<string>();
  3872. columnName.Add(PdnResources.GetString("Menu.Imagement.Measurementlist.ordernumber.text"));
  3873. columnName.Add(PdnResources.GetString("Menu.Thenumberofpointsonaverticalline.text"));
  3874. columnName.Add(PdnResources.GetString("Menu.Pointsonparallellines.text"));
  3875. columnName.Add(PdnResources.GetString("Menu.Verticallength.text"));
  3876. columnName.Add(PdnResources.GetString("Menu.VerticalThelengthofparallellinesength.text"));
  3877. dataList.Add(columnName);
  3878. List<string> strList = new List<string>();
  3879. strList.Add("1");
  3880. strList.Add(this.vPointCount.ToString());
  3881. strList.Add(this.hPointCount.ToString());
  3882. strList.Add(((decimal)lv * (decimal)unitLength).ToString());
  3883. strList.Add(((decimal)lh * (decimal)unitLength).ToString());
  3884. dataList.Add(strList);
  3885. bool isExist = false;//是否已存在进行替换
  3886. int modelIndex = -1;//要替换的下标
  3887. for (int j = 0; j < tempDataModel.Count; j++)
  3888. {
  3889. if (tempDataModel[j].tagName.Equals(tag))
  3890. {
  3891. isExist = true;
  3892. modelIndex = j;
  3893. break;
  3894. }
  3895. }
  3896. if (isExist && modelIndex > -1)
  3897. tempDataModel[modelIndex].dataList = dataList;
  3898. else
  3899. {
  3900. ExportProjectModel newModel = new ExportProjectModel();
  3901. newModel.tagName = tag;
  3902. newModel.picName = imgName;
  3903. newModel.dataList = dataList;
  3904. tempDataModel.Add(newModel);
  3905. }
  3906. }
  3907. }
  3908. /// <summary>
  3909. /// 结果计算
  3910. /// </summary>
  3911. private void ResultCalculation()
  3912. {
  3913. if (this.pictureDataTables.Count == 0)
  3914. return;
  3915. if (!this.allShow && this.listView2.SelectedItems.Count == 0)
  3916. return;
  3917. // 视场数n
  3918. int n = 0;
  3919. if (this.allShow)
  3920. n = this.listView2.Items.Count;
  3921. else
  3922. n = this.listView2.SelectedItems.Count;
  3923. List<string> selectItems = new List<string>();
  3924. if (this.allShow)
  3925. {
  3926. foreach (ListViewItem item in this.listView2.Items)
  3927. {
  3928. selectItems.Add(item.Tag.ToString());
  3929. }
  3930. }
  3931. else
  3932. {
  3933. foreach (ListViewItem item in this.listView2.SelectedItems)
  3934. {
  3935. selectItems.Add(item.Tag.ToString());
  3936. }
  3937. }
  3938. //
  3939. // 特征截线数和特征截点数(多视场平均值)
  3940. //
  3941. double totalNlv = 0;
  3942. double totalNlh = 0;
  3943. double totalPlv = 0;
  3944. double totalPlh = 0;
  3945. foreach (DataTable item in this.pictureDataTables)
  3946. {
  3947. if (selectItems.Contains(item.TableName))
  3948. {
  3949. totalNlv += (double)Convert.ToDecimal(item.Rows[0][2]);
  3950. totalNlh += (double)Convert.ToDecimal(item.Rows[0][3]);
  3951. totalPlv += (double)Convert.ToDecimal(item.Rows[0][4]);
  3952. totalPlh += (double)Convert.ToDecimal(item.Rows[0][5]);
  3953. }
  3954. }
  3955. // 垂直截线数
  3956. double nlvAve = totalNlv / n;
  3957. // 水平截线数
  3958. double nlhAve = totalNlh / n;
  3959. // 垂直截点数
  3960. double plvAve = totalPlv / n;
  3961. // 水平截点数
  3962. double plhAve = totalPlh / n;
  3963. //计算标准误差s(4个)
  3964. double sNlv;
  3965. double sNlh;
  3966. double sPlv;
  3967. double sPlh;
  3968. double sumNlv = 0;
  3969. double sumNlh = 0;
  3970. double sumPlv = 0;
  3971. double sumPlh = 0;
  3972. foreach (DataTable item in this.pictureDataTables)
  3973. {
  3974. if (selectItems.Contains(item.TableName))
  3975. {
  3976. sumNlv += ((double)Convert.ToDecimal(item.Rows[0][2]) - nlvAve) * ((double)Convert.ToDecimal(item.Rows[0][2]) - nlvAve);
  3977. sumNlh += ((double)Convert.ToDecimal(item.Rows[0][3]) - nlhAve) * ((double)Convert.ToDecimal(item.Rows[0][3]) - nlhAve);
  3978. sumPlv += ((double)Convert.ToDecimal(item.Rows[0][4]) - plvAve) * ((double)Convert.ToDecimal(item.Rows[0][4]) - plvAve);
  3979. sumPlh += ((double)Convert.ToDecimal(item.Rows[0][5]) - plhAve) * ((double)Convert.ToDecimal(item.Rows[0][5]) - plhAve);
  3980. }
  3981. }
  3982. sNlv = Math.Sqrt(sumNlv / (n - 1));
  3983. sNlh = Math.Sqrt(sumNlh / (n - 1));
  3984. sPlv = Math.Sqrt(sumPlv / (n - 1));
  3985. sPlh = Math.Sqrt(sumPlh / (n - 1));
  3986. //
  3987. // 计算95%置信区间(95%CI)
  3988. //
  3989. // 计算与市场相关系数t
  3990. double t = 0;
  3991. if (n - 1 == 2) t = 4.303;
  3992. if (n - 1 == 3) t = 3.182;
  3993. if (n - 1 == 4) t = 2.776;
  3994. if (n - 1 == 5) t = 2.571;
  3995. if (n - 1 == 6) t = 2.447;
  3996. if (n - 1 == 7) t = 2.365;
  3997. if (n - 1 == 8) t = 2.306;
  3998. if (n - 1 == 9) t = 2.262;
  3999. if (n - 1 == 10) t = 2.228;
  4000. double ciNlv = 0;
  4001. double ciNlh = 0;
  4002. double ciPlv = 0;
  4003. double ciPlh = 0;
  4004. // 垂直截线数95%CI
  4005. ciNlv = t * sNlv / Math.Sqrt(n);
  4006. // 水平截线数95%CI
  4007. ciNlh = t * sNlh / Math.Sqrt(n);
  4008. // 垂直截点数95%CI
  4009. ciPlv = t * sPlv / Math.Sqrt(n);
  4010. // 水平截点数95%CI
  4011. ciPlh = t * sPlh / Math.Sqrt(n);
  4012. //
  4013. // 计算相对精度百分数(%RA)
  4014. //
  4015. double raNlv = 0;
  4016. double raNlh = 0;
  4017. double raPlv = 0;
  4018. double raPlh = 0;
  4019. // 垂直截线数%RA
  4020. raNlv = ciNlv / nlvAve * 100;
  4021. // 水平截线数%RA
  4022. raNlh = ciNlh / nlhAve * 100;
  4023. // 垂直截点数%RA
  4024. raPlv = ciPlv / plvAve * 100;
  4025. // 水平截点数%RA
  4026. raPlh = ciPlh / plhAve * 100;
  4027. //
  4028. // 计算带状平均间距SB⊥
  4029. //
  4030. double sbV = 1 / nlvAve;
  4031. //
  4032. // 计算平均自由程λ⊥
  4033. //
  4034. // 带状组织体积分数
  4035. double v = 0;
  4036. double lmtV = (1 - v) / nlvAve;
  4037. //
  4038. // 计算各向异性指数AI
  4039. //
  4040. double aiNlv = nlvAve / nlhAve;
  4041. double aiPlv = plvAve / plhAve;
  4042. //
  4043. // 计算取向度Ω12
  4044. //
  4045. double omgN12 = (nlvAve - nlhAve) / (nlvAve + 0.571 * nlhAve);
  4046. double omgP12 = (plvAve - plhAve) / (plvAve + 0.571 * plhAve);
  4047. this.dataGridView4.Rows.Clear();
  4048. DataGridViewRow dataGridViewRow = new DataGridViewRow();
  4049. foreach (DataGridViewColumn Column in this.dataGridView4.Columns)
  4050. {
  4051. dataGridViewRow.Cells.Add(Column.CellTemplate.Clone() as DataGridViewCell);
  4052. }
  4053. int dec = Convert.ToInt32(this.numericUpDown1.Value);
  4054. dataGridViewRow.Cells[0].Value = "X";
  4055. if (double.IsNaN(nlvAve))
  4056. dataGridViewRow.Cells[1].Value = "-";
  4057. else
  4058. dataGridViewRow.Cells[1].Value = Math.Round(nlvAve, dec);
  4059. if (double.IsNaN(nlhAve))
  4060. dataGridViewRow.Cells[2].Value = "-";
  4061. else
  4062. dataGridViewRow.Cells[2].Value = Math.Round(nlhAve, dec);
  4063. if (double.IsNaN(aiNlv))
  4064. dataGridViewRow.Cells[3].Value = "-";
  4065. else
  4066. dataGridViewRow.Cells[3].Value = Math.Round(aiNlv, dec);
  4067. if (double.IsNaN(omgN12))
  4068. dataGridViewRow.Cells[4].Value = "-";
  4069. else
  4070. dataGridViewRow.Cells[4].Value = Math.Round(omgN12, dec);
  4071. if (double.IsNaN(plvAve))
  4072. dataGridViewRow.Cells[5].Value = "-";
  4073. else
  4074. dataGridViewRow.Cells[5].Value = Math.Round(plvAve, dec);
  4075. if (double.IsNaN(plhAve))
  4076. dataGridViewRow.Cells[6].Value = "-";
  4077. else
  4078. dataGridViewRow.Cells[6].Value = Math.Round(plhAve, dec);
  4079. if (double.IsNaN(aiPlv))
  4080. dataGridViewRow.Cells[7].Value = "-";
  4081. else
  4082. dataGridViewRow.Cells[7].Value = Math.Round(aiPlv, dec);
  4083. if (double.IsNaN(omgP12))
  4084. dataGridViewRow.Cells[8].Value = "-";
  4085. else
  4086. dataGridViewRow.Cells[8].Value = Math.Round(omgP12, dec);
  4087. if (double.IsNaN(sbV))
  4088. dataGridViewRow.Cells[9].Value = "-";
  4089. else
  4090. dataGridViewRow.Cells[9].Value = Math.Round(sbV, dec);
  4091. if (double.IsNaN(lmtV))
  4092. dataGridViewRow.Cells[10].Value = "-";
  4093. else
  4094. dataGridViewRow.Cells[10].Value = Math.Round(lmtV, dec);
  4095. this.dataGridView4.Rows.Add(dataGridViewRow);
  4096. dataGridViewRow = new DataGridViewRow();
  4097. foreach (DataGridViewColumn Column in this.dataGridView4.Columns)
  4098. {
  4099. dataGridViewRow.Cells.Add(Column.CellTemplate.Clone() as DataGridViewCell);
  4100. }
  4101. dataGridViewRow.Cells[0].Value = "s";
  4102. if (double.IsNaN(sNlv))
  4103. dataGridViewRow.Cells[1].Value = "-";
  4104. else
  4105. dataGridViewRow.Cells[1].Value = Math.Round(sNlv, dec);
  4106. if (double.IsNaN(sNlh))
  4107. dataGridViewRow.Cells[2].Value = "-";
  4108. else
  4109. dataGridViewRow.Cells[2].Value = Math.Round(sNlh, dec);
  4110. dataGridViewRow.Cells[3].Value = "-";
  4111. dataGridViewRow.Cells[4].Value = "-";
  4112. if (double.IsNaN(sPlv))
  4113. dataGridViewRow.Cells[5].Value = "-";
  4114. else
  4115. dataGridViewRow.Cells[5].Value = Math.Round(sPlv, dec);
  4116. if (double.IsNaN(sPlh))
  4117. dataGridViewRow.Cells[6].Value = "-";
  4118. else
  4119. dataGridViewRow.Cells[6].Value = Math.Round(sPlh, dec);
  4120. dataGridViewRow.Cells[7].Value = "-";
  4121. dataGridViewRow.Cells[8].Value = "-";
  4122. dataGridViewRow.Cells[9].Value = "-";
  4123. dataGridViewRow.Cells[10].Value = "-";
  4124. this.dataGridView4.Rows.Add(dataGridViewRow);
  4125. dataGridViewRow = new DataGridViewRow();
  4126. foreach (DataGridViewColumn Column in this.dataGridView4.Columns)
  4127. {
  4128. dataGridViewRow.Cells.Add(Column.CellTemplate.Clone() as DataGridViewCell);
  4129. }
  4130. dataGridViewRow.Cells[0].Value = "95%CI";
  4131. if (double.IsNaN(ciNlv))
  4132. dataGridViewRow.Cells[1].Value = "-";
  4133. else
  4134. dataGridViewRow.Cells[1].Value = "±" + Math.Round(ciNlv, dec);
  4135. if (double.IsNaN(ciNlh))
  4136. dataGridViewRow.Cells[2].Value = "-";
  4137. else
  4138. dataGridViewRow.Cells[2].Value = "±" + Math.Round(ciNlh, dec);
  4139. dataGridViewRow.Cells[3].Value = "-";
  4140. dataGridViewRow.Cells[4].Value = "-";
  4141. if (double.IsNaN(ciPlv))
  4142. dataGridViewRow.Cells[5].Value = "-";
  4143. else
  4144. dataGridViewRow.Cells[5].Value = "±" + Math.Round(ciPlv, dec);
  4145. if (double.IsNaN(ciPlh))
  4146. dataGridViewRow.Cells[6].Value = "-";
  4147. else
  4148. dataGridViewRow.Cells[6].Value = "±" + Math.Round(ciPlh, dec);
  4149. dataGridViewRow.Cells[7].Value = "-";
  4150. dataGridViewRow.Cells[8].Value = "-";
  4151. dataGridViewRow.Cells[9].Value = "-";
  4152. dataGridViewRow.Cells[10].Value = "-";
  4153. this.dataGridView4.Rows.Add(dataGridViewRow);
  4154. dataGridViewRow = new DataGridViewRow();
  4155. foreach (DataGridViewColumn Column in this.dataGridView4.Columns)
  4156. {
  4157. dataGridViewRow.Cells.Add(Column.CellTemplate.Clone() as DataGridViewCell);
  4158. }
  4159. dataGridViewRow.Cells[0].Value = "%RA";
  4160. if (double.IsNaN(raNlv))
  4161. dataGridViewRow.Cells[1].Value = "-";
  4162. else
  4163. dataGridViewRow.Cells[1].Value = Math.Round(raNlv, dec);
  4164. if (double.IsNaN(raNlh))
  4165. dataGridViewRow.Cells[2].Value = "-";
  4166. else
  4167. dataGridViewRow.Cells[2].Value = Math.Round(raNlh, dec);
  4168. dataGridViewRow.Cells[3].Value = "-";
  4169. dataGridViewRow.Cells[4].Value = "-";
  4170. if (double.IsNaN(raPlv))
  4171. dataGridViewRow.Cells[5].Value = "-";
  4172. else
  4173. dataGridViewRow.Cells[5].Value = Math.Round(raPlv, dec);
  4174. if (double.IsNaN(raPlh))
  4175. dataGridViewRow.Cells[6].Value = "-";
  4176. else
  4177. dataGridViewRow.Cells[6].Value = Math.Round(raPlh, dec);
  4178. dataGridViewRow.Cells[7].Value = "-";
  4179. dataGridViewRow.Cells[8].Value = "-";
  4180. dataGridViewRow.Cells[9].Value = "-";
  4181. dataGridViewRow.Cells[10].Value = "-";
  4182. this.dataGridView4.Rows.Add(dataGridViewRow);
  4183. dataGridViewRow = new DataGridViewRow();
  4184. foreach (DataGridViewColumn Column in this.dataGridView4.Columns)
  4185. {
  4186. dataGridViewRow.Cells.Add(Column.CellTemplate.Clone() as DataGridViewCell);
  4187. }
  4188. dataGridViewRow.Cells[0].Value = "n";
  4189. dataGridViewRow.Cells[1].Value = n;
  4190. dataGridViewRow.Cells[2].Value = "-";
  4191. dataGridViewRow.Cells[3].Value = "-";
  4192. dataGridViewRow.Cells[4].Value = "-";
  4193. dataGridViewRow.Cells[5].Value = "-";
  4194. dataGridViewRow.Cells[6].Value = "-";
  4195. dataGridViewRow.Cells[7].Value = "-";
  4196. dataGridViewRow.Cells[8].Value = "-";
  4197. dataGridViewRow.Cells[9].Value = "-";
  4198. dataGridViewRow.Cells[10].Value = "-";
  4199. this.dataGridView4.Rows.Add(dataGridViewRow);
  4200. tableResult = new DataTable();
  4201. foreach (DataGridViewColumn Column in this.dataGridView4.Columns)
  4202. {
  4203. tableResult.Columns.Add(Column.HeaderText);
  4204. }
  4205. DataRow dataRow = tableResult.NewRow();
  4206. dataRow[0] = "X";
  4207. dataRow[1] = nlvAve;
  4208. dataRow[2] = nlhAve;
  4209. dataRow[3] = aiNlv;
  4210. dataRow[4] = omgN12;
  4211. dataRow[5] = plvAve;
  4212. dataRow[6] = plhAve;
  4213. dataRow[7] = aiPlv;
  4214. dataRow[8] = omgP12;
  4215. dataRow[9] = sbV;
  4216. dataRow[10] = lmtV;
  4217. tableResult.Rows.Add(dataRow);
  4218. dataRow = tableResult.NewRow();
  4219. dataRow[0] = "s";
  4220. if (double.IsNaN(sNlv))
  4221. dataRow[1] = "-";
  4222. else
  4223. dataRow[1] = sNlv;
  4224. if (double.IsNaN(sNlh))
  4225. dataRow[2] = "-";
  4226. else
  4227. dataRow[2] = sNlh;
  4228. dataRow[3] = "-";
  4229. dataRow[4] = "-";
  4230. if (double.IsNaN(sPlv))
  4231. dataRow[5] = "-";
  4232. else
  4233. dataRow[5] = sPlv;
  4234. if (double.IsNaN(sPlh))
  4235. dataRow[6] = "-";
  4236. else
  4237. dataRow[6] = sPlh;
  4238. dataRow[7] = "-";
  4239. dataRow[8] = "-";
  4240. dataRow[9] = "-";
  4241. dataRow[10] = "-";
  4242. tableResult.Rows.Add(dataRow);
  4243. dataRow = tableResult.NewRow();
  4244. dataRow[0] = "95%CI";
  4245. if (double.IsNaN(ciNlv))
  4246. dataRow[1] = "-";
  4247. else
  4248. dataRow[1] = ciNlv;
  4249. if (double.IsNaN(ciNlh))
  4250. dataRow[2] = "-";
  4251. else
  4252. dataRow[2] = ciNlh;
  4253. dataRow[3] = "-";
  4254. dataRow[4] = "-";
  4255. if (double.IsNaN(ciPlv))
  4256. dataRow[5] = "-";
  4257. else
  4258. dataRow[5] = ciPlv;
  4259. if (double.IsNaN(ciPlh))
  4260. dataRow[6] = "-";
  4261. else
  4262. dataRow[6] = ciPlh;
  4263. dataRow[7] = "-";
  4264. dataRow[8] = "-";
  4265. dataRow[9] = "-";
  4266. dataRow[10] = "-";
  4267. tableResult.Rows.Add(dataRow);
  4268. dataRow = tableResult.NewRow();
  4269. dataRow[0] = "%RA";
  4270. if (double.IsNaN(raNlv))
  4271. dataRow[1] = "-";
  4272. else
  4273. dataRow[1] = raNlv;
  4274. if (double.IsNaN(raNlh))
  4275. dataRow[2] = "-";
  4276. else
  4277. dataRow[2] = raNlh;
  4278. dataRow[3] = "-";
  4279. dataRow[4] = "-";
  4280. if (double.IsNaN(raPlv))
  4281. dataRow[5] = "-";
  4282. else
  4283. dataRow[5] = raPlv;
  4284. if (double.IsNaN(raPlh))
  4285. dataRow[6] = "-";
  4286. else
  4287. dataRow[6] = raPlh;
  4288. dataRow[7] = "-";
  4289. dataRow[8] = "-";
  4290. dataRow[9] = "-";
  4291. dataRow[10] = "-";
  4292. tableResult.Rows.Add(dataRow);
  4293. dataRow = tableResult.NewRow();
  4294. dataRow[0] = "n";
  4295. dataRow[1] = n;
  4296. dataRow[2] = "-";
  4297. dataRow[3] = "-";
  4298. dataRow[4] = "-";
  4299. dataRow[5] = "-";
  4300. dataRow[6] = "-";
  4301. dataRow[7] = "-";
  4302. dataRow[8] = "-";
  4303. dataRow[9] = "-";
  4304. dataRow[10] = "-";
  4305. tableResult.Rows.Add(dataRow);
  4306. }
  4307. /// <summary>
  4308. /// 导出结果
  4309. /// </summary>
  4310. /// <param name="sender"></param>
  4311. /// <param name="e"></param>
  4312. private void button14_Click(object sender, EventArgs e)
  4313. {
  4314. if (this.listView2.Items.Count > 0)
  4315. {
  4316. System.Data.DataSet ds = new DataSet();
  4317. DataTable table1 = new DataTable();
  4318. table1.TableName = PdnResources.GetString("Menu.breakdown.text");
  4319. foreach (DataGridViewColumn c in this.dataGridView2.Columns)
  4320. {
  4321. table1.Columns.Add(c.HeaderText);
  4322. }
  4323. for (int r = 0; r < this.dataGridView2.Rows.Count; r++)
  4324. {
  4325. DataRow dataRow = table1.NewRow();
  4326. if (r == 0)
  4327. {
  4328. for (int c = 0; c < this.dataGridView2.Rows[r].Cells.Count; c++)
  4329. {
  4330. dataRow[this.dataGridView2.Columns[c].HeaderText] = this.dataGridView2.Columns[c].HeaderText;
  4331. }
  4332. table1.Rows.Add(dataRow);
  4333. }
  4334. dataRow = table1.NewRow();
  4335. for (int c = 0; c < this.dataGridView2.Rows[r].Cells.Count; c++)
  4336. {
  4337. dataRow[this.dataGridView2.Columns[c].HeaderText] = this.dataGridView2.Rows[r].Cells[c].Value;
  4338. }
  4339. table1.Rows.Add(dataRow);
  4340. }
  4341. DataTable table2 = new DataTable();
  4342. table2.TableName = PdnResources.GetString("Menu.statisaatics.text");
  4343. foreach (DataGridViewColumn c in this.dataGridView4.Columns)
  4344. {
  4345. table2.Columns.Add(c.HeaderText);
  4346. }
  4347. for (int r = 0; r < this.dataGridView4.Rows.Count; r++)
  4348. {
  4349. DataRow dataRow = table2.NewRow();
  4350. if (r == 0)
  4351. {
  4352. for (int c = 0; c < this.dataGridView4.Rows[r].Cells.Count; c++)
  4353. {
  4354. dataRow[this.dataGridView4.Columns[c].HeaderText] = this.dataGridView4.Columns[c].HeaderText;
  4355. }
  4356. table2.Rows.Add(dataRow);
  4357. }
  4358. dataRow = table2.NewRow();
  4359. for (int c = 0; c < this.dataGridView4.Rows[r].Cells.Count; c++)
  4360. {
  4361. dataRow[this.dataGridView4.Columns[c].HeaderText] = this.dataGridView4.Rows[r].Cells[c].Value;
  4362. }
  4363. table2.Rows.Add(dataRow);
  4364. }
  4365. if (table1.Rows.Count > 0) ds.Tables.Add(table1);
  4366. if (table2.Rows.Count > 0) ds.Tables.Add(table2);
  4367. if (ds.Tables.Count > 0)
  4368. DataToExcle(ds);
  4369. }
  4370. else
  4371. {
  4372. MessageBox.Show(PdnResources.GetString("Menu.Noanalysisresults.text")+"!");
  4373. }
  4374. }
  4375. /// <summary>
  4376. /// 导出多 Sheet 报表
  4377. /// </summary>
  4378. /// <param name="ds">要导出的数据</param>
  4379. public void DataToExcle(System.Data.DataSet ds)
  4380. {
  4381. try
  4382. {
  4383. if (ds.Tables == null || ds.Tables.Count == 0)
  4384. {
  4385. MessageBox.Show(PdnResources.GetString("Menu.Nonedata.Text")+"!");
  4386. return;
  4387. }
  4388. SaveFileDialog saveFileDialog = new SaveFileDialog();
  4389. saveFileDialog.DefaultExt = "xlsx";
  4390. saveFileDialog.Title = PdnResources.GetString("Menu.ExportdatatoEXECLtable.Text");
  4391. saveFileDialog.FileName = PdnResources.GetString("Menu.DedicatedAnalysis.BlackMetal.BandedStructure.Text")+ PdnResources.GetString("Menu.Analysisresult.text") + DateTime.Now.ToString("yyyyMMddhhmmss");
  4392. saveFileDialog.Filter = "microsoft office execl files (*.xlsx)|*.xlsx";
  4393. saveFileDialog.RestoreDirectory = true;
  4394. if (saveFileDialog.ShowDialog() == DialogResult.OK)
  4395. {
  4396. List<System.Data.DataTable> list = new List<System.Data.DataTable>();
  4397. foreach (System.Data.DataTable itemTable in ds.Tables)
  4398. list.Add(itemTable);
  4399. this.appWorkspace.ExportDataToExcelWithProgress(list, saveFileDialog.FileName, true, true, true);
  4400. }
  4401. }
  4402. catch (Exception e)
  4403. {
  4404. throw e;
  4405. }
  4406. }
  4407. /// <summary>
  4408. /// 不可点击空白区域
  4409. /// </summary>
  4410. /// <param name="sender"></param>
  4411. /// <param name="e"></param>
  4412. private void listView1_MouseUp(object sender, MouseEventArgs e)
  4413. {
  4414. if (e.Button == MouseButtons.Left)
  4415. {
  4416. if (listView1.SelectedItems.Count > 0)
  4417. {
  4418. }
  4419. else if (listView1.SelectedItems.Count <= 0)//点击空白区
  4420. {
  4421. if (this.listView1.FocusedItem != null)
  4422. {
  4423. ListViewItem item = this.listView1.GetItemAt(e.X, e.Y);
  4424. if (item == null)
  4425. {
  4426. this.listView1.FocusedItem.Selected = true;
  4427. }
  4428. }
  4429. }
  4430. }
  4431. }
  4432. /// <summary>
  4433. /// 小数
  4434. /// </summary>
  4435. /// <param name="sender"></param>
  4436. /// <param name="e"></param>
  4437. private void numericUpDown1_ValueChanged(object sender, EventArgs e)
  4438. {
  4439. if (this.dataGridView1.Rows.Count > 0)
  4440. RefreshResultsData();
  4441. if (this.dataGridView2.Rows.Count > 0)
  4442. RefreshDataGridView4();
  4443. if (this.listView2.Items.Count > 0)
  4444. ResultCalculation();
  4445. }
  4446. /// <summary>
  4447. /// 设置
  4448. /// </summary>
  4449. /// <param name="sender"></param>
  4450. /// <param name="e"></param>
  4451. private void button1_Click(object sender, EventArgs e)
  4452. {
  4453. AnalyzeSettingDialog recombinationRateSetDialog = new AnalyzeSettingDialog(this, "Template.Manager.item3.MicrostructureBan_ASTME1268");
  4454. if (recombinationRateSetDialog.hasModule)
  4455. {
  4456. recombinationRateSetDialog.StartPosition = FormStartPosition.CenterScreen;
  4457. recombinationRateSetDialog.ShowDialog();
  4458. }
  4459. else
  4460. {
  4461. recombinationRateSetDialog = null;
  4462. }
  4463. }
  4464. /// <summary>
  4465. /// 生成报告
  4466. /// </summary>
  4467. /// <param name="sender"></param>
  4468. /// <param name="e"></param>
  4469. private void button13_Click(object sender, EventArgs e)
  4470. {
  4471. if (this.checkBox3.Checked)
  4472. {
  4473. AnalyzeSettingDialog recombinationRateSetDialog = new AnalyzeSettingDialog(this, "Template.Manager.item3.MicrostructureBan_ASTME1268");
  4474. if (recombinationRateSetDialog.hasModule)
  4475. {
  4476. recombinationRateSetDialog.StartPosition = FormStartPosition.CenterScreen;
  4477. recombinationRateSetDialog.ShowDialog();
  4478. }
  4479. else
  4480. {
  4481. recombinationRateSetDialog = null;
  4482. }
  4483. }
  4484. if (this.analyzeSettingModel != null && !string.IsNullOrEmpty(this.analyzeSettingModel.analyzeClassify))
  4485. {
  4486. //获取word书签与excel单元格的关系,以字典方式存储
  4487. List<mic_module_infos> mic_module_infos = mic_module_infos_BLL.FindAll().FindAll(a => a.analyze_classify == this.analyzeSettingModel.analyzeClassify);
  4488. Dictionary<string, string> tagInfos = new Dictionary<string, string>();
  4489. if (mic_module_infos != null && mic_module_infos.Count > 0)
  4490. {
  4491. foreach (mic_module_infos info in mic_module_infos)
  4492. {
  4493. tagInfos.Add(info.tag_name, info.cell_position);
  4494. }
  4495. }
  4496. List<List<string>> analysisContent = new List<List<string>>();
  4497. for (int i = 0; i < this.dataGridView2.Rows.Count; i++)
  4498. {
  4499. List<string> content1 = new List<string>();
  4500. if (i == 0)
  4501. {
  4502. content1.Add(this.dataGridView2.Columns[0].HeaderText);
  4503. content1.Add(this.dataGridView2.Columns[1].HeaderText);
  4504. content1.Add(this.dataGridView2.Columns[2].HeaderText);
  4505. content1.Add(this.dataGridView2.Columns[3].HeaderText);
  4506. content1.Add(this.dataGridView2.Columns[4].HeaderText);
  4507. content1.Add(this.dataGridView2.Columns[5].HeaderText);
  4508. analysisContent.Add(content1);
  4509. }
  4510. content1 = new List<string>();
  4511. content1.Add(this.dataGridView2.Rows[i].Cells[0].Value.ToString());
  4512. content1.Add(this.dataGridView2.Rows[i].Cells[1].Value.ToString());
  4513. content1.Add(this.dataGridView2.Rows[i].Cells[2].Value.ToString());
  4514. content1.Add(this.dataGridView2.Rows[i].Cells[3].Value.ToString());
  4515. content1.Add(this.dataGridView2.Rows[i].Cells[4].Value.ToString());
  4516. content1.Add(this.dataGridView2.Rows[i].Cells[5].Value.ToString());
  4517. analysisContent.Add(content1);
  4518. }
  4519. List<string> content2 = new List<string>();
  4520. analysisContent.Add(content2);
  4521. for (int i = 0; i < this.dataGridView4.Rows.Count; i++)
  4522. {
  4523. List<string> content1 = new List<string>();
  4524. if (i == 0)
  4525. {
  4526. content1.Add(this.dataGridView4.Columns[0].HeaderText);
  4527. content1.Add(this.dataGridView4.Columns[1].HeaderText);
  4528. content1.Add(this.dataGridView4.Columns[2].HeaderText);
  4529. content1.Add(this.dataGridView4.Columns[3].HeaderText);
  4530. content1.Add(this.dataGridView4.Columns[4].HeaderText);
  4531. content1.Add(this.dataGridView4.Columns[5].HeaderText);
  4532. content1.Add(this.dataGridView4.Columns[6].HeaderText);
  4533. content1.Add(this.dataGridView4.Columns[7].HeaderText);
  4534. content1.Add(this.dataGridView4.Columns[8].HeaderText);
  4535. content1.Add(this.dataGridView4.Columns[9].HeaderText);
  4536. content1.Add(this.dataGridView4.Columns[10].HeaderText);
  4537. analysisContent.Add(content1);
  4538. }
  4539. content1 = new List<string>();
  4540. content1.Add(this.dataGridView4.Rows[i].Cells[0].Value.ToString());
  4541. content1.Add(this.dataGridView4.Rows[i].Cells[1].Value.ToString());
  4542. content1.Add(this.dataGridView4.Rows[i].Cells[2].Value.ToString());
  4543. content1.Add(this.dataGridView4.Rows[i].Cells[3].Value.ToString());
  4544. content1.Add(this.dataGridView4.Rows[i].Cells[4].Value.ToString());
  4545. content1.Add(this.dataGridView4.Rows[i].Cells[5].Value.ToString());
  4546. content1.Add(this.dataGridView4.Rows[i].Cells[6].Value.ToString());
  4547. content1.Add(this.dataGridView4.Rows[i].Cells[7].Value.ToString());
  4548. content1.Add(this.dataGridView4.Rows[i].Cells[8].Value.ToString());
  4549. content1.Add(this.dataGridView4.Rows[i].Cells[9].Value.ToString());
  4550. content1.Add(this.dataGridView4.Rows[i].Cells[10].Value.ToString());
  4551. analysisContent.Add(content1);
  4552. }
  4553. bitList = new List<Bitmap>();
  4554. if (this.allShow)
  4555. {
  4556. foreach (KeyValuePair<string, List<Bitmap>> kv in this.bitDic)
  4557. {
  4558. bitList.Add(kv.Value[0]);
  4559. bitList.Add(kv.Value[1]);
  4560. }
  4561. }
  4562. else
  4563. {
  4564. if (this.listView2.SelectedItems != null && this.listView2.SelectedItems.Count > 0)
  4565. {
  4566. foreach (ListViewItem item in this.listView2.SelectedItems)
  4567. {
  4568. if (bitDic.ContainsKey(item.Tag.ToString()))
  4569. {
  4570. bitList.Add(bitDic[item.Tag.ToString()][0]);
  4571. bitList.Add(bitDic[item.Tag.ToString()][1]);
  4572. }
  4573. }
  4574. }
  4575. }
  4576. this.appWorkspace.CreateAnalysisReport(this.analyzeSettingModel, analysisContent, bitList, tagInfos);
  4577. }
  4578. else
  4579. MessageBox.Show(PdnResources.GetString("Menu.Pleasesettheanalysisreportfirst.text")+"!");
  4580. }
  4581. /// <summary>
  4582. /// 自动添加截点
  4583. /// </summary>
  4584. /// <param name="sender"></param>
  4585. /// <param name="e"></param>
  4586. private void checkBox4_CheckedChanged(object sender, EventArgs e)
  4587. {
  4588. if(checkBox4.Checked)
  4589. {
  4590. if (this.button6.Visible)
  4591. {
  4592. MessageBox.Show(PdnResources.GetString("Menu.Pleasestartmeasuring.text")+"!");
  4593. this.checkBox4.Checked = false;
  4594. return;
  4595. }
  4596. if (this.documentWorkspace.phaseModels.Count == 0 || (this.documentWorkspace.phaseModels.Count != 0 && this.documentWorkspace.phaseModels[0].mat == null))
  4597. {
  4598. MessageBox.Show(PdnResources.GetString("Menu.Pleaseperformbinarizationoperationfirst.text")+"!");
  4599. this.checkBox4.Checked = false;
  4600. return;
  4601. }
  4602. GetNumberOfGrains();
  4603. RefreshResultsData();
  4604. }
  4605. else
  4606. {
  4607. this.vPointCount = 0;
  4608. this.hPointCount = 0;
  4609. this.p1RectangleFs.Clear();
  4610. this.dataGridView1.Rows.Clear();
  4611. this.dataGridView3.Rows.Clear();
  4612. }
  4613. this.documentWorkspace.Refresh();
  4614. }
  4615. /// <summary>
  4616. /// 自动添加截点
  4617. /// </summary>
  4618. private void GetNumberOfGrains()
  4619. {
  4620. this.vPointCount = 0;
  4621. this.hPointCount = 0;
  4622. this.p1RectangleFs.Clear();
  4623. Mat OriginalPicture = new Mat();
  4624. if (this.documentWorkspace.PhaseModels[0].mat != null)
  4625. this.documentWorkspace.phaseModels[0].mat.CopyTo(OriginalPicture);
  4626. else
  4627. mat.CopyTo(OriginalPicture);
  4628. List<PointF> vPointFs = new List<PointF>();
  4629. List<PointF> hPointFs = new List<PointF>();
  4630. foreach (var rectangleF in this.vRectangleFs)
  4631. {
  4632. for (int i = (int)rectangleF.Top + 3; i <= rectangleF.Bottom - 3; i++)
  4633. {
  4634. vPointFs.Add(new PointF((float)rectangleF.X + (float)rectangleF.Width / 2, i));
  4635. }
  4636. }
  4637. foreach (var rectangleF in this.hRectangleFs)
  4638. {
  4639. for (int i = (int)rectangleF.Left + 3; i <= rectangleF.Right - 3; i++)
  4640. {
  4641. hPointFs.Add(new PointF(i, (float)rectangleF.Y + (float)rectangleF.Height / 2));
  4642. }
  4643. }
  4644. foreach (var pointF in vPointFs)
  4645. {
  4646. PointF center = pointF;
  4647. if (center.Y >= 0 && center.Y < this.documentWorkspace.CompositionSurface.Height
  4648. && center.X >= 0 && center.X < this.documentWorkspace.CompositionSurface.Width)
  4649. {
  4650. Vec4b vec4BCenter = OriginalPicture.At<Vec4b>();
  4651. if (center.X >= 0 && center.X < this.documentWorkspace.CompositionSurface.Width
  4652. && center.Y >= 0 && center.Y < this.documentWorkspace.CompositionSurface.Height)
  4653. {
  4654. vec4BCenter = OriginalPicture.At<Vec4b>((int)center.Y, (int)center.X);
  4655. if (this.documentWorkspace.PhaseModels[0].mat != null)
  4656. {
  4657. if (vec4BCenter.Item3 > 0)
  4658. {
  4659. continue;
  4660. }
  4661. }
  4662. else if (vec4BCenter.Item0 == 0 && vec4BCenter.Item1 == 0 && vec4BCenter.Item2 == 0 && vec4BCenter.Item3 == 255)
  4663. continue;
  4664. }
  4665. PointF leftTopP = new PointF(center.X - 1, center.Y - 1);
  4666. PointF top = new PointF(center.X, center.Y - 1);
  4667. PointF rightTop = new PointF(center.X + 1, center.Y - 1);
  4668. PointF left = new PointF(center.X - 1, center.Y);
  4669. PointF right = new PointF(center.X + 1, center.Y);
  4670. PointF leftBottom = new PointF(center.X - 1, center.Y + 1);
  4671. PointF bottom = new PointF(center.X, center.Y + 1);
  4672. PointF rightBottom = new PointF(center.X + 1, center.Y + 1);
  4673. Vec4b vec4BLeftTop = OriginalPicture.At<Vec4b>();
  4674. Vec4b vec4BTop = OriginalPicture.At<Vec4b>();
  4675. Vec4b vec4BRightTop = OriginalPicture.At<Vec4b>();
  4676. Vec4b vec4BLeft = OriginalPicture.At<Vec4b>();
  4677. Vec4b vec4BRight = OriginalPicture.At<Vec4b>();
  4678. Vec4b vec4BLeftBottom = OriginalPicture.At<Vec4b>();
  4679. Vec4b vec4BBottom = OriginalPicture.At<Vec4b>();
  4680. Vec4b vec4BRightBottom = OriginalPicture.At<Vec4b>();
  4681. if (leftTopP.X >= 0 && leftTopP.X < this.documentWorkspace.CompositionSurface.Width
  4682. && leftTopP.Y >= 0 && leftTopP.Y < this.documentWorkspace.CompositionSurface.Height)
  4683. vec4BLeftTop = OriginalPicture.At<Vec4b>((int)leftTopP.Y, (int)leftTopP.X);
  4684. if (top.X >= 0 && top.X < this.documentWorkspace.CompositionSurface.Width
  4685. && top.Y >= 0 && top.Y < this.documentWorkspace.CompositionSurface.Height)
  4686. vec4BTop = OriginalPicture.At<Vec4b>((int)top.Y, (int)top.X);
  4687. if (rightTop.X >= 0 && rightTop.X < this.documentWorkspace.CompositionSurface.Width
  4688. && rightTop.Y >= 0 && rightTop.Y < this.documentWorkspace.CompositionSurface.Height)
  4689. vec4BRightTop = OriginalPicture.At<Vec4b>((int)rightTop.Y, (int)rightTop.X);
  4690. if (left.X >= 0 && left.X < this.documentWorkspace.CompositionSurface.Width
  4691. && left.Y >= 0 && left.Y < this.documentWorkspace.CompositionSurface.Height)
  4692. vec4BLeft = OriginalPicture.At<Vec4b>((int)left.Y, (int)left.X);
  4693. if (right.X >= 0 && right.X < this.documentWorkspace.CompositionSurface.Width
  4694. && right.Y >= 0 && right.Y < this.documentWorkspace.CompositionSurface.Height)
  4695. vec4BRight = OriginalPicture.At<Vec4b>((int)right.Y, (int)right.X);
  4696. if (leftBottom.X >= 0 && leftBottom.X < this.documentWorkspace.CompositionSurface.Width
  4697. && leftBottom.Y >= 0 && leftBottom.Y < this.documentWorkspace.CompositionSurface.Height)
  4698. vec4BLeftBottom = OriginalPicture.At<Vec4b>((int)leftBottom.Y, (int)leftBottom.X);
  4699. if (bottom.X >= 0 && bottom.X < this.documentWorkspace.CompositionSurface.Width
  4700. && bottom.Y >= 0 && bottom.Y < this.documentWorkspace.CompositionSurface.Height)
  4701. vec4BBottom = OriginalPicture.At<Vec4b>((int)bottom.Y, (int)bottom.X);
  4702. if (rightBottom.X >= 0 && rightBottom.X < this.documentWorkspace.CompositionSurface.Width
  4703. && rightBottom.Y >= 0 && rightBottom.Y < this.documentWorkspace.CompositionSurface.Height)
  4704. vec4BRightBottom = OriginalPicture.At<Vec4b>((int)rightBottom.Y, (int)rightBottom.X);
  4705. if (center.X == 0 && center.Y > 0 && center.Y < this.documentWorkspace.CompositionSurface.Height)
  4706. {
  4707. vec4BLeftTop = vec4BCenter;
  4708. vec4BLeft = vec4BCenter;
  4709. vec4BLeftBottom = vec4BCenter;
  4710. }
  4711. else if (center.X == 0 && center.Y == 0)
  4712. {
  4713. vec4BLeftTop = vec4BCenter;
  4714. vec4BLeft = vec4BCenter;
  4715. vec4BLeftBottom = vec4BCenter;
  4716. vec4BTop = vec4BCenter;
  4717. vec4BRightTop = vec4BCenter;
  4718. }
  4719. else if (center.X == 0 && center.Y == this.documentWorkspace.CompositionSurface.Height)
  4720. {
  4721. vec4BLeftTop = vec4BCenter;
  4722. vec4BLeft = vec4BCenter;
  4723. vec4BLeftBottom = vec4BCenter;
  4724. vec4BBottom = vec4BCenter;
  4725. vec4BRightBottom = vec4BCenter;
  4726. }
  4727. if (center.X == this.documentWorkspace.CompositionSurface.Width && center.Y > 0 && center.Y < this.documentWorkspace.CompositionSurface.Height)
  4728. {
  4729. vec4BRightTop = vec4BCenter;
  4730. vec4BRight = vec4BCenter;
  4731. vec4BRightBottom = vec4BCenter;
  4732. }
  4733. else if (center.X == this.documentWorkspace.CompositionSurface.Width && center.Y == 0)
  4734. {
  4735. vec4BLeftTop = vec4BCenter;
  4736. vec4BTop = vec4BCenter;
  4737. vec4BRightTop = vec4BCenter;
  4738. vec4BRight = vec4BCenter;
  4739. vec4BRightBottom = vec4BCenter;
  4740. }
  4741. else if (center.X == this.documentWorkspace.CompositionSurface.Width && center.Y == this.documentWorkspace.CompositionSurface.Height)
  4742. {
  4743. vec4BLeftBottom = vec4BCenter;
  4744. vec4BBottom = vec4BCenter;
  4745. vec4BRightBottom = vec4BCenter;
  4746. vec4BRight = vec4BCenter;
  4747. vec4BRightTop = vec4BCenter;
  4748. }
  4749. else if (center.Y == 0 && center.X > 0 && center.X < this.documentWorkspace.CompositionSurface.Width)
  4750. {
  4751. vec4BLeftTop = vec4BCenter;
  4752. vec4BTop = vec4BCenter;
  4753. vec4BRightTop = vec4BCenter;
  4754. }
  4755. else if (center.Y == this.documentWorkspace.CompositionSurface.Height && center.X > 0 && center.X < this.documentWorkspace.CompositionSurface.Width)
  4756. {
  4757. vec4BLeftBottom = vec4BCenter;
  4758. vec4BBottom = vec4BCenter;
  4759. vec4BRightBottom = vec4BCenter;
  4760. }
  4761. if (vec4BCenter == vec4BLeftTop && vec4BCenter == vec4BTop && vec4BCenter == vec4BRightTop
  4762. && vec4BCenter == vec4BLeft && vec4BCenter == vec4BRight && vec4BCenter == vec4BLeftBottom
  4763. && vec4BCenter == vec4BBottom && vec4BCenter == vec4BRightBottom)
  4764. { }
  4765. else
  4766. {
  4767. float size = (float)(Convert.ToInt32(this.txt_LeftSize.Text) / unitLength);
  4768. p1RectangleFs.Add(new RectangleF(pointF.X - (float)(size / 2)
  4769. , pointF.Y - (float)(size / 2)
  4770. , size, size));
  4771. this.vPointCount++;
  4772. }
  4773. }
  4774. }
  4775. foreach (var pointF in hPointFs)
  4776. {
  4777. PointF center = pointF;
  4778. if (center.Y >= 0 && center.Y < this.documentWorkspace.CompositionSurface.Height
  4779. && center.X >= 0 && center.X < this.documentWorkspace.CompositionSurface.Width)
  4780. {
  4781. Vec4b vec4BCenter = OriginalPicture.At<Vec4b>();
  4782. if (center.X >= 0 && center.X < this.documentWorkspace.CompositionSurface.Width
  4783. && center.Y >= 0 && center.Y < this.documentWorkspace.CompositionSurface.Height)
  4784. {
  4785. vec4BCenter = OriginalPicture.At<Vec4b>((int)center.Y, (int)center.X);
  4786. if (this.documentWorkspace.PhaseModels[0].mat != null)
  4787. {
  4788. if (vec4BCenter.Item3 > 0)
  4789. {
  4790. continue;
  4791. }
  4792. }
  4793. else if (vec4BCenter.Item0 == 0 && vec4BCenter.Item1 == 0 && vec4BCenter.Item2 == 0 && vec4BCenter.Item3 == 255)
  4794. continue;
  4795. }
  4796. PointF leftTopP = new PointF(center.X - 1, center.Y - 1);
  4797. PointF top = new PointF(center.X, center.Y - 1);
  4798. PointF rightTop = new PointF(center.X + 1, center.Y - 1);
  4799. PointF left = new PointF(center.X - 1, center.Y);
  4800. PointF right = new PointF(center.X + 1, center.Y);
  4801. PointF leftBottom = new PointF(center.X - 1, center.Y + 1);
  4802. PointF bottom = new PointF(center.X, center.Y + 1);
  4803. PointF rightBottom = new PointF(center.X + 1, center.Y + 1);
  4804. Vec4b vec4BLeftTop = OriginalPicture.At<Vec4b>();
  4805. Vec4b vec4BTop = OriginalPicture.At<Vec4b>();
  4806. Vec4b vec4BRightTop = OriginalPicture.At<Vec4b>();
  4807. Vec4b vec4BLeft = OriginalPicture.At<Vec4b>();
  4808. Vec4b vec4BRight = OriginalPicture.At<Vec4b>();
  4809. Vec4b vec4BLeftBottom = OriginalPicture.At<Vec4b>();
  4810. Vec4b vec4BBottom = OriginalPicture.At<Vec4b>();
  4811. Vec4b vec4BRightBottom = OriginalPicture.At<Vec4b>();
  4812. if (leftTopP.X >= 0 && leftTopP.X < this.documentWorkspace.CompositionSurface.Width
  4813. && leftTopP.Y >= 0 && leftTopP.Y < this.documentWorkspace.CompositionSurface.Height)
  4814. vec4BLeftTop = OriginalPicture.At<Vec4b>((int)leftTopP.Y, (int)leftTopP.X);
  4815. if (top.X >= 0 && top.X < this.documentWorkspace.CompositionSurface.Width
  4816. && top.Y >= 0 && top.Y < this.documentWorkspace.CompositionSurface.Height)
  4817. vec4BTop = OriginalPicture.At<Vec4b>((int)top.Y, (int)top.X);
  4818. if (rightTop.X >= 0 && rightTop.X < this.documentWorkspace.CompositionSurface.Width
  4819. && rightTop.Y >= 0 && rightTop.Y < this.documentWorkspace.CompositionSurface.Height)
  4820. vec4BRightTop = OriginalPicture.At<Vec4b>((int)rightTop.Y, (int)rightTop.X);
  4821. if (left.X >= 0 && left.X < this.documentWorkspace.CompositionSurface.Width
  4822. && left.Y >= 0 && left.Y < this.documentWorkspace.CompositionSurface.Height)
  4823. vec4BLeft = OriginalPicture.At<Vec4b>((int)left.Y, (int)left.X);
  4824. if (right.X >= 0 && right.X < this.documentWorkspace.CompositionSurface.Width
  4825. && right.Y >= 0 && right.Y < this.documentWorkspace.CompositionSurface.Height)
  4826. vec4BRight = OriginalPicture.At<Vec4b>((int)right.Y, (int)right.X);
  4827. if (leftBottom.X >= 0 && leftBottom.X < this.documentWorkspace.CompositionSurface.Width
  4828. && leftBottom.Y >= 0 && leftBottom.Y < this.documentWorkspace.CompositionSurface.Height)
  4829. vec4BLeftBottom = OriginalPicture.At<Vec4b>((int)leftBottom.Y, (int)leftBottom.X);
  4830. if (bottom.X >= 0 && bottom.X < this.documentWorkspace.CompositionSurface.Width
  4831. && bottom.Y >= 0 && bottom.Y < this.documentWorkspace.CompositionSurface.Height)
  4832. vec4BBottom = OriginalPicture.At<Vec4b>((int)bottom.Y, (int)bottom.X);
  4833. if (rightBottom.X >= 0 && rightBottom.X < this.documentWorkspace.CompositionSurface.Width
  4834. && rightBottom.Y >= 0 && rightBottom.Y < this.documentWorkspace.CompositionSurface.Height)
  4835. vec4BRightBottom = OriginalPicture.At<Vec4b>((int)rightBottom.Y, (int)rightBottom.X);
  4836. if (center.X == 0 && center.Y > 0 && center.Y < this.documentWorkspace.CompositionSurface.Height)
  4837. {
  4838. vec4BLeftTop = vec4BCenter;
  4839. vec4BLeft = vec4BCenter;
  4840. vec4BLeftBottom = vec4BCenter;
  4841. }
  4842. else if (center.X == 0 && center.Y == 0)
  4843. {
  4844. vec4BLeftTop = vec4BCenter;
  4845. vec4BLeft = vec4BCenter;
  4846. vec4BLeftBottom = vec4BCenter;
  4847. vec4BTop = vec4BCenter;
  4848. vec4BRightTop = vec4BCenter;
  4849. }
  4850. else if (center.X == 0 && center.Y == this.documentWorkspace.CompositionSurface.Height)
  4851. {
  4852. vec4BLeftTop = vec4BCenter;
  4853. vec4BLeft = vec4BCenter;
  4854. vec4BLeftBottom = vec4BCenter;
  4855. vec4BBottom = vec4BCenter;
  4856. vec4BRightBottom = vec4BCenter;
  4857. }
  4858. if (center.X == this.documentWorkspace.CompositionSurface.Width && center.Y > 0 && center.Y < this.documentWorkspace.CompositionSurface.Height)
  4859. {
  4860. vec4BRightTop = vec4BCenter;
  4861. vec4BRight = vec4BCenter;
  4862. vec4BRightBottom = vec4BCenter;
  4863. }
  4864. else if (center.X == this.documentWorkspace.CompositionSurface.Width && center.Y == 0)
  4865. {
  4866. vec4BLeftTop = vec4BCenter;
  4867. vec4BTop = vec4BCenter;
  4868. vec4BRightTop = vec4BCenter;
  4869. vec4BRight = vec4BCenter;
  4870. vec4BRightBottom = vec4BCenter;
  4871. }
  4872. else if (center.X == this.documentWorkspace.CompositionSurface.Width && center.Y == this.documentWorkspace.CompositionSurface.Height)
  4873. {
  4874. vec4BLeftBottom = vec4BCenter;
  4875. vec4BBottom = vec4BCenter;
  4876. vec4BRightBottom = vec4BCenter;
  4877. vec4BRight = vec4BCenter;
  4878. vec4BRightTop = vec4BCenter;
  4879. }
  4880. else if (center.Y == 0 && center.X > 0 && center.X < this.documentWorkspace.CompositionSurface.Width)
  4881. {
  4882. vec4BLeftTop = vec4BCenter;
  4883. vec4BTop = vec4BCenter;
  4884. vec4BRightTop = vec4BCenter;
  4885. }
  4886. else if (center.Y == this.documentWorkspace.CompositionSurface.Height && center.X > 0 && center.X < this.documentWorkspace.CompositionSurface.Width)
  4887. {
  4888. vec4BLeftBottom = vec4BCenter;
  4889. vec4BBottom = vec4BCenter;
  4890. vec4BRightBottom = vec4BCenter;
  4891. }
  4892. if (vec4BCenter == vec4BLeftTop && vec4BCenter == vec4BTop && vec4BCenter == vec4BRightTop
  4893. && vec4BCenter == vec4BLeft && vec4BCenter == vec4BRight && vec4BCenter == vec4BLeftBottom
  4894. && vec4BCenter == vec4BBottom && vec4BCenter == vec4BRightBottom)
  4895. { }
  4896. else
  4897. {
  4898. float size = (float)(Convert.ToInt32(this.txt_LeftSize.Text) / unitLength);
  4899. p1RectangleFs.Add(new RectangleF(pointF.X - (float)(size / 2)
  4900. , pointF.Y - (float)(size / 2)
  4901. , size, size));
  4902. this.hPointCount++;
  4903. }
  4904. }
  4905. }
  4906. }
  4907. /// <summary>
  4908. /// 刷新结果数据
  4909. /// </summary>
  4910. private void RefreshResultsData()
  4911. {
  4912. double unitLength = 0;
  4913. this.appWorkspace.getMeasureInfo().TryGetValue(MeasurementUnit.Millimeter, out unitLength);
  4914. this.dataGridView1.Rows.Clear();
  4915. this.dataGridView3.Rows.Clear();
  4916. DataGridViewRow dtr = new DataGridViewRow();
  4917. DataGridViewRow dtr1 = new DataGridViewRow();
  4918. foreach (DataGridViewColumn Column in this.dataGridView1.Columns)
  4919. {
  4920. dtr.Cells.Add(Column.CellTemplate.Clone() as DataGridViewCell);
  4921. dtr1.Cells.Add(Column.CellTemplate.Clone() as DataGridViewCell);
  4922. }
  4923. decimal lv = 0;
  4924. decimal lh = 0;
  4925. if (this.vRectangleFs.Count > 0)
  4926. lv = ((decimal)this.vRectangleFs[0].Height - 6) * this.vNumber;
  4927. if (this.hRectangleFs.Count > 0)
  4928. lh = ((decimal)this.hRectangleFs[0].Width - 6) * this.hNumber;
  4929. if (lv != 0 && lh != 0)
  4930. {
  4931. dtr.Cells[0].Value = PdnResources.GetString("Menu.view.text") + "1";
  4932. dtr.Cells[1].Value = Math.Round((decimal)this.vPointCount / 2 / ((decimal)lv * (decimal)unitLength), Convert.ToInt32(this.numericUpDown1.Value));
  4933. dtr.Cells[2].Value = Math.Round((decimal)this.hPointCount / 2 / ((decimal)lh * (decimal)unitLength), Convert.ToInt32(this.numericUpDown1.Value));
  4934. dtr.Cells[3].Value = Math.Round((decimal)this.vPointCount / ((decimal)lv * (decimal)unitLength), Convert.ToInt32(this.numericUpDown1.Value));
  4935. dtr.Cells[4].Value = Math.Round((decimal)this.hPointCount / ((decimal)lh * (decimal)unitLength), Convert.ToInt32(this.numericUpDown1.Value));
  4936. this.dataGridView1.Rows.Add(dtr);
  4937. dtr1.Cells[0].Value = PdnResources.GetString("Menu.view.text") + "1";
  4938. dtr1.Cells[1].Value = (decimal)this.vPointCount / 2 / ((decimal)lv * (decimal)unitLength);
  4939. dtr1.Cells[2].Value = (decimal)this.hPointCount / 2 / ((decimal)lh * (decimal)unitLength);
  4940. dtr1.Cells[3].Value = (decimal)this.vPointCount / ((decimal)lv * (decimal)unitLength);
  4941. dtr1.Cells[4].Value = (decimal)this.hPointCount / ((decimal)lh * (decimal)unitLength);
  4942. }
  4943. this.dataGridView3.Rows.Add(dtr1);
  4944. }
  4945. private void checkBox5_CheckedChanged(object sender, EventArgs e)
  4946. {
  4947. this.documentWorkspace.Refresh();
  4948. }
  4949. /// <summary>
  4950. /// 导出项目
  4951. /// </summary>
  4952. /// <param name="sender"></param>
  4953. /// <param name="e"></param>
  4954. private void button8_Click(object sender, EventArgs e)
  4955. {
  4956. try
  4957. {
  4958. if (this.analyzeSettingModel == null)
  4959. {
  4960. MessageBox.Show(PdnResources.GetString("Menu.Settheexporteitemfirst.Text"));
  4961. return;
  4962. }
  4963. //获取项目工程内的文件夹路径
  4964. ProjectEngineering.NodeItem item = this.appWorkspace.GetInsertProjectPath(2, "Menu.DedicatedAnalysis.BlackMetal.BandedStructure.Text", this.analyzeSettingModel.savePath);
  4965. if (item != null)
  4966. {
  4967. //向文件夹内保存图片和报告
  4968. if (!string.IsNullOrEmpty(this.analyzeSettingModel.analyzeClassify))
  4969. {
  4970. //获取word书签与excel单元格的关系,以字典方式存储
  4971. List<mic_module_infos> mic_module_infos = mic_module_infos_BLL.FindAll().FindAll(a => a.analyze_classify == this.analyzeSettingModel.analyzeClassify);
  4972. Dictionary<string, string> tagInfos = new Dictionary<string, string>();
  4973. if (mic_module_infos != null && mic_module_infos.Count > 0)
  4974. {
  4975. foreach (mic_module_infos info in mic_module_infos)
  4976. {
  4977. tagInfos.Add(info.tag_name, info.cell_position);
  4978. }
  4979. }
  4980. //分析结果
  4981. List<List<string>> analysisContent = new List<List<string>>();
  4982. for (int i = 0; i < this.dataGridView2.Rows.Count; i++)
  4983. {
  4984. List<string> content1 = new List<string>();
  4985. if (i == 0)
  4986. {
  4987. content1.Add(this.dataGridView2.Columns[0].HeaderText);
  4988. content1.Add(this.dataGridView2.Columns[1].HeaderText);
  4989. content1.Add(this.dataGridView2.Columns[2].HeaderText);
  4990. content1.Add(this.dataGridView2.Columns[3].HeaderText);
  4991. content1.Add(this.dataGridView2.Columns[4].HeaderText);
  4992. content1.Add(this.dataGridView2.Columns[5].HeaderText);
  4993. analysisContent.Add(content1);
  4994. }
  4995. content1 = new List<string>();
  4996. content1.Add(this.dataGridView2.Rows[i].Cells[0].Value.ToString());
  4997. content1.Add(this.dataGridView2.Rows[i].Cells[1].Value.ToString());
  4998. content1.Add(this.dataGridView2.Rows[i].Cells[2].Value.ToString());
  4999. content1.Add(this.dataGridView2.Rows[i].Cells[3].Value.ToString());
  5000. content1.Add(this.dataGridView2.Rows[i].Cells[4].Value.ToString());
  5001. content1.Add(this.dataGridView2.Rows[i].Cells[5].Value.ToString());
  5002. analysisContent.Add(content1);
  5003. }
  5004. List<string> content2 = new List<string>();
  5005. analysisContent.Add(content2);
  5006. for (int i = 0; i < this.dataGridView4.Rows.Count; i++)
  5007. {
  5008. List<string> content1 = new List<string>();
  5009. if (i == 0)
  5010. {
  5011. content1.Add(this.dataGridView4.Columns[0].HeaderText);
  5012. content1.Add(this.dataGridView4.Columns[1].HeaderText);
  5013. content1.Add(this.dataGridView4.Columns[2].HeaderText);
  5014. content1.Add(this.dataGridView4.Columns[3].HeaderText);
  5015. content1.Add(this.dataGridView4.Columns[4].HeaderText);
  5016. content1.Add(this.dataGridView4.Columns[5].HeaderText);
  5017. content1.Add(this.dataGridView4.Columns[6].HeaderText);
  5018. content1.Add(this.dataGridView4.Columns[7].HeaderText);
  5019. content1.Add(this.dataGridView4.Columns[8].HeaderText);
  5020. content1.Add(this.dataGridView4.Columns[9].HeaderText);
  5021. content1.Add(this.dataGridView4.Columns[10].HeaderText);
  5022. analysisContent.Add(content1);
  5023. }
  5024. content1 = new List<string>();
  5025. content1.Add(this.dataGridView4.Rows[i].Cells[0].Value.ToString());
  5026. content1.Add(this.dataGridView4.Rows[i].Cells[1].Value.ToString());
  5027. content1.Add(this.dataGridView4.Rows[i].Cells[2].Value.ToString());
  5028. content1.Add(this.dataGridView4.Rows[i].Cells[3].Value.ToString());
  5029. content1.Add(this.dataGridView4.Rows[i].Cells[4].Value.ToString());
  5030. content1.Add(this.dataGridView4.Rows[i].Cells[5].Value.ToString());
  5031. content1.Add(this.dataGridView4.Rows[i].Cells[6].Value.ToString());
  5032. content1.Add(this.dataGridView4.Rows[i].Cells[7].Value.ToString());
  5033. content1.Add(this.dataGridView4.Rows[i].Cells[8].Value.ToString());
  5034. content1.Add(this.dataGridView4.Rows[i].Cells[9].Value.ToString());
  5035. content1.Add(this.dataGridView4.Rows[i].Cells[10].Value.ToString());
  5036. analysisContent.Add(content1);
  5037. }
  5038. bitList = new List<Bitmap>();
  5039. if (this.allShow)
  5040. {
  5041. foreach (KeyValuePair<string, List<Bitmap>> kv in this.bitDic)
  5042. {
  5043. bitList.Add(kv.Value[0]);
  5044. bitList.Add(kv.Value[1]);
  5045. }
  5046. }
  5047. else
  5048. {
  5049. if (this.listView2.SelectedItems != null && this.listView2.SelectedItems.Count > 0)
  5050. {
  5051. foreach (ListViewItem itemL2 in this.listView2.SelectedItems)
  5052. {
  5053. if (bitDic.ContainsKey(itemL2.Tag.ToString()))
  5054. {
  5055. bitList.Add(bitDic[itemL2.Tag.ToString()][0]);
  5056. bitList.Add(bitDic[itemL2.Tag.ToString()][1]);
  5057. }
  5058. }
  5059. }
  5060. }
  5061. //中间数据
  5062. if (!this.allShow)
  5063. {
  5064. if (this.listView2.SelectedItems != null && this.listView2.SelectedItems.Count > 0)
  5065. {
  5066. List<ExportProjectModel> exportModel = new List<ExportProjectModel>();
  5067. foreach (ListViewItem rowItem in this.listView2.SelectedItems)
  5068. {
  5069. foreach (ExportProjectModel model in this.tempDataModel)
  5070. {
  5071. if (model.tagName.Equals(rowItem.Tag))
  5072. {
  5073. ExportProjectModel tempModel = new ExportProjectModel();
  5074. tempModel.tagName = model.tagName;
  5075. tempModel.picName = model.picName;
  5076. tempModel.dataList = model.dataList;
  5077. exportModel.Add(tempModel);
  5078. break;
  5079. }
  5080. }
  5081. }
  5082. this.appWorkspace.CreateAnalysisReport(this.analyzeSettingModel, analysisContent, exportModel, bitList, tagInfos, item.path, item.code);
  5083. }
  5084. }
  5085. else
  5086. this.appWorkspace.CreateAnalysisReport(this.analyzeSettingModel, analysisContent, tempDataModel, bitList, tagInfos, item.path, item.code);
  5087. }
  5088. else
  5089. {
  5090. MessageBox.Show(PdnResources.GetString("Menu.Pleasesettheanalysisreportfirst.text")+"!");
  5091. return;
  5092. }
  5093. //保存项目信息到数据库
  5094. this.appWorkspace.InsertIntoDB(this.analyzeSettingModel, item);
  5095. }
  5096. }
  5097. catch (Exception)
  5098. {
  5099. }
  5100. }
  5101. #region 参数保存及提取
  5102. /// <summary>
  5103. /// 保存参数的key,value和type
  5104. /// </summary>
  5105. /// <param name="param_key"></param>
  5106. /// <param name="param_value"></param>
  5107. /// <param name="param_type"></param>
  5108. private void saveParamValue(string param_key, string param_value, int param_type)
  5109. {
  5110. bool foundItem = false;
  5111. foreach (var item in this.analysisModel.ListParam)
  5112. {
  5113. if (item.param_key.Equals(param_key) && item.menuId == this.menuId)
  5114. {
  5115. item.param_value = param_value;
  5116. item.setValue();
  5117. foundItem = true;
  5118. break;
  5119. }
  5120. }
  5121. if (!foundItem)
  5122. {
  5123. GrainSizeAnalysisModel analysisItem = new GrainSizeAnalysisModel();
  5124. analysisItem.menuId = this.menuId;
  5125. analysisItem.param_key = param_key;
  5126. analysisItem.param_type = param_type;
  5127. analysisItem.param_value = param_value;
  5128. analysisItem.setValue();
  5129. this.analysisModel.ListParam.Add(analysisItem);
  5130. }
  5131. }
  5132. /// <summary>
  5133. /// 保存界面中的参数到model
  5134. /// </summary>
  5135. private void saveDialogParamValues()
  5136. {
  5137. saveParamValue(ParamKey_GridUse, comboBox1.Text, (int)Base.Dtryt.ItemString);//使用网格
  5138. saveParamValue(ParamKey_GridMove, checkBox5.Checked ? "0" : "1", (int)Base.Dtryt.Boolean);//网格移动
  5139. saveParamValue(ParamKey_Report, checkBox3.Checked ? "0" : "1", (int)Base.Dtryt.Boolean);//报告设置
  5140. saveParamValue(ParamKey_Circular, rb_LeftCircle.Checked ? "0" : "1", (int)Base.Dtryt.Boolean);//圆形
  5141. saveParamValue(ParamKey_Square, rb_LeftSquare.Checked ? "0" : "1", (int)Base.Dtryt.Boolean);//方形
  5142. saveParamValue(ParamKey_Solid, rb_leftFill.Checked ? "0" : "1", (int)Base.Dtryt.Boolean);//实心
  5143. saveParamValue(ParamKey_Hollow, rb_leftNoFill.Checked ? "0" : "1", (int)Base.Dtryt.Boolean);//空心
  5144. saveParamValue(ParamKey_Size, txt_LeftSize.Text, (int)Base.Dtryt.ItemString);//尺寸
  5145. saveParamValue(ParamKey_Width, txt_LeftLineWeight.Text, (int)Base.Dtryt.ItemString);//线宽
  5146. saveParamValue(ParamKey_Colour, panel1.BackColor.ToArgb().ToString(), (int)Base.Dtryt.Color);//颜色
  5147. saveParamValue(ParamKey_DecimalPlace, numericUpDown1 != null ? numericUpDown1.Value.ToString() : "", (int)Base.Dtryt.Decimal);//保留小数位数
  5148. }
  5149. /// <summary>
  5150. /// 获取保存的参数
  5151. /// </summary>
  5152. private void GetListParamModel()
  5153. {
  5154. if (this.analysisModel != null)
  5155. {
  5156. for (int i = 0; i < this.analysisModel.ListParam.Count; i++)
  5157. {
  5158. switch (this.analysisModel.ListParam[i].param_key)
  5159. {
  5160. case ParamKey_GridUse:
  5161. comboBox1.Text = (string)this.analysisModel.ListParam[i].value;
  5162. break;
  5163. case ParamKey_GridMove:
  5164. checkBox5.Checked = (Boolean)this.analysisModel.ListParam[i].value;
  5165. break;
  5166. case ParamKey_Report:
  5167. checkBox3.Checked = (Boolean)this.analysisModel.ListParam[i].value;
  5168. break;
  5169. case ParamKey_Circular:
  5170. rb_LeftCircle.Checked = (Boolean)this.analysisModel.ListParam[i].value;
  5171. break;
  5172. case ParamKey_Square:
  5173. rb_LeftSquare.Checked = (Boolean)this.analysisModel.ListParam[i].value;
  5174. break;
  5175. case ParamKey_Solid:
  5176. rb_leftFill.Checked = (Boolean)this.analysisModel.ListParam[i].value;
  5177. break;
  5178. case ParamKey_Hollow:
  5179. rb_leftNoFill.Checked = (Boolean)this.analysisModel.ListParam[i].value;
  5180. break;
  5181. case ParamKey_Size:
  5182. txt_LeftSize.Text = (string)this.analysisModel.ListParam[i].value;
  5183. break;
  5184. case ParamKey_Width:
  5185. txt_LeftLineWeight.Text = (string)this.analysisModel.ListParam[i].value;
  5186. break;
  5187. case ParamKey_Colour:
  5188. panel1.BackColor = Color.FromArgb((int)this.analysisModel.ListParam[i].value);
  5189. break;
  5190. case ParamKey_DecimalPlace:
  5191. numericUpDown1.Value = decimal.Parse(this.analysisModel.ListParam[i].param_value);
  5192. break;
  5193. }
  5194. }
  5195. }
  5196. }
  5197. #endregion
  5198. #region [脚本相关]
  5199. private void getValue(string key, object value)
  5200. {
  5201. switch (key)
  5202. {
  5203. case "parameter1":
  5204. comboBox1.SelectedIndex = (int)value;
  5205. break;
  5206. case "OpenWhileExportReport":
  5207. checkBox3.Checked = Convert.ToBoolean(value);
  5208. break;
  5209. case "CalculatorDecimalDigits":
  5210. numericUpDown1.Value = Convert.ToDecimal(value);
  5211. break;
  5212. case "ExportResults":
  5213. value = false;
  5214. break;
  5215. case "ExportReports":
  5216. value = false;
  5217. break;
  5218. case "ExportProjects":
  5219. value = false;
  5220. break;
  5221. }
  5222. }
  5223. #endregion
  5224. #region [脚本录制]
  5225. private void getScriptRecording()
  5226. {
  5227. string className = InvariantData.path_Action + ".Action" + menuId;
  5228. ParamObject param = (ParamObject)System.Reflection.Assembly.Load(InvariantData.assembly_Data).CreateInstance(className);
  5229. List<Args> args = param.Lists;
  5230. foreach (var item in args)
  5231. {
  5232. item.value = setScriptRecording(item.key);
  5233. }
  5234. //找出二值相关参数 进行赋值
  5235. List<Args> isNullList = args.Where(m => m.value == null).ToList();
  5236. foreach (var item in isNullList)
  5237. {
  5238. item.value = binaryClass.setScriptRecording(item.key);
  5239. }
  5240. appWorkspace.SetScriptStartRecording(this.menuId, menuName, args);
  5241. }
  5242. private object setScriptRecording(string key)
  5243. {
  5244. object value = null;
  5245. switch (key)
  5246. {
  5247. case "parameter1":
  5248. value = comboBox1.SelectedIndex;
  5249. break;
  5250. case "OpenWhileExportReport":
  5251. value = checkBox3.Checked;
  5252. break;
  5253. case "CalculatorDecimalDigits":
  5254. value = numericUpDown1.Value;
  5255. break;
  5256. }
  5257. return value;
  5258. }
  5259. #endregion
  5260. }
  5261. }