IDEView.cpp 84 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732
  1. // VectorView.cpp : implementation of the CIDEView class
  2. //
  3. #include "stdafx.h"
  4. #include "IDEView.h"
  5. #include "PicSizeDlg.h"
  6. #include "gooddc.h"
  7. #include "graphdef.h"
  8. #include "MainFrm.h"
  9. #include "PicListDlg.h"
  10. #include ".\ideview.h"
  11. #include "BaseProDlg.h"
  12. #include "Dlg_RealTimeCurve.h"
  13. #ifdef _DEBUG
  14. #define new DEBUG_NEW
  15. #undef THIS_FILE
  16. static char THIS_FILE[] = __FILE__;
  17. #endif
  18. #pragma warning (disable: 4700)
  19. CDrawObjList g_Copied;
  20. /////////////////////////////////////////////////////////////////////////////
  21. // CIDEView
  22. IMPLEMENT_DYNCREATE(CIDEView, CScrollView)
  23. BEGIN_MESSAGE_MAP(CIDEView, CScrollView)
  24. //{{AFX_MSG_MAP(CIDEView)
  25. ON_WM_CREATE()
  26. ON_WM_DESTROY()
  27. ON_COMMAND(ID_EDIT_UNFREEZE, OnEditUnfreeze)
  28. ON_COMMAND(ID_EDIT_PASTE, OnEditPaste)
  29. ON_COMMAND(ID_EDIT_MOVETOFRONT, OnEditMovetofront)
  30. ON_COMMAND(ID_EDIT_MOVETOBACK, OnEditMovetoback)
  31. ON_COMMAND(ID_EDIT_HINVERT, OnEditHinvert)
  32. ON_COMMAND(ID_EDIT_FREEZE, OnEditFreeze)
  33. ON_COMMAND(ID_EDIT_CUT, OnEditCut)
  34. ON_COMMAND(ID_EDIT_COPY, OnEditCopy)
  35. ON_COMMAND(ID_EDIT_CLEAR, OnEditDelete)
  36. ON_COMMAND(ID_DESK_GRID, OnDeskGrid)
  37. ON_COMMAND(ID_ALIGN_TOP, OnAlignTop)
  38. ON_COMMAND(ID_ALIGN_VCENTER, OnAlignVcenter)
  39. ON_COMMAND(ID_ALIGN_RIGHT, OnAlignRight)
  40. ON_COMMAND(ID_ALIGN_LEFT, OnAlignLeft)
  41. ON_COMMAND(ID_ALIGN_HCENTER, OnAlignHcenter)
  42. ON_COMMAND(ID_ALIGN_BOTTOM, OnAlignBottom)
  43. ON_COMMAND(ID_EDIT_VINVERT, OnEditVinvert)
  44. ON_WM_MOUSEMOVE()
  45. ON_WM_LBUTTONDOWN()
  46. ON_WM_LBUTTONUP()
  47. ON_COMMAND(ID_POINTER, OnPointer)
  48. ON_WM_KEYDOWN()
  49. ON_COMMAND(ID_FILE_NEW, OnFileNew)
  50. ON_COMMAND(ID_FILE_OPEN, OnFileOpen)
  51. ON_COMMAND(ID_FILE_SAVE, OnFileSave)
  52. ON_COMMAND(ID_FILE_SAVE_AS, OnFileSaveAs)
  53. ON_COMMAND(ID_APP_EXIT, OnAppExit)
  54. ON_UPDATE_COMMAND_UI(ID_DESK_GRID, OnUpdateDeskGrid)
  55. ON_UPDATE_COMMAND_UI(ID_EDIT_FREEZE, OnUpdateEditFreeze)
  56. ON_COMMAND(ID_REDO, OnRedo)
  57. ON_COMMAND(ID_UNDO, OnUndo)
  58. ON_UPDATE_COMMAND_UI(ID_UNDO, OnUpdateUndo)
  59. ON_UPDATE_COMMAND_UI(ID_REDO, OnUpdateRedo)
  60. ON_COMMAND(ID_PICSIZE, OnPicsize)
  61. ON_UPDATE_COMMAND_UI(ID_ALIGN_BOTTOM, OnUpdateAlignBottom)
  62. ON_UPDATE_COMMAND_UI(ID_ALIGN_HCENTER, OnUpdateAlignHcenter)
  63. ON_UPDATE_COMMAND_UI(ID_ALIGN_LEFT, OnUpdateAlignLeft)
  64. ON_UPDATE_COMMAND_UI(ID_ALIGN_RIGHT, OnUpdateAlignRight)
  65. ON_UPDATE_COMMAND_UI(ID_ALIGN_TOP, OnUpdateAlignTop)
  66. ON_UPDATE_COMMAND_UI(ID_ALIGN_VCENTER, OnUpdateAlignVcenter)
  67. ON_UPDATE_COMMAND_UI(ID_EDIT_HINVERT, OnUpdateEditHinvert)
  68. ON_UPDATE_COMMAND_UI(ID_EDIT_MOVETOBACK, OnUpdateEditMovetoback)
  69. ON_UPDATE_COMMAND_UI(ID_EDIT_MOVETOFRONT, OnUpdateEditMovetofront)
  70. ON_UPDATE_COMMAND_UI(ID_EDIT_VINVERT, OnUpdateEditVinvert)
  71. ON_UPDATE_COMMAND_UI(ID_EDIT_COPY, OnUpdateEditCopy)
  72. ON_UPDATE_COMMAND_UI(ID_EDIT_CUT, OnUpdateEditCut)
  73. ON_UPDATE_COMMAND_UI(ID_EDIT_CLEAR, OnUpdateEditClear)
  74. ON_UPDATE_COMMAND_UI(ID_EDIT_PASTE, OnUpdateEditPaste)
  75. ON_COMMAND(ID_DRAW_TLINE, OnDrawTline)
  76. ON_COMMAND(ID_DRAW_TEXT, OnDrawText)
  77. ON_COMMAND(ID_DRAW_RECT, OnDrawRect)
  78. ON_COMMAND(ID_DRAW_DATA, OnDrawData)
  79. ON_COMMAND(ID_DRAW_BUTTON, OnDraw3drect)
  80. ON_COMMAND(ID_DRAW_3CIRCLE, OnDraw3circle)
  81. ON_UPDATE_COMMAND_UI(ID_POINTER, OnUpdatePointer)
  82. ON_WM_LBUTTONDBLCLK()
  83. ON_WM_TIMER()
  84. ON_UPDATE_COMMAND_UI(ID_DRAW_3CIRCLE, OnUpdateDraw3circle)
  85. ON_UPDATE_COMMAND_UI(ID_DRAW_BUTTON, OnUpdateDraw3drect)
  86. ON_UPDATE_COMMAND_UI(ID_DRAW_DATA, OnUpdateDrawData)
  87. ON_UPDATE_COMMAND_UI(ID_DRAW_TEXT, OnUpdateDrawText)
  88. ON_UPDATE_COMMAND_UI(ID_DRAW_TLINE, OnUpdateDrawTline)
  89. ON_WM_RBUTTONDOWN()
  90. ON_COMMAND(ID_EDIT_SAVE, OnEditSave)
  91. ON_UPDATE_COMMAND_UI(ID_EDIT_SAVE, OnUpdateEditSave)
  92. ON_WM_ERASEBKGND()
  93. ON_UPDATE_COMMAND_UI(ID_DRAW_RECT, OnUpdateDrawRect)
  94. ON_UPDATE_COMMAND_UI(ID_PICSIZE, OnUpdatePicsize)
  95. ON_COMMAND(ID_DRAW_BITMAP, OnDrawBitmap)
  96. ON_UPDATE_COMMAND_UI(ID_DRAW_BITMAP, OnUpdateDrawBitmap)
  97. ON_COMMAND(ID_DRAW_CURVE, OnDrawCurve)
  98. ON_UPDATE_COMMAND_UI(ID_DRAW_CURVE, OnUpdateDrawCurve)
  99. ON_COMMAND(ID_DRAW_WATCH, OnDrawWatch)
  100. ON_UPDATE_COMMAND_UI(ID_DRAW_WATCH, OnUpdateDrawWatch)
  101. ON_COMMAND(ID_DRAW_BAR, OnDrawBar)
  102. ON_UPDATE_COMMAND_UI(ID_DRAW_BAR, OnUpdateDrawBar)
  103. ON_COMMAND(ID_VERSPACE, OnVerspace)
  104. ON_UPDATE_COMMAND_UI(ID_VERSPACE, OnUpdateVerspace)
  105. ON_COMMAND(ID_SAMEWIDTH, OnSamewidth)
  106. ON_UPDATE_COMMAND_UI(ID_SAMEWIDTH, OnUpdateSamewidth)
  107. ON_COMMAND(ID_SAMEHEIGHT, OnSameheight)
  108. ON_UPDATE_COMMAND_UI(ID_SAMEHEIGHT, OnUpdateSameheight)
  109. ON_COMMAND(ID_HORSPACE, OnHorspace)
  110. ON_UPDATE_COMMAND_UI(ID_HORSPACE, OnUpdateHorspace)
  111. ON_COMMAND(ID_ALLSAME, OnAllsame)
  112. ON_UPDATE_COMMAND_UI(ID_ALLSAME, OnUpdateAllsame)
  113. ON_COMMAND(ID_OPENPIC, OnOpenpic)
  114. ON_COMMAND(ID_DRAW_ARC, OnDrawArc)
  115. ON_COMMAND(ID_DRAW_BREAKER, OnDrawBreaker)
  116. ON_COMMAND(ID_DRAW_FAN, OnDrawFan)
  117. ON_COMMAND(ID_DRAW_GRID, OnDrawGrid)
  118. ON_COMMAND(ID_DRAW_HISCURVE, OnDrawHiscurve)
  119. ON_COMMAND(ID_DRAW_LINE, OnDrawLine)
  120. ON_COMMAND(ID_DRAW_PIE, OnDrawPie)
  121. ON_COMMAND(ID_DRAW_PIPE, OnDrawPipe)
  122. ON_COMMAND(ID_DRAW_POLYGON, OnDrawPolygon)
  123. ON_COMMAND(ID_DRAW_REPORT, OnDrawReport)
  124. ON_COMMAND(ID_DRAW_SINGLEBAR, OnDrawSinglebar)
  125. ON_COMMAND(ID_DRAW_TRANSFER, OnDrawTransfer)
  126. ON_COMMAND(ID_DRAW_YPIPE, OnDrawYpipe)
  127. ON_COMMAND(ID_DRAW_ZHELINE, OnDrawZheline)
  128. ON_COMMAND(ID_DRAW_ZHEPIPE, OnDrawZhepipe)
  129. ON_COMMAND(ID_DRAW_ARROW, OnDrawArrow)
  130. ON_COMMAND(ID_DRAW_ELLIPSE, OnDrawEllipse)
  131. ON_COMMAND(ID_DRAW_SWITCH, OnDrawSwitch)
  132. ON_COMMAND(ID_DRAW_OCX, OnDrawOCX)
  133. ON_COMMAND(ID_DRAW_FLASH, OnDrawFlash)
  134. ON_COMMAND(ID_COMBINE, OnCombine)
  135. ON_COMMAND(ID_DISCOMBINE, OnDiscombine)
  136. ON_COMMAND(ID_DRAW_ROUNDRECT, OnDrawRoundrect)
  137. ON_COMMAND(ID_FILE_PRINT, OnFilePrint)
  138. ON_UPDATE_COMMAND_UI(ID_DRAW_SWITCH, OnUpdateDrawSwitch)
  139. ON_UPDATE_COMMAND_UI(ID_DRAW_ARC, OnUpdateDrawArc)
  140. ON_UPDATE_COMMAND_UI(ID_DRAW_ARROW, OnUpdateDrawArrow)
  141. ON_UPDATE_COMMAND_UI(ID_DRAW_BREAKER, OnUpdateDrawBreaker)
  142. ON_UPDATE_COMMAND_UI(ID_DRAW_ELLIPSE, OnUpdateDrawEllipse)
  143. ON_UPDATE_COMMAND_UI(ID_DRAW_FAN, OnUpdateDrawFan)
  144. ON_UPDATE_COMMAND_UI(ID_DRAW_GRID, OnUpdateDrawGrid)
  145. ON_UPDATE_COMMAND_UI(ID_DRAW_HISCURVE, OnUpdateDrawHiscurve)
  146. ON_UPDATE_COMMAND_UI(ID_DRAW_PIE, OnUpdateDrawPie)
  147. ON_UPDATE_COMMAND_UI(ID_DRAW_PIPE, OnUpdateDrawPipe)
  148. ON_UPDATE_COMMAND_UI(ID_DRAW_POLYGON, OnUpdateDrawPolygon)
  149. ON_UPDATE_COMMAND_UI(ID_DRAW_REPORT, OnUpdateDrawReport)
  150. ON_UPDATE_COMMAND_UI(ID_DRAW_SINGLEBAR, OnUpdateDrawSinglebar)
  151. ON_UPDATE_COMMAND_UI(ID_DRAW_TRANSFER, OnUpdateDrawTransfer)
  152. ON_UPDATE_COMMAND_UI(ID_DRAW_YPIPE, OnUpdateDrawYpipe)
  153. ON_UPDATE_COMMAND_UI(ID_DRAW_ZHELINE, OnUpdateDrawZheline)
  154. ON_UPDATE_COMMAND_UI(ID_DRAW_ZHEPIPE, OnUpdateDrawZhepipe)
  155. ON_UPDATE_COMMAND_UI(ID_DRAW_LINE, OnUpdateDrawLine)
  156. ON_UPDATE_COMMAND_UI(ID_DISCOMBINE, OnUpdateDiscombine)
  157. ON_UPDATE_COMMAND_UI(ID_COMBINE, OnUpdateCombine)
  158. ON_UPDATE_COMMAND_UI(ID_DRAW_ROUNDRECT, OnUpdateDrawRoundrect)
  159. ON_UPDATE_COMMAND_UI(ID_DRAW_OCX, OnUpdateDrawOCX)
  160. ON_UPDATE_COMMAND_UI(ID_DRAW_FLASH, OnUpdateDrawFlash)
  161. ON_WM_MOUSEWHEEL()
  162. //}}AFX_MSG_MAP
  163. // Standard printing commands
  164. ON_COMMAND(ID_FILE_PRINT, CScrollView::OnFilePrint)
  165. ON_COMMAND(ID_FILE_PRINT_DIRECT, CScrollView::OnFilePrint)
  166. ON_COMMAND(ID_FILE_PRINT_PREVIEW, CScrollView::OnFilePrintPreview)
  167. ON_COMMAND(ID_PROPERTY, OnProperty)
  168. ON_UPDATE_COMMAND_UI(ID_PROPERTY, OnUpdateProperty)
  169. ON_COMMAND(IDM_EDITVAR, OnEditVar)
  170. ON_UPDATE_COMMAND_UI(IDM_EDITVAR, OnUpdateEditVar)
  171. ON_COMMAND(IDM_REALTIMECURVE, OnRealTimeCurve)
  172. ON_UPDATE_COMMAND_UI(IDM_REALTIMECURVE, OnUpdateRealTimeCurve)
  173. ON_WM_CLOSE()
  174. ON_WM_KILLFOCUS()
  175. ON_WM_SETFOCUS()
  176. ON_WM_HSCROLL()
  177. ON_WM_RBUTTONDBLCLK()
  178. END_MESSAGE_MAP()
  179. /////////////////////////////////////////////////////////////////////////////
  180. // CIDEView construction/destruction
  181. CIDEView::CIDEView()
  182. {
  183. // TODO: add construction code here
  184. m_mouseState = FALSE;
  185. m_bDrag = FALSE;
  186. m_nDragHandle = 0;
  187. m_nBDragHandle = 0;
  188. m_bMoveElements = FALSE;
  189. m_bFreezed = FALSE;
  190. m_bRectSelect = FALSE;
  191. m_mouseRect = CRect(0,0,0,0);
  192. m_pCurActionObj = NULL;
  193. m_bPolygon = FALSE;
  194. //创建临时文件
  195. char tmpPathc[_MAX_PATH+1];
  196. GetTempPath(_MAX_PATH,tmpPathc);
  197. CString tmpPath = tmpPathc;
  198. ::CreateDirectory(tmpPath+"\\VDTemp",NULL);
  199. CGraph* pGraph = new CGraph(CSize(0,0));
  200. pGraph->m_strPicFile = _T(tmpPath+"\\VDTemp\\"+"\\First.ed");
  201. pGraph->Store();
  202. pGraph->m_strPicFile = _T(tmpPath+"\\VDTemp\\"+"\\Second.ed");
  203. pGraph->Store();
  204. pGraph->m_strPicFile = _T(tmpPath+"\\VDTemp\\"+"\\Third.ed");
  205. pGraph->Store();
  206. pGraph->m_strPicFile = _T(tmpPath+"\\VDTemp\\"+"\\Forth.ed");
  207. pGraph->Store();
  208. pGraph->m_strPicFile = _T(tmpPath+"\\VDTemp\\"+"\\Fifth.ed");
  209. pGraph->Store();
  210. pGraph->m_strPicFile = _T(tmpPath+"\\VDTemp\\"+"\\Six.ed");
  211. pGraph->Store();
  212. delete pGraph;
  213. m_nRudoPosition = 0;
  214. m_nCanUndoTimes = 0;
  215. m_nCanRedoTimes = 0;
  216. m_tblTime = CTime::GetCurrentTime();
  217. m_bOcxCreate = false;
  218. m_bIsHaveOCX = false;//是否有OCX
  219. m_bModified = FALSE;
  220. }
  221. CIDEView::~CIDEView()
  222. {
  223. int test=0;
  224. }
  225. BOOL CIDEView::PreCreateWindow(CREATESTRUCT& cs)
  226. {
  227. // TODO: Modify the Window class or styles here by modifying
  228. // the CREATESTRUCT cs
  229. return CScrollView::PreCreateWindow(cs);
  230. }
  231. /////////////////////////////////////////////////////////////////////////////
  232. // CIDEView drawing
  233. void CIDEView::OnDraw(CDC* pDC)
  234. {
  235. CIDEDoc* pDoc = GetDocument();
  236. ASSERT_VALID(pDoc);
  237. // TODO: add draw code for native data here
  238. //if( !m_bIsHaveOCX )
  239. {
  240. // 1.创建内存DC;
  241. CRect rect=NULL;
  242. CGoodDC dc;
  243. dc.Create(pDC);
  244. CRect rectClip;
  245. dc.GetClipBox(&rectClip);
  246. dc.FillSolidRect(rectClip,RGB(128,128,128));
  247. LAYOUTSTRUCT layout;
  248. CRect m_rect = layout.rect;
  249. CString sOCXPath;
  250. int nOcxIndex=0;
  251. // 2.在指定的DC环境设备上绘制所有的图元;
  252. rect = m_pGraph->Draw(&dc,sOCXPath,nOcxIndex);
  253. // 3.编辑状态下,显示选中图元的手势边框;
  254. if(/*m_bHandle*/g_bRun == FALSE)
  255. {// 编辑状态选中时,显示的选中的边框;
  256. POSITION pos = m_selection.GetHeadPosition();
  257. while(pos != NULL)
  258. {
  259. CDrawObj* pObj = m_selection.GetNext(pos);
  260. pObj->DrawTracker(&dc);
  261. }
  262. }
  263. // 画响应动作的图元的外框;
  264. //if (m_pCurActionObj != NULL )
  265. //{
  266. // m_pCurActionObj->DrawFrame(&dc);
  267. //}
  268. // 4.编辑状态下,以虚线框显示区选时的矩形范围;
  269. CPen dotpen;
  270. dotpen.CreatePen(PS_DOT, 1, RGB(195,195,195));
  271. CPen* oldobj = dc.SelectObject(&dotpen);
  272. // 区选图元时显示的4条边框;
  273. dc.MoveTo(m_mouseRect.left,m_mouseRect.top);
  274. dc.LineTo(m_mouseRect.right,m_mouseRect.top);
  275. dc.LineTo(m_mouseRect.right,m_mouseRect.bottom);
  276. dc.LineTo(m_mouseRect.left,m_mouseRect.bottom);
  277. dc.LineTo(m_mouseRect.left,m_mouseRect.top);
  278. dc.SelectObject(oldobj);
  279. if( rect.Width()>0 && rect.Height()>0 && g_bRun && nOcxIndex>=0 && nOcxIndex<=9 )
  280. {
  281. if( !m_bOcxCreate && sOCXPath!="" )
  282. {
  283. m_bOcxCreate = true;
  284. ShowOCX( rect,sOCXPath,nOcxIndex,g_sCurrentPageName );
  285. }
  286. dc.Destroy( );
  287. }
  288. else
  289. dc.Destroy();
  290. DeleteObject( dotpen );
  291. }
  292. }
  293. /////////////////////////////////////////////////////////////////////////////
  294. // CIDEView printing
  295. BOOL CIDEView::OnPreparePrinting(CPrintInfo* pInfo)
  296. {
  297. // default preparation
  298. pInfo->SetMinPage(1);
  299. pInfo->SetMaxPage(1);
  300. return DoPreparePrinting(pInfo);
  301. }
  302. void CIDEView::OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo)
  303. {
  304. // TODO: add extra initialization before printing
  305. CString sTemp;
  306. int nTemp=0;
  307. if(m_pGraph->m_Type == 0)
  308. {
  309. int nOffsetX = pDC->GetDeviceCaps(PHYSICALOFFSETX);
  310. int nOffsetY = pDC->GetDeviceCaps(PHYSICALOFFSETY);
  311. int nLogPixelX = pDC->GetDeviceCaps(LOGPIXELSX);
  312. int nLogPixelY = pDC->GetDeviceCaps(LOGPIXELSY);
  313. pDC->SetMapMode(MM_ISOTROPIC);
  314. pDC->SetWindowExt(100,100);
  315. pDC->SetViewportExt(nLogPixelX,nLogPixelY);
  316. pDC->SetViewportOrg(-nOffsetX,-nOffsetY);
  317. m_pGraph->Draw(pDC,sTemp,nTemp);
  318. }
  319. else
  320. {
  321. CSize size = m_pGraph->m_sizePic;
  322. int nHScale = pInfo->m_rectDraw.Width() / size.cx;
  323. int nVScale = pInfo->m_rectDraw.Height() / size.cy;
  324. int nScale = min(nHScale,nVScale);
  325. pDC->SetMapMode(MM_ISOTROPIC);
  326. pDC->SetWindowExt(1000,1000);
  327. pDC->SetViewportExt(1000*nScale,1000*nScale);
  328. int nHOffset = pInfo->m_rectDraw.Width() - nScale*size.cx;
  329. int nVOffset = pInfo->m_rectDraw.Height() - nScale*size.cy;
  330. pDC->SetViewportOrg(nHOffset/2,nVOffset/2);
  331. m_pGraph->Print(pDC);
  332. }
  333. }
  334. void CIDEView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
  335. {
  336. // TODO: add cleanup after printing
  337. }
  338. /////////////////////////////////////////////////////////////////////////////
  339. // CIDEView diagnostics
  340. #ifdef _DEBUG
  341. void CIDEView::AssertValid() const
  342. {
  343. CScrollView::AssertValid();
  344. }
  345. void CIDEView::Dump(CDumpContext& dc) const
  346. {
  347. CScrollView::Dump(dc);
  348. }
  349. CIDEDoc* CIDEView::GetDocument() // non-debug version is inline
  350. {
  351. ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CIDEDoc)));
  352. return (CIDEDoc*)m_pDocument;
  353. }
  354. #endif //_DEBUG
  355. /////////////////////////////////////////////////////////////////////////////
  356. // CIDEView message handlers
  357. BOOL CIDEView::Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext)
  358. {
  359. // TODO: Add your specialized code here and/or call the base class
  360. return CWnd::Create(lpszClassName, lpszWindowName, dwStyle, rect, pParentWnd, nID, pContext);
  361. }
  362. int CIDEView::OnCreate(LPCREATESTRUCT lpCreateStruct)
  363. {
  364. if (CScrollView::OnCreate(lpCreateStruct) == -1)
  365. {
  366. return -1;
  367. }
  368. m_bMove = TRUE;
  369. m_bHandle = TRUE;
  370. m_bModified = FALSE;
  371. m_pointMouse = CPoint(0,0);
  372. CString strPicFile = AfxGetApp()->m_lpCmdLine;
  373. if(!strPicFile.IsEmpty()) m_bMove = FALSE;
  374. m_pGraph = new CGraph(CSize(0,0));
  375. m_pGraph->SetPicFile(strPicFile);
  376. m_pGraph->SetView(this);
  377. m_pGraph->Load();
  378. RefreshScrollSizes();
  379. //CWnd *pWnd = GetParent(); ////下面这段子框架全屏幕显示
  380. //RECT rect;
  381. //WINDOWPLACEMENT wp,oldwp;
  382. //POINT pmin,pmax;
  383. //GetWindowPlacement(&oldwp);
  384. //if(pWnd != NULL)
  385. // pWnd-> GetClientRect(&rect);
  386. //
  387. //rect.bottom = 900;
  388. //pmax.x = rect.right ;
  389. //pmax.y = rect.bottom ;
  390. //pmin = oldwp.ptMinPosition ;
  391. //wp.length = sizeof(WINDOWPLACEMENT);
  392. //wp.flags = WPF_RESTORETOMAXIMIZED;
  393. //wp.showCmd = SW_SHOWMAXIMIZED;
  394. //wp.rcNormalPosition = rect;
  395. //SetWindowPlacement(&wp); ////上面这段子框架全屏幕显示
  396. SetTimer(3, 1000, NULL);
  397. return 0;
  398. }
  399. void CIDEView::OnDestroy()
  400. {
  401. CScrollView::OnDestroy();
  402. #if VIEW_USE_THREAD
  403. MTVERIFY( SetEvent( m_hFreshGraphObject ) );
  404. MTVERIFY( SetEvent( m_hIDEViewRunObject ) );
  405. MTVERIFY( WaitForSingleObject( m_hFreshGraphThread, INFINITE ) != WAIT_FAILED );
  406. MTVERIFY( CloseHandle( m_hFreshGraphThread ) );
  407. m_hFreshGraphThread = NULL;
  408. MTVERIFY( CloseHandle( m_hIDEViewRunObject ) );
  409. MTVERIFY( CloseHandle( m_hFreshGraphObject ) );
  410. m_hFreshGraphObject = NULL;
  411. DeleteCriticalSection( &m_csFreshGraph );
  412. #endif
  413. // TODO: Add your message handler code here
  414. POSITION pos = m_copied.GetHeadPosition();
  415. while(pos != NULL)
  416. {
  417. CDrawObj *pObj = m_copied.GetNext(pos);
  418. delete pObj;
  419. }
  420. m_copied.RemoveAll();
  421. pos = g_Copied.GetHeadPosition();
  422. while(pos != NULL)
  423. {
  424. CDrawObj *pObj = g_Copied.GetNext(pos);
  425. delete pObj;
  426. }
  427. g_Copied.RemoveAll();
  428. pos = m_deleted.GetHeadPosition();
  429. while(pos != NULL)
  430. {
  431. CDrawObj *pObj = m_deleted.GetNext(pos);
  432. delete pObj;
  433. }
  434. m_deleted.RemoveAll();
  435. delete m_pGraph;
  436. m_pGraph = NULL;
  437. // TODO: Add your message handler code here
  438. }
  439. void CIDEView::OnEditUnfreeze()
  440. {
  441. POSITION pos = m_selection.GetHeadPosition();
  442. if( pos!=NULL )
  443. {
  444. while( pos != NULL)
  445. {
  446. CDrawObj* pObj = m_selection.GetNext(pos);
  447. pObj->m_bOnMove = false;
  448. }
  449. }
  450. else
  451. {
  452. m_bFreezed = FALSE;
  453. }
  454. }
  455. void CIDEView::OnEditPaste()
  456. {
  457. // TODO: Add your command handler code here
  458. #if 1
  459. m_selection.RemoveAll();
  460. POSITION pos = g_Copied.GetHeadPosition();
  461. while(pos != NULL)
  462. {
  463. CDrawObj *pObj = g_Copied.GetNext(pos);
  464. CDrawObj *pNewObj = pObj->Clone();
  465. pObj->m_rect.OffsetRect(20,20);
  466. pNewObj->m_rect.OffsetRect(20,20);
  467. if (pNewObj->IsKindOf( RUNTIME_CLASS(CDrawPoly) ))
  468. {
  469. int nPointCount = ((CDrawPoly*)pNewObj)->m_nPoints;
  470. for (int i = 0; i<nPointCount; i++)
  471. {
  472. ((CDrawPoly*)pNewObj)->m_points[i] += CSize(20,20);
  473. ((CDrawPoly*)pObj)->m_points[i] += CSize(20,20);
  474. }
  475. }
  476. pNewObj->m_pView = this;
  477. m_pGraph->m_DrawObjList.AddTail(pNewObj);
  478. m_selection.AddTail(pNewObj);
  479. }
  480. Invalidate(FALSE);
  481. m_bModified = TRUE;
  482. #else
  483. m_selection.RemoveAll();
  484. POSITION pos = m_copied.GetHeadPosition();
  485. while(pos != NULL)
  486. {
  487. CDrawObj *pObj = m_copied.GetNext(pos);
  488. CDrawObj *pNewObj = pObj->Clone();
  489. pObj->m_rect.OffsetRect(20,20);
  490. pNewObj->m_rect.OffsetRect(20,20);
  491. if (pNewObj->IsKindOf( RUNTIME_CLASS(CDrawPoly) ))
  492. {
  493. int nPointCount = ((CDrawPoly*)pNewObj)->m_nPoints;
  494. for (int i = 0; i<nPointCount; i++)
  495. {
  496. ((CDrawPoly*)pNewObj)->m_points[i] += CSize(20,20);
  497. ((CDrawPoly*)pObj)->m_points[i] += CSize(20,20);
  498. }
  499. }
  500. m_pGraph->m_DrawObjList.AddTail(pNewObj);
  501. m_selection.AddTail(pNewObj);
  502. }
  503. Invalidate(FALSE);
  504. m_bModified = TRUE;
  505. #endif
  506. }
  507. void CIDEView::OnEditMovetofront()
  508. {
  509. // TODO: Add your command handler code here
  510. POSITION pos = m_selection.GetHeadPosition();
  511. while(pos != NULL)
  512. {
  513. CDrawObj* pObj = m_selection.GetNext(pos);
  514. POSITION pos0 = m_pGraph->m_DrawObjList.Find(pObj);
  515. m_pGraph->m_DrawObjList.RemoveAt(pos0);
  516. m_pGraph->m_DrawObjList.AddTail(pObj);
  517. pObj->Invalidate();
  518. }
  519. Invalidate(FALSE);
  520. m_bModified = TRUE;
  521. }
  522. void CIDEView::OnEditMovetoback()
  523. {
  524. // TODO: Add your command handler code here
  525. POSITION pos = m_selection.GetTailPosition();
  526. while(pos != NULL)
  527. {
  528. CDrawObj* pObj = m_selection.GetPrev(pos);
  529. POSITION pos0 = m_pGraph->m_DrawObjList.Find(pObj);
  530. m_pGraph->m_DrawObjList.RemoveAt(pos0);
  531. m_pGraph->m_DrawObjList.AddHead(pObj);
  532. pObj->Invalidate();
  533. }
  534. Invalidate(FALSE);
  535. m_bModified = TRUE;
  536. }
  537. void CIDEView::OnEditHinvert()
  538. {
  539. // TODO: Add your command handler code here
  540. POSITION pos = m_selection.GetHeadPosition();
  541. while(pos != NULL)
  542. {
  543. CDrawObj *pObj = m_selection.GetNext(pos);
  544. int temp = pObj->m_rect.left;
  545. pObj->m_rect.left = pObj->m_rect.right;
  546. pObj->m_rect.right = temp;
  547. pObj->Invalidate();
  548. m_bModified = TRUE;
  549. }
  550. Invalidate(FALSE);
  551. m_bModified = TRUE;
  552. }
  553. void CIDEView::OnEditFreeze()
  554. {
  555. // TODO: Add your command handler code here
  556. CRect freshRect; // 需要刷新的区域
  557. POSITION pos = m_selection.GetHeadPosition();
  558. if( pos!=NULL )
  559. {
  560. while( pos != NULL)
  561. {
  562. CDrawObj* pObj = m_selection.GetNext(pos);
  563. pObj->m_bOnMove = true;
  564. }
  565. }
  566. else
  567. {
  568. m_bFreezed = !m_bFreezed;
  569. }
  570. }
  571. void CIDEView::OnEditCut()
  572. {
  573. // TODO: Add your command handler code here
  574. OnEditCopy();
  575. OnEditDelete();
  576. Invalidate(FALSE);
  577. }
  578. void CIDEView::OnEditCopy()
  579. {
  580. // TODO: Add your command handler code here
  581. #if 1
  582. // 复制前,先清除之前的;
  583. POSITION pos = g_Copied.GetHeadPosition();
  584. while(pos != NULL)
  585. {
  586. CDrawObj *pObj = g_Copied.GetNext(pos);
  587. delete pObj;
  588. }
  589. g_Copied.RemoveAll();
  590. pos = m_selection.GetHeadPosition();
  591. while(pos != NULL)
  592. {
  593. CDrawObj* pObj = m_selection.GetNext(pos);
  594. CDrawObj *pNewObj = pObj->Clone();
  595. g_Copied.AddTail(pNewObj);
  596. }
  597. #else
  598. POSITION pos = m_copied.GetHeadPosition();
  599. while(pos != NULL)
  600. {
  601. CDrawObj *pObj = m_copied.GetNext(pos);
  602. delete pObj;
  603. }
  604. m_copied.RemoveAll();
  605. pos = m_selection.GetHeadPosition();
  606. while(pos != NULL)
  607. {
  608. CDrawObj* pObj = m_selection.GetNext(pos);
  609. CDrawObj *pNewObj = pObj->Clone();
  610. m_copied.AddTail(pNewObj);
  611. }
  612. #endif
  613. }
  614. void CIDEView::OnEditDelete()
  615. {
  616. POSITION pos = m_deleted.GetHeadPosition();
  617. while(pos != NULL)
  618. {
  619. CDrawObj* pObj = m_deleted.GetNext(pos);
  620. delete pObj;
  621. }
  622. m_deleted.RemoveAll();
  623. #if 0
  624. pos = m_selection.GetHeadPosition();
  625. while(pos != NULL)
  626. {
  627. CDrawObj* pObj = m_selection.GetNext(pos);
  628. pObj->Invalidate();
  629. Remove(pObj);
  630. m_deleted.AddTail(pObj);
  631. }
  632. m_selection.RemoveAll();
  633. #endif
  634. for(POSITION pos = m_selection.GetHeadPosition();pos!=NULL;)
  635. {
  636. POSITION pos1 = pos ; //要在这里做一个备份
  637. CDrawObj* pObj = m_selection.GetNext(pos);//他会改变 pos的值
  638. pObj->Invalidate();
  639. Remove(pObj);
  640. m_deleted.AddTail(pObj);
  641. }
  642. m_selection.RemoveAll();
  643. m_bModified = TRUE;
  644. }
  645. void CIDEView::OnDeskGrid()
  646. {
  647. m_pGraph->m_bGrid = !m_pGraph->m_bGrid;
  648. m_bModified = TRUE;
  649. Invalidate(FALSE);
  650. }
  651. void CIDEView::OnAlignTop()
  652. {
  653. CRect rect = GetAlignRect();
  654. POSITION pos = m_selection.GetHeadPosition();
  655. while(pos != NULL)
  656. {
  657. CDrawObj* pObj = m_selection.GetNext(pos);
  658. CRect r = pObj->m_rect;
  659. r.OffsetRect(0, rect.top - min(r.top, r.bottom));
  660. pObj->MoveTo(r);
  661. m_bModified = TRUE;
  662. }
  663. Invalidate(FALSE);
  664. }
  665. void CIDEView::OnAlignVcenter()
  666. {
  667. CRect rect = GetAlignRect();
  668. int y0 = rect.top + rect.Height() / 2;
  669. POSITION pos = m_selection.GetTailPosition();
  670. m_selection.GetPrev(pos);
  671. while(pos != NULL)
  672. {
  673. CDrawObj* pObj = m_selection.GetPrev(pos);
  674. CRect r = pObj->m_rect;
  675. int y = r.top + r.Height() / 2;
  676. r.OffsetRect(0, y0-y);
  677. pObj->MoveTo(r);
  678. m_bModified = TRUE;
  679. }
  680. Invalidate(FALSE);
  681. }
  682. void CIDEView::OnAlignRight()
  683. {
  684. CRect rect = GetAlignRect();
  685. POSITION pos = m_selection.GetHeadPosition();
  686. while(pos != NULL)
  687. {
  688. CDrawObj* pObj = m_selection.GetNext(pos);
  689. CRect r = pObj->m_rect;
  690. r.OffsetRect(rect.right - max(r.left, r.right), 0);
  691. pObj->MoveTo(r);
  692. m_bModified = TRUE;
  693. }
  694. Invalidate(FALSE);
  695. }
  696. void CIDEView::OnAlignLeft()
  697. {
  698. CRect rect = GetAlignRect();
  699. POSITION pos = m_selection.GetHeadPosition();
  700. while(pos != NULL)
  701. {
  702. CDrawObj* pObj = m_selection.GetNext(pos);
  703. CRect r = pObj->m_rect;
  704. r.OffsetRect(rect.left - min(r.left, r.right), 0);
  705. pObj->MoveTo(r);
  706. m_bModified = TRUE;
  707. }
  708. Invalidate(FALSE);
  709. }
  710. void CIDEView::OnAlignHcenter()
  711. {
  712. CRect rect = GetAlignRect();
  713. int x0 = rect.left + rect.Width() / 2;
  714. POSITION pos = m_selection.GetTailPosition();
  715. m_selection.GetPrev(pos);
  716. while(pos != NULL)
  717. {
  718. CDrawObj* pObj = m_selection.GetPrev(pos);
  719. CRect r = pObj->m_rect;
  720. int x = r.left + r.Width() / 2;
  721. r.OffsetRect(x0-x, 0);
  722. pObj->MoveTo(r);
  723. m_bModified = TRUE;
  724. }
  725. Invalidate(FALSE);
  726. }
  727. void CIDEView::OnAlignBottom()
  728. {
  729. CRect rect = GetAlignRect();
  730. POSITION pos = m_selection.GetHeadPosition();
  731. while(pos != NULL)
  732. {
  733. CDrawObj* pObj = m_selection.GetNext(pos);
  734. CRect r = pObj->m_rect;
  735. r.OffsetRect(0, rect.bottom - max(r.top, r.bottom));
  736. pObj->MoveTo(r);
  737. m_bModified = TRUE;
  738. }
  739. Invalidate(FALSE);
  740. }
  741. void CIDEView::OnEditVinvert()
  742. {
  743. POSITION pos = m_selection.GetHeadPosition();
  744. while(pos != NULL)
  745. {
  746. CDrawObj *pObj = m_selection.GetNext(pos);
  747. int temp = pObj->m_rect.top;
  748. pObj->m_rect.top = pObj->m_rect.bottom;
  749. pObj->m_rect.bottom = temp;
  750. pObj->Invalidate();
  751. m_bModified = TRUE;
  752. }
  753. Invalidate(FALSE);
  754. }
  755. void CIDEView::OnMouseMove(UINT nFlags, CPoint point)
  756. {
  757. if ( m_mouseState )
  758. _tprintf(_T("按住鼠标移动:x:%d, y:%d\n"), point.x, point.y);
  759. if(CDrawObj::bRuning == TRUE)
  760. {
  761. POSITION pos = m_pGraph->m_DrawObjList.GetHeadPosition();
  762. while(pos != NULL)
  763. {
  764. CDrawObj* pObj = m_pGraph->m_DrawObjList.GetNext(pos);
  765. if ( (pObj->m_bOnButtonDown) && 0!=pObj->m_rect.PtInRect(point) && pObj->m_bShow )
  766. {
  767. HCURSOR hCursor;
  768. hCursor = AfxGetApp() -> LoadCursor(IDC_HANDCUR);
  769. SetCursor(hCursor);
  770. break;
  771. }
  772. }
  773. // 运行状态下,做动作响应处理
  774. //CClientDC dc(this);
  775. //OnPrepareDC(&dc);
  776. //CPoint local = point;
  777. //dc.DPtoLP(&local);
  778. //CDrawObj* tmp = ObjectAt(local);
  779. //if ( tmp != NULL ) //该图元响应move动作
  780. //{
  781. // if (tmp->m_bOnMove)
  782. // {
  783. // m_nCurActionType = MOUSE_MOVE;
  784. // m_pCurActionObj = tmp;
  785. // tmp->ProcessAction(MOUSE_MOVE);
  786. // }
  787. // if (tmp->IsKindOf( RUNTIME_CLASS(CDrawButton) ) ||
  788. // ( tmp->IsKindOf( RUNTIME_CLASS(CDrawBitmap) ) &&
  789. // ( tmp->m_downAction.m_nActionType == LINK_COMMOND || tmp->m_downAction.m_nActionType == SET_COMMOND ||
  790. // //tmp->m_downAction.m_nActionType == YT_COMMOND || tmp->m_downAction.m_nActionType == YK_COMMOND ||
  791. // tmp->m_downAction.m_nActionType == EXIT_COMMOND || tmp->m_downAction.m_nActionType == EXTERN_COMMOND) ) )
  792. // {
  793. // //::SetCursor(LoadCursor(NULL,(char*) IDC_HAND));
  794. // m_pCurActionObj = tmp;
  795. // }
  796. //}
  797. //else
  798. //{
  799. // m_pCurActionObj = NULL;
  800. //}
  801. return;
  802. }
  803. CClientDC dc(this);
  804. OnPrepareDC(&dc);
  805. CPoint local = point;
  806. dc.DPtoLP(&local);
  807. CSize offset = point-local;
  808. m_pointMouse = local;
  809. bool bFresh = false;
  810. if (m_mouseState == TRUE) // 鼠标按下;
  811. {
  812. if ((g_nElementNo != 0)&&(m_tempObj != NULL) ) //添加新的图元;
  813. {
  814. //画新图元的外形;
  815. m_tempObj->m_rect = CRect(m_startPoint,m_pointMouse);
  816. m_bModified = TRUE;
  817. CRect freshRect = m_tempObj->m_rect;
  818. freshRect.NormalizeRect();
  819. CRect lastRect = CRect(m_lastPoint,m_lastPoint+CSize(4,4));
  820. lastRect.NormalizeRect();
  821. freshRect.UnionRect(freshRect,lastRect);
  822. freshRect.InflateRect(4,4);
  823. freshRect.OffsetRect(offset);
  824. InvalidateRect(freshRect,FALSE);
  825. }
  826. else if (m_bDrag == TRUE) // 改变图元大小;
  827. {
  828. m_selection.GetHead()->MoveHandleTo(m_nBDragHandle,local);
  829. SetCursor(m_selection.GetHead()->GetHandleCursor());
  830. m_bModified = TRUE;
  831. CRect freshRect = m_selection.GetHead()->m_rect;
  832. freshRect.NormalizeRect();
  833. CRect lastRect = CRect(m_lastPoint,m_lastPoint+CSize(4,4));
  834. lastRect.NormalizeRect();
  835. freshRect.UnionRect(freshRect,lastRect);
  836. freshRect.InflateRect(4,4);
  837. freshRect.OffsetRect(offset);
  838. InvalidateRect(freshRect,FALSE);
  839. }
  840. else if (m_bRectSelect == TRUE) // 区选图元;
  841. {
  842. m_mouseRect = CRect(m_startPoint,local);
  843. CRect freshRect = m_mouseRect; // 需要刷新的区域;
  844. freshRect.NormalizeRect();
  845. CRect lastRect = CRect(m_startPoint,m_lastPoint);
  846. lastRect.NormalizeRect();
  847. freshRect.UnionRect(freshRect,lastRect);
  848. freshRect.InflateRect(4,4);
  849. freshRect.OffsetRect(offset);
  850. InvalidateRect(freshRect,FALSE);
  851. }
  852. }
  853. // 如果鼠标没按下,则判断是否到选中图元(一个)的边上了,是的话,改变图标;
  854. if (m_mouseState == FALSE)
  855. {
  856. if ((g_nElementNo == 0) && (m_selection.GetCount() == 1))
  857. {
  858. m_nDragHandle = m_selection.GetHead()->HitTest(local);
  859. if ( (m_nDragHandle>0)&&(m_nDragHandle<9) )
  860. {
  861. SetCursor(m_selection.GetHead()->GetHandleCursor());
  862. }
  863. }
  864. }
  865. if((m_bMoveElements == TRUE)&&(!m_bFreezed)) // 移动一个或多个图元;
  866. {
  867. HCURSOR hCursor;
  868. hCursor = AfxGetApp() -> LoadCursor(IDC_CURSOR1);
  869. SetCursor(hCursor);
  870. CRect freshRect; // 需要刷新的区域;
  871. bool bFirst = true;
  872. POSITION pos = m_selection.GetHeadPosition();
  873. while( pos != NULL)
  874. {
  875. CDrawObj* pObj = m_selection.GetNext(pos);
  876. if( pObj->m_bOnMove )
  877. continue;
  878. CRect rect = pObj->m_rect;
  879. if (bFirst)
  880. {
  881. freshRect = rect;
  882. freshRect.InflateRect(4,4);
  883. }
  884. else
  885. freshRect.UnionRect(freshRect, rect);
  886. CPoint delta = CPoint(local-m_lastPoint);
  887. rect += delta;
  888. pObj->MoveTo(rect);
  889. rect.NormalizeRect();
  890. freshRect.UnionRect(freshRect, rect);
  891. freshRect.InflateRect(4,4);
  892. m_bModified = TRUE;
  893. bFirst = false;
  894. InvalidateRect(freshRect,FALSE);
  895. }
  896. }
  897. CString str;
  898. // 要访问类CMainFrame,需要将mainfrm.h文件引入;
  899. CMainFrame * pFrame = (CMainFrame *) AfxGetApp()->m_pMainWnd;
  900. CStatusBar * pStatus = (CStatusBar *) &pFrame->m_wndStatusBar;
  901. str.Format (g_strLogicDoorinate, local.x, local.y);
  902. pStatus->SetPaneText(1, str);
  903. // 根据情况,刷新部分区域;
  904. if (bFresh )
  905. Invalidate(FALSE);
  906. m_lastPoint = local;
  907. CScrollView::OnMouseMove(nFlags, point);
  908. }
  909. long CIDEView::OnOutbarNotify(WPARAM wParam, LPARAM lParam)
  910. {
  911. return 0;
  912. }
  913. void CIDEView::OnLButtonDown(UINT nFlags, CPoint point) // 鼠标按下:选择或画;
  914. {
  915. if(CDrawObj::bRuning == TRUE)
  916. {
  917. // 运行状态下,做动作响应处理;
  918. CClientDC dc(this);
  919. OnPrepareDC(&dc);
  920. CPoint local = point;
  921. dc.DPtoLP(&local);
  922. CDrawObj* tmp = ObjectAt(local);
  923. if ( tmp != NULL && 1) //该图元响应click动作;
  924. {
  925. if (tmp->m_bOnButtonDown && tmp->m_bShow )
  926. {
  927. //AfxMessageBox( tmp->m_strCaption );
  928. m_nCurActionType = MOUSE_CLICK_DOWN;
  929. m_pCurActionObj = tmp;
  930. tmp->ProcessAction(MOUSE_CLICK_DOWN);
  931. }
  932. }
  933. else
  934. {
  935. m_pCurActionObj = NULL;
  936. }
  937. return;
  938. }
  939. CClientDC dc(this);
  940. OnPrepareDC(&dc);
  941. CPoint local = point;
  942. dc.DPtoLP(&local);
  943. // 鼠标按下时,还原拖动为FALSE;
  944. m_bDrag = FALSE;
  945. // 鼠标按下时,设置鼠标状态为TURE表示按下;
  946. m_mouseState = TRUE;
  947. m_startPoint = local;
  948. m_lastPoint = local;
  949. if (ObjectAt(local))
  950. _tprintf(_T("按下鼠标:x:%d, y:%d\n"), point.x, point.y);
  951. if (g_nElementNo != 0)
  952. {// 生成一个图元;
  953. if ( g_nElementNo == POLYGON || g_nElementNo == ZHELINE)
  954. {
  955. if ( m_bPolygon )
  956. {// 如果是折线(折线需要多次按下松开鼠标);
  957. ((CDrawPoly*)m_tempObj)->AddPoint(local);
  958. ((CDrawPoly*)m_tempObj)->RecalcBounds();
  959. CRect freshRect = m_tempObj->m_rect;
  960. freshRect.NormalizeRect();
  961. freshRect.InflateRect(4,4);
  962. InvalidateRect(freshRect,FALSE);
  963. }
  964. else
  965. {// 如果不是折线,只需要按下和松开鼠标一次;
  966. m_selection.RemoveAll();
  967. // 根据类型创建新图元;
  968. m_tempObj = CreateDrawObjbyNo(g_nElementNo);
  969. if (m_tempObj != NULL)
  970. {
  971. m_pGraph->m_DrawObjList.AddTail(m_tempObj);
  972. m_selection.AddTail(m_tempObj);
  973. ((CDrawPoly*)m_tempObj)->AddPoint(local);
  974. m_bPolygon = true;
  975. }
  976. }
  977. }
  978. else
  979. {
  980. m_selection.RemoveAll();
  981. m_tempObj = CreateDrawObjbyNo(g_nElementNo); /**/
  982. if (m_tempObj != NULL)
  983. {
  984. m_pGraph->m_DrawObjList.AddTail(m_tempObj);
  985. m_selection.AddTail(m_tempObj);
  986. }
  987. }
  988. }
  989. else if(m_nDragHandle == 0)
  990. {// 选择一个图元;
  991. CDrawObj *pObj = ObjectAt(local);
  992. if(pObj != NULL)
  993. {
  994. //selectMode = move;
  995. if(!IsSelected(pObj))
  996. Select(pObj, (nFlags & MK_CONTROL) != 0);
  997. else if((nFlags & MK_CONTROL) != 0)
  998. {
  999. POSITION ipos = m_selection.Find(pObj);
  1000. if(ipos != NULL) m_selection.RemoveAt(ipos);
  1001. } //去掉selection中的该图元;
  1002. m_bMoveElements = TRUE;
  1003. }
  1004. else if((nFlags & MK_CONTROL) == 0)
  1005. {
  1006. m_selection.RemoveAll();
  1007. m_bMoveElements = FALSE;
  1008. m_bRectSelect = TRUE; //rectselect 区域选;
  1009. }
  1010. }
  1011. else // 拉动一个图元;
  1012. {
  1013. m_bDrag = TRUE;
  1014. m_nBDragHandle = m_nDragHandle;
  1015. }
  1016. //Invalidate(FALSE);
  1017. CScrollView::OnLButtonDown(nFlags, point);
  1018. }
  1019. /************************************************************************/
  1020. /* 函数:[5/11/2016 IT];
  1021. /* 描述:;
  1022. /* 参数:;
  1023. /* [IN] :;
  1024. /* [OUT] :;
  1025. /* [IN/OUT] :;
  1026. /* 返回:void;
  1027. /* 注意:1.生成图元时放开鼠标;2.选中时放开鼠标;3.拖动时放开鼠标;
  1028. /* 示例:;
  1029. /*
  1030. /* 修改:;
  1031. /* 日期:;
  1032. /* 内容:;
  1033. /************************************************************************/
  1034. void CIDEView::OnLButtonUp(UINT nFlags, CPoint point) // 松开鼠标,完成画或移动或变形;
  1035. {
  1036. if(CDrawObj::bRuning == TRUE)
  1037. {
  1038. m_pCurActionObj = NULL;
  1039. // 运行状态下,做动作响应处理
  1040. CClientDC dc(this);
  1041. OnPrepareDC(&dc);
  1042. CPoint local = point;
  1043. dc.DPtoLP(&local);
  1044. CDrawObj* tmp = ObjectAt(point);
  1045. if ( tmp != NULL && tmp->m_bOnButtonUp && tmp->m_bShow ) //该图元响应click动作
  1046. {
  1047. m_nCurActionType = MOUSE_CLICK_UP;
  1048. m_pCurActionObj = tmp;
  1049. if (tmp->m_bOnButtonUp)
  1050. {
  1051. tmp->ProcessAction(MOUSE_CLICK_UP);
  1052. }
  1053. }
  1054. else
  1055. {
  1056. m_pCurActionObj = NULL;
  1057. }
  1058. return;
  1059. }
  1060. CClientDC dc(this);
  1061. OnPrepareDC(&dc);
  1062. CPoint local = point;
  1063. dc.DPtoLP(&local);
  1064. m_mouseState = FALSE;
  1065. m_endPoint = local;
  1066. if (ObjectAt(local))
  1067. _tprintf(_T("松开鼠标:x:%d, y:%d\n"), point.x, point.y);
  1068. // 图元类型不为空,且图元对象不为空,完成新图元;
  1069. if ((g_nElementNo != 0)&&(m_tempObj != NULL) )
  1070. {//添加新图元;
  1071. if ( (g_nElementNo == POLYGON || g_nElementNo == ZHELINE )&& m_bPolygon)
  1072. {// 如果是折线,不完成图元;
  1073. ;
  1074. }
  1075. else
  1076. {
  1077. // 图元大小;
  1078. m_tempObj->m_rect = CRect(m_startPoint,m_endPoint);
  1079. if ((abs(CPoint(m_endPoint-m_startPoint).x)<6) && (abs(CPoint(m_endPoint-m_startPoint).y)<6))
  1080. {// 如果生成的图元区域过小,删除图元,认为不生成;
  1081. Remove(m_tempObj);
  1082. delete m_tempObj;
  1083. m_tempObj = NULL;
  1084. g_nElementNo = 0;
  1085. }
  1086. else // 图元添加成功了,做临时文件处理;
  1087. {
  1088. if (m_nRudoPosition == 0) //上一次也是编辑;
  1089. {
  1090. ExchangeSave();
  1091. if (m_nCanUndoTimes<5)
  1092. {
  1093. m_nCanUndoTimes++;
  1094. }
  1095. }
  1096. else //上一次不是编辑;
  1097. {
  1098. FileProcess();
  1099. }
  1100. m_nRudoPosition = 0;
  1101. m_nCanRedoTimes = 0;
  1102. }
  1103. }
  1104. }
  1105. if (m_bRectSelect) //选中一堆图元;
  1106. {
  1107. m_mouseRect.NormalizeRect();
  1108. ObjectIn();
  1109. }
  1110. if((m_bMoveElements == TRUE)&&(!m_bFreezed)) //移动,也要临时文件记录;
  1111. {
  1112. if (m_nRudoPosition == 0) //上一次也是编辑;
  1113. {
  1114. ExchangeSave();
  1115. }
  1116. else //上一次不是编辑;
  1117. {
  1118. FileProcess();
  1119. }
  1120. m_nRudoPosition = 0;
  1121. m_nCanRedoTimes = 0;
  1122. }
  1123. if(m_bDrag)
  1124. {// 放开拖动;
  1125. if (m_nRudoPosition == 0) //上一次也是编辑;
  1126. {
  1127. ExchangeSave();
  1128. }
  1129. else //上一次不是编辑;
  1130. {
  1131. FileProcess();
  1132. }
  1133. m_nRudoPosition = 0;
  1134. m_nCanRedoTimes = 0;
  1135. }
  1136. m_bMoveElements = FALSE;
  1137. m_bDrag = FALSE;
  1138. m_mouseRect = CRect(0,0,0,0);
  1139. m_bRectSelect = FALSE;
  1140. Invalidate(FALSE);
  1141. CScrollView::OnLButtonUp(nFlags, point);
  1142. }
  1143. void CIDEView::OnRButtonDblClk(UINT nFlags, CPoint point)
  1144. {
  1145. // TODO: 在此添加消息处理程序代码和/或调用默认值
  1146. CScrollView::OnRButtonDblClk(nFlags, point);
  1147. }
  1148. //属性设定
  1149. void CIDEView::OnLButtonDblClk(UINT nFlags, CPoint point)
  1150. {
  1151. if(CDrawObj::bRuning == TRUE )
  1152. {
  1153. //CClientDC dc(this);
  1154. //OnPrepareDC(&dc);
  1155. CPoint local = point;
  1156. //dc.DPtoLP(&local);
  1157. CDrawObj *pObj = ObjectAt(local);
  1158. if(pObj != NULL)
  1159. {
  1160. CString sVarName;
  1161. if( pObj->m_bVariant && pObj->m_strCaption!="" )
  1162. sVarName = pObj->m_strCaption;
  1163. else if( pObj->m_strDynShow!="" )
  1164. sVarName = GetVarNameFromGS( pObj->m_strDynShow );
  1165. else if( pObj->m_strDynForeCon!="" )
  1166. sVarName = GetVarNameFromGS( pObj->m_strDynForeCon );
  1167. else if( pObj->m_strDynBackCon!="" )
  1168. sVarName = GetVarNameFromGS( pObj->m_strDynBackCon );
  1169. else if( pObj->m_strDynLineCon!="" )
  1170. sVarName = GetVarNameFromGS( pObj->m_strDynLineCon );
  1171. else if( pObj->m_strHoriPos!="" )
  1172. sVarName = GetVarNameFromGS( pObj->m_strHoriPos );
  1173. else if( pObj->m_strHoriSize!="" )
  1174. sVarName = GetVarNameFromGS( pObj->m_strHoriSize );
  1175. else if( pObj->m_strVertiPos!="" )
  1176. sVarName = GetVarNameFromGS( pObj->m_strVertiPos );
  1177. else if( pObj->m_strVertiSize!="" )
  1178. sVarName = GetVarNameFromGS( pObj->m_strVertiSize );
  1179. else if( pObj->m_strCurrentCaption!="" )
  1180. sVarName = GetVarNameFromGS( pObj->m_strCurrentCaption );
  1181. if( pObj->IsKindOf( RUNTIME_CLASS(CDrawBitmap) ) && sVarName=="" )
  1182. {
  1183. if( ((CDrawBitmap *)pObj)->m_strDynCondition!="" )
  1184. sVarName = GetVarNameFromGS( ((CDrawBitmap *)pObj)->m_strDynCondition );
  1185. }
  1186. if( pObj->IsKindOf( RUNTIME_CLASS(CDrawGif) ) && sVarName=="" )
  1187. {
  1188. if( ((CDrawGif *)pObj)->m_strDynCondition!="" )
  1189. sVarName = GetVarNameFromGS( ((CDrawGif *)pObj)->m_strDynCondition );
  1190. }
  1191. if( sVarName!="" )
  1192. {
  1193. }
  1194. }
  1195. return;
  1196. }
  1197. if (m_selection.GetCount()<1) {
  1198. return;
  1199. }
  1200. CClientDC dc(this);
  1201. OnPrepareDC(&dc);
  1202. CPoint local = point;
  1203. dc.DPtoLP(&local);
  1204. if ( (g_nElementNo = POLYGON || g_nElementNo == ZHELINE ) && m_tempObj != NULL && m_bPolygon)
  1205. {
  1206. ((CDrawPoly*)m_tempObj)->AddPoint(local);
  1207. m_bPolygon = false;
  1208. ((CDrawPoly*)m_tempObj)->RecalcBounds();
  1209. CRect freshRect = m_tempObj->m_rect;
  1210. freshRect.NormalizeRect();
  1211. freshRect.InflateRect(4,4);
  1212. InvalidateRect(freshRect,FALSE);
  1213. m_tempObj = NULL;
  1214. g_nElementNo = 0;
  1215. }
  1216. else
  1217. {
  1218. if (m_selection.GetCount()>1)
  1219. {
  1220. COLORREF _clrFore; // 前景色
  1221. COLORREF _clrLine; // 线色
  1222. COLORREF _clrBack; // 背景色
  1223. COLORREF _clrFill; // 填充色
  1224. LOGFONT _logfont; // 字体
  1225. CString _strLineType; // 线型
  1226. int _nLineWidth; // 线宽
  1227. int _nFillMode; //填充類型
  1228. int nPosIndex=0;
  1229. POSITION pos = m_selection.GetHeadPosition();
  1230. while(pos != NULL)
  1231. {
  1232. CDrawObj* pObj = m_selection.GetNext(pos);
  1233. pObj->m_bModifyMore = TRUE;
  1234. if( nPosIndex==0 )
  1235. {
  1236. if ( pObj->OnAttrib() )
  1237. {
  1238. m_bModified = TRUE;
  1239. _clrFore = pObj->m_clrFore;
  1240. _clrLine = pObj->m_clrLine;
  1241. _clrBack = pObj->m_clrBack;
  1242. _clrFill = pObj->m_clrFill;
  1243. _logfont = pObj->m_logfont;
  1244. _strLineType = pObj->m_strLineType;
  1245. _nLineWidth = pObj->m_nLineWidth;
  1246. _nFillMode = pObj->m_nFillMode;
  1247. }
  1248. else
  1249. {
  1250. return;
  1251. }
  1252. }
  1253. else
  1254. {
  1255. pObj->m_clrFore = _clrFore;
  1256. pObj->m_clrLine = _clrLine;
  1257. pObj->m_clrBack = _clrBack;
  1258. pObj->m_clrFill = _clrFill;
  1259. pObj->m_logfont = _logfont;
  1260. pObj->m_strLineType = _strLineType;
  1261. pObj->m_nLineWidth = _nLineWidth;
  1262. pObj->m_nFillMode = _nFillMode;
  1263. }
  1264. CRect freshRect = pObj->m_rect;
  1265. freshRect.NormalizeRect();
  1266. freshRect.InflateRect(4,4);
  1267. InvalidateRect(freshRect,FALSE);
  1268. g_nElementNo = 0;
  1269. nPosIndex++;
  1270. }
  1271. }
  1272. else
  1273. {
  1274. POSITION pos = m_selection.GetHeadPosition();
  1275. CDrawObj *pObj = m_selection.GetNext(pos);
  1276. pObj->m_bModifyMore = FALSE;
  1277. if ( pObj->OnAttrib() )
  1278. m_bModified = TRUE;
  1279. CRect freshRect = pObj->m_rect;
  1280. freshRect.NormalizeRect();
  1281. freshRect.InflateRect(4,4);
  1282. InvalidateRect(freshRect,FALSE);
  1283. g_nElementNo = 0;
  1284. }
  1285. }
  1286. CScrollView::OnLButtonDblClk(nFlags, point);
  1287. }
  1288. // 判断是有效变量名
  1289. BOOL CIDEView::IsValidChar(char chr)
  1290. {
  1291. if ( chr >= '0' && chr <= '9')
  1292. return TRUE;
  1293. else if ((chr >= 'A' && chr <= 'Z') || (chr >= 'a' && chr <= 'z') )
  1294. return TRUE;
  1295. else if (chr == '_')
  1296. return TRUE;
  1297. else
  1298. return FALSE;
  1299. }
  1300. //从组合公式中找出变量名加入到画面结构中
  1301. CString CIDEView::GetVarNameFromGS( CString sGS )
  1302. {
  1303. //LOG4C((LOG_NOTICE, "GetVarFromGSAddToStruct sGS :%s", sGS));
  1304. //sGS = "(HG7053_DI10>=3)OR(HG7053_LinkStatus<=33)";
  1305. //sGS = "((HG7053_DI10>=3))";
  1306. //sGS = "(HG7053_DI10>=3)AND(HG7053_LinkStatus<=33)OR(HG7053_DI15<3)";
  1307. int nLen = sGS.GetLength();
  1308. int nPos1=0,nPos2=0;
  1309. int nPos3=0,nPos4=0;
  1310. CString sTemp,s1,s2,s3;
  1311. CString sGS2[10];
  1312. int nCount=0;
  1313. //OR AND NOT
  1314. for( int i=0;i<nLen;i++ )
  1315. {
  1316. if( sGS.Mid( i,2)=="OR" )
  1317. {
  1318. sGS2[nCount++] = sGS.Mid( nPos1,i-nPos1 );
  1319. nPos1 = i+2;
  1320. }
  1321. if( (sGS.Mid( i,3)=="AND" || sGS.Mid( i,3)=="NOT") )
  1322. {
  1323. sGS2[nCount++] = sGS.Mid( nPos1,i-nPos1 );
  1324. nPos1 = i+3;
  1325. }
  1326. }
  1327. if( nPos1<nLen )
  1328. {
  1329. sGS2[nCount++] = sGS.Mid( nPos1,nLen-nPos1 );
  1330. }
  1331. for( int iGSIndex=0;iGSIndex<nCount;iGSIndex++ )
  1332. {
  1333. nPos3=0;
  1334. nPos4=0;
  1335. nLen = sGS2[iGSIndex].GetLength();
  1336. if( !IsValidChar( sGS2[iGSIndex][0] ) )
  1337. {
  1338. if( IsValidChar( sGS2[iGSIndex][1] ) )
  1339. nPos3 = 1;
  1340. else
  1341. nPos3 = 2;
  1342. for( int i=nPos3;i<nLen;i++ )
  1343. {
  1344. if( !IsValidChar( sGS2[iGSIndex][i] ) )
  1345. {
  1346. nPos4 = i-0;
  1347. break;
  1348. }
  1349. }
  1350. sTemp = sGS2[iGSIndex].Mid( nPos3,nPos4-nPos3 );
  1351. }
  1352. else
  1353. {
  1354. for( int i=nPos3;i<nLen;i++ )
  1355. {
  1356. if( !IsValidChar( sGS2[iGSIndex][i] ) )
  1357. {
  1358. nPos4 = i-0;
  1359. break;
  1360. }
  1361. }
  1362. sTemp = sGS2[iGSIndex].Mid( nPos3,nPos4-nPos3 );
  1363. }
  1364. }
  1365. return sTemp;
  1366. }
  1367. CDrawObj * CIDEView::CreateDrawObjbyNo(int objNo)
  1368. {
  1369. if (objNo == TlineShape)
  1370. {
  1371. CDrawTLine * temp = new CDrawTLine();
  1372. temp->m_pView = this;
  1373. CDrawObj * ele = (CDrawObj *)temp;
  1374. return ele;
  1375. }
  1376. if (objNo == TextShape)
  1377. {
  1378. CDrawText * temp = new CDrawText();
  1379. temp->m_pView = this;
  1380. CDrawObj * ele = (CDrawObj *)temp;
  1381. return ele;
  1382. }
  1383. if (objNo == RectShape)
  1384. {
  1385. CDrawRect * temp = new CDrawRect();
  1386. temp->m_pView = this;
  1387. CDrawObj * ele = (CDrawObj *)temp;
  1388. return ele;
  1389. }
  1390. if (objNo == DataShape)
  1391. {
  1392. CDrawDatabox * temp = new CDrawDatabox();
  1393. temp->m_pView = this;
  1394. CDrawObj * ele = (CDrawObj *)temp;
  1395. return ele;
  1396. }
  1397. if (objNo == BUTTON)
  1398. {
  1399. CDrawButton * temp = new CDrawButton();
  1400. temp->m_pView = this;
  1401. CDrawObj * ele = (CDrawObj *)temp;
  1402. return ele;
  1403. }
  1404. if (objNo == ThreeDCircleShape)
  1405. {
  1406. CDraw3dCircle * temp = new CDraw3dCircle();
  1407. temp->m_pView = this;
  1408. CDrawObj * ele = (CDrawObj *)temp;
  1409. return ele;
  1410. }
  1411. if (objNo == RealCurveShape)
  1412. {
  1413. CDrawCurve * temp = new CDrawCurve();
  1414. temp->m_pView = this;
  1415. CDrawObj * ele = (CDrawObj *)temp;
  1416. return ele;
  1417. }
  1418. if (objNo == BarShape)
  1419. {
  1420. CDrawBar * temp = new CDrawBar();
  1421. temp->m_pView = this;
  1422. CDrawObj * ele = (CDrawObj *)temp;
  1423. return ele;
  1424. }
  1425. if (objNo == ELLIPSE)
  1426. {
  1427. CDrawOval * temp = new CDrawOval();
  1428. temp->m_pView = this;
  1429. CDrawObj * ele = (CDrawObj *)temp;
  1430. return ele;
  1431. }
  1432. if (objNo == LINE)
  1433. {
  1434. CDrawLine * temp = new CDrawLine();
  1435. temp->m_pView = this;
  1436. CDrawObj * ele = (CDrawObj *)temp;
  1437. return ele;
  1438. }
  1439. if (objNo == BREAKER)
  1440. {
  1441. CDrawBreaker * temp = new CDrawBreaker();
  1442. temp->m_pView = this;
  1443. CDrawObj * ele = (CDrawObj *)temp;
  1444. return ele;
  1445. }
  1446. if (objNo == SWITCH)
  1447. {
  1448. CDrawSwitch * temp = new CDrawSwitch();
  1449. temp->m_pView = this;
  1450. CDrawObj * ele = (CDrawObj *)temp;
  1451. return ele;
  1452. }
  1453. if (objNo == GRID)
  1454. {
  1455. CDrawGrid * temp = new CDrawGrid();
  1456. temp->m_pView = this;
  1457. CDrawObj * ele = (CDrawObj *)temp;
  1458. return ele;
  1459. }
  1460. if (objNo == BitmapShape)
  1461. {
  1462. CDrawBitmap * temp = new CDrawBitmap();
  1463. temp->m_pView = this;
  1464. CDrawObj * ele = (CDrawObj *)temp;
  1465. return ele;
  1466. }
  1467. if( objNo == GifShape )
  1468. {
  1469. CDrawGif* temp = new CDrawGif();
  1470. temp->m_pView = this;
  1471. CDrawObj* ele = (CDrawObj *)temp;
  1472. return ele;
  1473. }
  1474. if (objNo == TRANSFER)
  1475. {
  1476. CDrawTransfer * temp = new CDrawTransfer();
  1477. temp->m_pView = this;
  1478. CDrawObj * ele = (CDrawObj *)temp;
  1479. return ele;
  1480. }
  1481. if (objNo == ARC)
  1482. {
  1483. CDrawArc * temp = new CDrawArc();
  1484. temp->m_pView = this;
  1485. CDrawObj * ele = (CDrawObj *)temp;
  1486. return ele;
  1487. }
  1488. if (objNo == ARROW)
  1489. {
  1490. CDrawArrow * temp = new CDrawArrow();
  1491. temp->m_pView = this;
  1492. CDrawObj * ele = (CDrawObj *)temp;
  1493. return ele;
  1494. }
  1495. if (objNo == POLYGON)
  1496. {
  1497. CDrawPoly * temp = new CDrawPoly();
  1498. temp->m_pView = this;
  1499. CDrawObj * ele = (CDrawObj *)temp;
  1500. return ele;
  1501. }
  1502. if (objNo == ZHELINE)
  1503. {
  1504. CDrawMLine * temp = new CDrawMLine();
  1505. temp->m_pView = this;
  1506. CDrawObj * ele = (CDrawObj *)temp;
  1507. return ele;
  1508. }
  1509. if (objNo == PIPE)
  1510. {
  1511. CDrawPipe * temp = new CDrawPipe();
  1512. temp->m_pView = this;
  1513. CDrawObj * ele = (CDrawObj *)temp;
  1514. return ele;
  1515. }
  1516. if (objNo == ZHEPIPE)
  1517. {
  1518. CDrawZhePipe * temp = new CDrawZhePipe();
  1519. temp->m_pView = this;
  1520. CDrawObj * ele = (CDrawObj *)temp;
  1521. return ele;
  1522. }
  1523. if ( objNo == YPIPE)
  1524. {
  1525. CDrawYPipe * temp = new CDrawYPipe();
  1526. temp->m_pView = this;
  1527. CDrawObj * ele = (CDrawObj *)temp;
  1528. return ele;
  1529. }
  1530. if ( objNo == WatchShape)
  1531. {
  1532. CDrawWatch * temp = new CDrawWatch();
  1533. temp->m_pView = this;
  1534. CDrawObj * ele = (CDrawObj *)temp;
  1535. return ele;
  1536. }
  1537. if ( objNo == SINGLEBAR)
  1538. {
  1539. CDrawSingleBar * temp = new CDrawSingleBar();
  1540. temp->m_pView = this;
  1541. CDrawObj * ele = (CDrawObj *)temp;
  1542. return ele;
  1543. }
  1544. if ( objNo == ROUNDRECT )
  1545. {
  1546. CDrawRoundRect * temp = new CDrawRoundRect();
  1547. temp->m_pView = this;
  1548. CDrawObj * ele = (CDrawObj *)temp;
  1549. return ele;
  1550. }
  1551. if ( objNo == PIE )
  1552. {
  1553. CDrawPie* temp = new CDrawPie();
  1554. temp->m_pView = this;
  1555. CDrawObj * ele = (CDrawObj *)temp;
  1556. return ele;
  1557. }
  1558. if ( objNo == FAN )
  1559. {
  1560. CDrawFan* temp = new CDrawFan();
  1561. temp->m_pView = this;
  1562. CDrawObj * ele = (CDrawObj *)temp;
  1563. return ele;
  1564. }
  1565. if ( objNo == HISCurveShape )
  1566. {
  1567. CDrawHisCurve* temp = new CDrawHisCurve();
  1568. temp->m_pView = this;
  1569. CDrawObj * ele = (CDrawObj *)temp;
  1570. return ele;
  1571. }
  1572. if ( objNo == REPORT )
  1573. {
  1574. CDrawTable* temp = new CDrawTable();
  1575. temp->m_pView = this;
  1576. CDrawObj * ele = (CDrawObj *)temp;
  1577. return ele;
  1578. }
  1579. if ( objNo == OCX )
  1580. {
  1581. CDrawOCX* temp = new CDrawOCX();
  1582. temp->m_pView = this;
  1583. CDrawObj * ele = (CDrawObj *)temp;
  1584. return ele;
  1585. }
  1586. if ( objNo == GIF )
  1587. {
  1588. CDrawGif* temp = new CDrawGif();
  1589. temp->m_pView = this;
  1590. CDrawObj * ele = (CDrawObj *)temp;
  1591. return ele;
  1592. }
  1593. if ( objNo == FLASH )
  1594. {
  1595. CDrawFlash* temp = new CDrawFlash();
  1596. temp->m_pView = this;
  1597. CDrawObj * ele = (CDrawObj *)temp;
  1598. return ele;
  1599. }
  1600. //if ( objNo == FLASH )
  1601. //{
  1602. // CDrawFlash* temp = new CDrawFlash();
  1603. // temp->m_pView = this;
  1604. // CDrawObj * ele = (CDrawObj *)temp;
  1605. // return ele;
  1606. //}
  1607. return NULL;
  1608. }
  1609. void CIDEView::OnPointer()
  1610. {
  1611. g_nElementNo = 0;
  1612. }
  1613. void CIDEView::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
  1614. {
  1615. int n = nRepCnt;
  1616. BOOL bShiftDown = (GetKeyState(VK_SHIFT)&0xf0);
  1617. if(!bShiftDown)
  1618. {
  1619. if(GetKeyState(VK_CONTROL)&0xf0)
  1620. {
  1621. n *= 10;
  1622. }
  1623. }
  1624. switch(nChar)
  1625. {
  1626. case VK_UP:
  1627. if(bShiftDown) KeyMove(0,0,0,-n);
  1628. else KeyMove(0,-n,0,-n);
  1629. m_bModified = TRUE;
  1630. break;
  1631. case VK_DOWN:
  1632. if(bShiftDown) KeyMove(0,0,0,n);
  1633. else KeyMove(0,n,0,n);
  1634. m_bModified = TRUE;
  1635. break;
  1636. case VK_LEFT:
  1637. if(bShiftDown) KeyMove(0,0,-n,0);
  1638. else KeyMove(-n,0,-n,0);
  1639. m_bModified = TRUE;
  1640. break;
  1641. case VK_RIGHT:
  1642. if(bShiftDown) KeyMove(0,0,n,0);
  1643. else KeyMove(n,0,n,0);
  1644. m_bModified = TRUE;
  1645. break;
  1646. case VK_DELETE:
  1647. #if 0
  1648. POSITION pos = m_selection.GetHeadPosition();
  1649. while(pos != NULL)
  1650. {
  1651. CDrawObj *pObj = m_selection.GetNext(pos);
  1652. Remove(pObj);
  1653. delete pObj;
  1654. m_bModified = TRUE;
  1655. }
  1656. m_selection.RemoveAll();
  1657. #endif
  1658. for(POSITION pos = m_selection.GetHeadPosition();pos!=NULL;)
  1659. {
  1660. POSITION pos1 = pos ; //要在这里做一个备份
  1661. CDrawObj *pObj = m_selection.GetNext(pos);//他会改变 pos的值
  1662. Remove(pObj);
  1663. if( pObj != NULL )
  1664. {
  1665. delete pObj;
  1666. pObj = NULL;
  1667. }
  1668. //m_selection.RemoveAt(pos1);
  1669. m_bModified = TRUE;
  1670. }
  1671. m_selection.RemoveAll();
  1672. break;
  1673. }
  1674. Invalidate(FALSE);
  1675. CScrollView::OnKeyDown(nChar, nRepCnt, nFlags);
  1676. }
  1677. void CIDEView::KeyMove(int x1,int y1,int x2,int y2)
  1678. {
  1679. POSITION pos = m_selection.GetHeadPosition();
  1680. while(pos != NULL)
  1681. {
  1682. CDrawObj* pObj = m_selection.GetNext(pos);
  1683. CRect rect = pObj->m_rect;
  1684. if(rect.left<rect.right)
  1685. {
  1686. rect.left += x1;
  1687. rect.right += x2;
  1688. }
  1689. else
  1690. {
  1691. rect.left += x2;
  1692. rect.right += x1;
  1693. }
  1694. if(rect.top<rect.bottom)
  1695. {
  1696. rect.top += y1;
  1697. rect.bottom += y2;
  1698. }
  1699. else
  1700. {
  1701. rect.top += y2;
  1702. rect.bottom += y1;
  1703. }
  1704. pObj->MoveTo(rect);
  1705. m_bModified = TRUE;
  1706. }
  1707. }
  1708. CDrawObj* CIDEView::ObjectAt(CPoint point)
  1709. {
  1710. CRect rect(point, CSize(1, 1));
  1711. POSITION pos = m_pGraph->m_DrawObjList.GetTailPosition();
  1712. while(pos != NULL)
  1713. {
  1714. CDrawObj* pObj = m_pGraph->m_DrawObjList.GetPrev(pos);
  1715. if( pObj->Intersects(rect) && pObj->m_bShow )
  1716. return pObj;
  1717. }
  1718. return NULL;
  1719. }
  1720. BOOL CIDEView::IsSelected(CDrawObj* pDrawObj)
  1721. {
  1722. return m_selection.Find((CObject *)pDrawObj) != NULL;
  1723. }
  1724. void CIDEView::Select(CDrawObj* pObj, BOOL bAdd)
  1725. {
  1726. if(!bAdd)
  1727. {
  1728. POSITION pos = m_selection.GetHeadPosition();
  1729. while(pos != NULL)
  1730. {
  1731. CDrawObj* pObj = m_selection.GetNext(pos);
  1732. pObj->Invalidate();
  1733. }
  1734. m_selection.RemoveAll();
  1735. }
  1736. if(pObj == NULL||IsSelected(pObj)) return;
  1737. {
  1738. m_selection.AddTail(pObj);
  1739. pObj->Invalidate();
  1740. }
  1741. }
  1742. void CIDEView::Remove(CDrawObj* pObj)
  1743. {
  1744. POSITION pos;
  1745. pos = m_selection.Find(pObj);
  1746. if(pos != NULL) m_selection.RemoveAt(pos);
  1747. pos = m_pGraph->m_DrawObjList.Find(pObj);
  1748. if(pos != NULL) m_pGraph->m_DrawObjList.RemoveAt(pos);
  1749. m_bModified = TRUE;
  1750. }
  1751. void CIDEView::OnFileNew()
  1752. {
  1753. if(m_bModified)
  1754. {
  1755. if(MessageBox(g_strSaveModify,g_strSelect,MB_YESNO|MB_ICONQUESTION) == IDYES)
  1756. OnFileSave();
  1757. }
  1758. m_selection.RemoveAll();
  1759. m_freezed.RemoveAll();
  1760. m_pGraph->SetPicFile("");
  1761. m_pGraph->Load();
  1762. Invalidate(FALSE);
  1763. POINT point;
  1764. point.x = 0;
  1765. point.y = 0;
  1766. ScrollToPosition(point);
  1767. m_bModified = TRUE;
  1768. }
  1769. void CIDEView::OnFileOpen()
  1770. {
  1771. if(m_bModified)
  1772. {
  1773. if(MessageBox(g_strSaveModify,g_strSelect,MB_YESNO|MB_ICONQUESTION) == IDYES)
  1774. OnFileSave();
  1775. }
  1776. DWORD dwFlags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT;
  1777. CString strFindPicFile = "";
  1778. LPSTR lpszFile = (char*)(const char*)strFindPicFile;
  1779. LPSTR lpszFilter = (char *)(LPCTSTR)g_strPictureFile2;
  1780. CFileDialog dlg(TRUE,".view",lpszFile,dwFlags,lpszFilter);
  1781. if(dlg.DoModal() == IDOK)
  1782. {
  1783. m_selection.RemoveAll();
  1784. m_freezed.RemoveAll();
  1785. CString strPicFile = dlg.GetPathName();
  1786. ASSERT(!strPicFile.IsEmpty());
  1787. m_pGraph->SetPicFile(strPicFile);
  1788. m_pGraph->Load();
  1789. //应该保存
  1790. char tmpPathc[_MAX_PATH+1];
  1791. GetTempPath(_MAX_PATH,tmpPathc);
  1792. CString tmpPath = tmpPathc;
  1793. CString oldFile = m_pGraph->m_strPicFile;
  1794. m_pGraph->m_strPicFile = _T(tmpPath+"\\VDTemp\\"+"\\first.ed");
  1795. m_pGraph->Store();
  1796. m_pGraph->m_strPicFile = oldFile;
  1797. RefreshScrollSizes();
  1798. POINT point;
  1799. point.x = 0;
  1800. point.y = 0;
  1801. ScrollToPosition(point);
  1802. m_bModified = FALSE;
  1803. }
  1804. }
  1805. void CIDEView::OnFileSave()
  1806. {
  1807. if(m_pGraph->m_strPicFile.IsEmpty())
  1808. OnFileSaveAs();
  1809. else
  1810. {
  1811. CRect rect = CRect(CPoint(0,0),m_pGraph->m_sizePic);
  1812. POSITION pos = m_pGraph->m_DrawObjList.GetHeadPosition();
  1813. while(pos != NULL)
  1814. {
  1815. CDrawObj *pObj = m_pGraph->m_DrawObjList.GetNext(pos);
  1816. CRect r = pObj->m_rect;
  1817. r.NormalizeRect();
  1818. if((r & rect).IsRectEmpty())
  1819. {
  1820. Remove(pObj);
  1821. delete pObj;
  1822. }
  1823. }
  1824. m_pGraph->Store();
  1825. m_bModified = FALSE;
  1826. }
  1827. }
  1828. void CIDEView::FileSave()
  1829. {
  1830. if(m_pGraph->m_strPicFile.IsEmpty())
  1831. OnFileSaveAs();
  1832. else
  1833. {
  1834. CRect rect = CRect(CPoint(0,0),m_pGraph->m_sizePic);
  1835. POSITION pos = m_pGraph->m_DrawObjList.GetHeadPosition();
  1836. while(pos != NULL)
  1837. {
  1838. CDrawObj *pObj = m_pGraph->m_DrawObjList.GetNext(pos);
  1839. CRect r = pObj->m_rect;
  1840. r.NormalizeRect();
  1841. if((r & rect).IsRectEmpty())
  1842. {
  1843. Remove(pObj);
  1844. delete pObj;
  1845. }
  1846. }
  1847. m_pGraph->Store();
  1848. m_bModified = FALSE;
  1849. }
  1850. }
  1851. void CIDEView::OnFileSaveAs()
  1852. {
  1853. DWORD dwFlags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT;
  1854. CString strFindPicFile = "";
  1855. LPSTR lpszFile = (char*)(const char*)strFindPicFile;
  1856. LPSTR lpszFilter = (char *)(LPCTSTR)g_strPictureFile2;
  1857. CFileDialog dlg(FALSE,".view",lpszFile,dwFlags,lpszFilter);
  1858. if(dlg.DoModal() == IDOK)
  1859. {
  1860. CString strPicFile = dlg.GetPathName();
  1861. ASSERT(!strPicFile.IsEmpty());
  1862. m_pGraph->SetPicFile(strPicFile);
  1863. OnFileSave();
  1864. }
  1865. }
  1866. void CIDEView::RefreshScrollSizes(void)
  1867. {
  1868. CSize sizeTotal = m_pGraph->m_sizePic;
  1869. CSize sizePage = CSize(200,200);
  1870. CSize sizeLine = CSize(10,10);
  1871. SetScrollSizes(MM_TEXT,sizeTotal,sizePage,sizeLine);
  1872. Invalidate(FALSE);
  1873. }
  1874. void CIDEView::OnAppExit()
  1875. {
  1876. if(m_bModified)
  1877. {
  1878. if(MessageBox(g_strSaveModify,g_strSelect,MB_YESNO|MB_ICONQUESTION) == IDYES)
  1879. OnFileSave();
  1880. }
  1881. CMainFrame *pMainFrm=(CMainFrame*)AfxGetApp()->m_pMainWnd;
  1882. pMainFrm->OnSuperEnd();
  1883. }
  1884. CRect CIDEView::GetAlignRect(void)
  1885. {
  1886. CDrawObj* pObj = m_selection.GetTail();
  1887. CRect rect = pObj->m_rect;
  1888. rect.NormalizeRect();
  1889. return rect;
  1890. }
  1891. void CIDEView::OnPrint(CDC* pDC, CPrintInfo* pInfo)
  1892. {
  1893. CString sTemp;
  1894. int nTemp=0;
  1895. if(m_pGraph->m_Type == 0)
  1896. {
  1897. int nOffsetX = pDC->GetDeviceCaps(PHYSICALOFFSETX);
  1898. int nOffsetY = pDC->GetDeviceCaps(PHYSICALOFFSETY);
  1899. int nLogPixelX = pDC->GetDeviceCaps(LOGPIXELSX);
  1900. int nLogPixelY = pDC->GetDeviceCaps(LOGPIXELSY);
  1901. pDC->SetMapMode(MM_ISOTROPIC);
  1902. pDC->SetWindowExt(100,100);
  1903. pDC->SetViewportExt(nLogPixelX,nLogPixelY);
  1904. pDC->SetViewportOrg(-nOffsetX,-nOffsetY);
  1905. m_pGraph->Draw(pDC,sTemp,nTemp);
  1906. }
  1907. else
  1908. {
  1909. CSize size = m_pGraph->m_sizePic;
  1910. int nHScale = pInfo->m_rectDraw.Width() / size.cx;
  1911. int nVScale = pInfo->m_rectDraw.Height() / size.cy;
  1912. int nScale = min(nHScale,nVScale);
  1913. pDC->SetMapMode(MM_ISOTROPIC);
  1914. pDC->SetWindowExt(1000,1000);
  1915. pDC->SetViewportExt(1000*nScale,1000*nScale);
  1916. int nHOffset = pInfo->m_rectDraw.Width() - nScale*size.cx;
  1917. int nVOffset = pInfo->m_rectDraw.Height() - nScale*size.cy;
  1918. pDC->SetViewportOrg(nHOffset/2,nVOffset/2);
  1919. m_pGraph->Print(pDC);
  1920. }
  1921. }
  1922. void CIDEView::OnUpdateDeskGrid(CCmdUI* pCmdUI)
  1923. {
  1924. if ( g_bRun ) {
  1925. pCmdUI->Enable(FALSE);
  1926. }
  1927. else
  1928. pCmdUI->Enable(TRUE);
  1929. pCmdUI->SetCheck(m_pGraph->m_bGrid);
  1930. }
  1931. void CIDEView::OnUpdateEditFreeze(CCmdUI* pCmdUI)
  1932. {
  1933. pCmdUI->SetCheck(m_bFreezed);
  1934. }
  1935. //选出载鼠标拖动区域的图元
  1936. void CIDEView::ObjectIn()
  1937. {
  1938. POSITION pos = m_pGraph->m_DrawObjList.GetTailPosition();
  1939. while(pos != NULL)
  1940. {
  1941. CDrawObj* pObj = m_pGraph->m_DrawObjList.GetPrev(pos);
  1942. CRect r = pObj->m_rect;
  1943. r.NormalizeRect();
  1944. if ((r.left>m_mouseRect.left)&&(r.right<m_mouseRect.right)
  1945. &&(r.bottom<m_mouseRect.bottom)&&(r.top>m_mouseRect.top))
  1946. m_selection.AddTail(pObj);
  1947. }
  1948. }
  1949. //用作do/redo的
  1950. void CIDEView::ExchangeSave()
  1951. {
  1952. char tmpPathc[_MAX_PATH+1];
  1953. GetTempPath(_MAX_PATH,tmpPathc);
  1954. CString tmpPath = tmpPathc;
  1955. CFile::Remove(_T(tmpPath+"\\VDTemp\\"+"\\Six.ed"));
  1956. CFile::Rename(_T(tmpPath+"\\VDTemp\\"+"\\Fifth.ed"),_T(tmpPath+"\\VDTemp\\"+"\\Six.ed"));
  1957. CFile::Rename(_T(tmpPath+"\\VDTemp\\"+"\\Forth.ed"),_T(tmpPath+"\\VDTemp\\"+"\\Fifth.ed"));
  1958. CFile::Rename(_T(tmpPath+"\\VDTemp\\"+"\\Third.ed"),_T(tmpPath+"\\VDTemp\\"+"\\Forth.ed"));
  1959. CFile::Rename(_T(tmpPath+"\\VDTemp\\"+"\\Second.ed"),_T(tmpPath+"\\VDTemp\\"+"\\Third.ed"));
  1960. CFile::Rename(_T(tmpPath+"\\VDTemp\\"+"\\First.ed"),_T(tmpPath+"\\VDTemp\\"+"\\Second.ed"));
  1961. CString oldFile = m_pGraph->m_strPicFile;
  1962. m_pGraph->m_strPicFile = _T(tmpPath+"\\VDTemp\\"+"\\First.ed");
  1963. m_pGraph->Store();
  1964. m_pGraph->m_strPicFile = oldFile;
  1965. }
  1966. void CIDEView::OnRedo() // 重做;
  1967. {
  1968. POSITION pos = m_selection.GetHeadPosition();
  1969. while(pos != NULL)
  1970. {
  1971. CDrawObj* pObj = m_selection.GetNext(pos);
  1972. pObj->Invalidate();
  1973. }
  1974. m_selection.RemoveAll();
  1975. char tmpPathc[_MAX_PATH+1];
  1976. GetTempPath(_MAX_PATH,tmpPathc);
  1977. CString tmpPath = tmpPathc;
  1978. CString oldFile = m_pGraph->m_strPicFile;
  1979. if (m_nRudoPosition == -1)
  1980. m_pGraph->m_strPicFile = _T(tmpPath+"\\VDTemp\\"+"\\first.ed");
  1981. else if (m_nRudoPosition == -2)
  1982. m_pGraph->m_strPicFile = _T(tmpPath+"\\VDTemp\\"+"\\second.ed");
  1983. else if (m_nRudoPosition == -3)
  1984. m_pGraph->m_strPicFile = _T(tmpPath+"\\VDTemp\\"+"\\third.ed");
  1985. else if (m_nRudoPosition == -4)
  1986. m_pGraph->m_strPicFile = _T(tmpPath+"\\VDTemp\\"+"\\forth.ed");
  1987. else if (m_nRudoPosition == -5)
  1988. m_pGraph->m_strPicFile = _T(tmpPath+"\\VDTemp\\"+"\\fifth.ed");
  1989. else
  1990. return;
  1991. m_pGraph->Load();
  1992. m_pGraph->m_strPicFile = oldFile;
  1993. m_nRudoPosition++;
  1994. m_nCanUndoTimes++;
  1995. m_nCanRedoTimes--;
  1996. Invalidate(FALSE);
  1997. }
  1998. void CIDEView::OnUndo() // 撤销;
  1999. {
  2000. POSITION pos = m_selection.GetHeadPosition();
  2001. while(pos != NULL)
  2002. {
  2003. CDrawObj* pObj = m_selection.GetNext(pos);
  2004. pObj->Invalidate();
  2005. }
  2006. m_selection.RemoveAll();
  2007. char tmpPathc[_MAX_PATH+1];
  2008. GetTempPath(_MAX_PATH,tmpPathc);
  2009. CString tmpPath = tmpPathc;
  2010. CString oldFile = m_pGraph->m_strPicFile;
  2011. if (m_nRudoPosition == 0)
  2012. m_pGraph->m_strPicFile = _T(tmpPath+"\\VDTemp\\"+"\\second.ed");
  2013. if (m_nRudoPosition == -1)
  2014. m_pGraph->m_strPicFile = _T(tmpPath+"\\VDTemp\\"+"\\third.ed");
  2015. if (m_nRudoPosition == -2)
  2016. m_pGraph->m_strPicFile = _T(tmpPath+"\\VDTemp\\"+"\\forth.ed");
  2017. if (m_nRudoPosition == -3)
  2018. m_pGraph->m_strPicFile = _T(tmpPath+"\\VDTemp\\"+"\\fifth.ed");
  2019. if (m_nRudoPosition == -4)
  2020. m_pGraph->m_strPicFile = _T(tmpPath+"\\VDTemp\\"+"\\six.ed");
  2021. if(m_nRudoPosition == -5) return;
  2022. m_pGraph->Load();
  2023. m_pGraph->m_strPicFile = oldFile;
  2024. m_nRudoPosition--;
  2025. m_nCanUndoTimes--;
  2026. m_nCanRedoTimes++;
  2027. Invalidate(FALSE);
  2028. }
  2029. void CIDEView::FileProcess()
  2030. {
  2031. char tmpPathc[_MAX_PATH+1];
  2032. GetTempPath(_MAX_PATH,tmpPathc);
  2033. CString tmpPath = tmpPathc;
  2034. if(m_nRudoPosition == -1)
  2035. {
  2036. CString oldFile = m_pGraph->m_strPicFile;
  2037. m_pGraph->m_strPicFile = _T(tmpPath+"\\VDTemp\\"+"\\first.ed");
  2038. m_pGraph->Store();
  2039. m_pGraph->m_strPicFile = oldFile;
  2040. }
  2041. if(m_nRudoPosition == -2)
  2042. {
  2043. CFile::Remove(_T(tmpPath+"\\VDTemp\\"+"\\Second.ed"));
  2044. CFile::Rename(_T(tmpPath+"\\VDTemp\\"+"\\Third.ed"),_T(tmpPath+"\\VDTemp\\"+"\\second.ed"));
  2045. CFile::Rename(_T(tmpPath+"\\VDTemp\\"+"\\Forth.ed"),_T(tmpPath+"\\VDTemp\\"+"\\third.ed"));
  2046. CFile::Rename(_T(tmpPath+"\\VDTemp\\"+"\\Fifth.ed"),_T(tmpPath+"\\VDTemp\\"+"\\forth.ed"));
  2047. CFile::Rename(_T(tmpPath+"\\VDTemp\\"+"\\Six.ed"),_T(tmpPath+"\\VDTemp\\"+"\\fifth.ed"));
  2048. CFile file6(_T(tmpPath+"\\VDTemp\\"+"\\Six.ed"),CFile::modeReadWrite|CFile::modeCreate);
  2049. file6.Close();
  2050. CString oldFile = m_pGraph->m_strPicFile;
  2051. if (m_nRudoPosition == 0)
  2052. m_pGraph->m_strPicFile = _T(tmpPath+"\\VDTemp\\"+"\\first.ed");
  2053. m_pGraph->Store();
  2054. m_pGraph->m_strPicFile = oldFile;
  2055. }
  2056. if(m_nRudoPosition == -3)
  2057. {
  2058. CFile::Remove(_T(tmpPath+"\\VDTemp\\"+"\\Second.ed"));
  2059. CFile::Remove(_T(tmpPath+"\\VDTemp\\"+"\\Third.ed"));
  2060. CFile::Rename(_T(tmpPath+"\\VDTemp\\"+"\\Forth.ed"),_T(tmpPath+"\\VDTemp\\"+"\\second.ed"));
  2061. CFile::Rename(_T(tmpPath+"\\VDTemp\\"+"\\Fifth.ed"),_T(tmpPath+"\\VDTemp\\"+"\\third.ed"));
  2062. CFile::Rename(_T(tmpPath+"\\VDTemp\\"+"\\Six.ed"),_T(tmpPath+"\\VDTemp\\"+"\\forth.ed"));
  2063. CFile file6(_T(tmpPath+"\\VDTemp\\"+"\\Six.ed"),CFile::modeReadWrite|CFile::modeCreate);
  2064. file6.Close();
  2065. CFile file5(_T(tmpPath+"\\VDTemp\\"+"\\fifth.ed"),CFile::modeReadWrite|CFile::modeCreate);
  2066. file5.Close();
  2067. CString oldFile = m_pGraph->m_strPicFile;
  2068. if (m_nRudoPosition == 0)
  2069. m_pGraph->m_strPicFile = _T(tmpPath+"\\VDTemp\\"+"\\first.ed");
  2070. m_pGraph->Store();
  2071. m_pGraph->m_strPicFile = oldFile;
  2072. }
  2073. if(m_nRudoPosition == -4)
  2074. {
  2075. CFile::Remove(_T(tmpPath+"\\VDTemp\\"+"\\Second.ed"));
  2076. CFile::Remove(_T(tmpPath+"\\VDTemp\\"+"\\third.ed"));
  2077. CFile::Remove(_T(tmpPath+"\\VDTemp\\"+"\\Forth.ed"));
  2078. CFile::Rename(_T(tmpPath+"\\VDTemp\\"+"\\fifth.ed"),_T(tmpPath+"\\VDTemp\\"+"\\second.ed"));
  2079. CFile::Rename(_T(tmpPath+"\\VDTemp\\"+"\\six.ed"),_T(tmpPath+"\\VDTemp\\"+"\\third.ed"));
  2080. CFile::Rename(_T(tmpPath+"\\VDTemp\\"+"\\Fifth.ed"),_T(tmpPath+"\\VDTemp\\"+"\\forth.ed"));
  2081. CFile::Rename(_T(tmpPath+"\\VDTemp\\"+"\\Six.ed"),_T(tmpPath+"\\VDTemp\\"+"\\fifth.ed"));
  2082. CFile file4(_T(tmpPath+"\\VDTemp\\"+"\\forth.ed"),CFile::modeReadWrite|CFile::modeCreate);
  2083. file4.Close();
  2084. CFile file6(_T(tmpPath+"\\VDTemp\\"+"\\Six.ed"),CFile::modeReadWrite|CFile::modeCreate);
  2085. file6.Close();
  2086. CFile file5(_T(tmpPath+"\\VDTemp\\"+"\\fifth.ed"),CFile::modeReadWrite|CFile::modeCreate);
  2087. file5.Close();
  2088. CString oldFile = m_pGraph->m_strPicFile;
  2089. if (m_nRudoPosition == 0)
  2090. m_pGraph->m_strPicFile = _T(tmpPath+"\\VDTemp\\"+"\\first.ed");
  2091. m_pGraph->Store();
  2092. m_pGraph->m_strPicFile = oldFile;
  2093. }
  2094. if(m_nRudoPosition == -5)
  2095. {
  2096. CFile::Remove(_T(tmpPath+"\\VDTemp\\"+"\\Second.ed"));
  2097. CFile::Remove(_T(tmpPath+"\\VDTemp\\"+"\\third.ed"));
  2098. CFile::Remove(_T(tmpPath+"\\VDTemp\\"+"\\Forth.ed"));
  2099. CFile::Remove(_T(tmpPath+"\\VDTemp\\"+"\\fifth.ed"));
  2100. CFile::Rename(_T(tmpPath+"\\VDTemp\\"+"\\six.ed"),_T(tmpPath+"\\VDTemp\\"+"\\second.ed"));
  2101. CFile file4(_T(tmpPath+"\\VDTemp\\"+"\\forth.ed"),CFile::modeReadWrite|CFile::modeCreate);
  2102. file4.Close();
  2103. CFile file6(_T(tmpPath+"\\VDTemp\\"+"\\Six.ed"),CFile::modeReadWrite|CFile::modeCreate);
  2104. file6.Close();
  2105. CFile file5(_T(tmpPath+"\\VDTemp\\"+"\\fifth.ed"),CFile::modeReadWrite|CFile::modeCreate);
  2106. file5.Close();
  2107. CFile file3(_T(tmpPath+"\\VDTemp\\"+"\\third.ed"),CFile::modeReadWrite|CFile::modeCreate);
  2108. file3.Close();
  2109. CString oldFile = m_pGraph->m_strPicFile;
  2110. if (m_nRudoPosition == 0)
  2111. m_pGraph->m_strPicFile = _T(tmpPath+"\\VDTemp\\"+"\\first.ed");
  2112. m_pGraph->Store();
  2113. m_pGraph->m_strPicFile = oldFile;
  2114. }
  2115. }
  2116. void CIDEView::OnUpdateUndo(CCmdUI* pCmdUI)
  2117. {
  2118. if (g_bRun == FALSE && m_nCanUndoTimes) {
  2119. pCmdUI->Enable(TRUE);
  2120. }
  2121. else
  2122. pCmdUI->Enable(FALSE);
  2123. }
  2124. void CIDEView::OnUpdateRedo(CCmdUI* pCmdUI)
  2125. {
  2126. if (g_bRun == FALSE && m_nCanRedoTimes) {
  2127. pCmdUI->Enable(TRUE);
  2128. }
  2129. else
  2130. pCmdUI->Enable(FALSE);
  2131. }
  2132. void CIDEView::OnPicsize()
  2133. {
  2134. CPicSizeDlg dlg;
  2135. dlg.m_nPictureHeight = m_pGraph->m_sizePic.cy;
  2136. dlg.m_nPictureWidth = m_pGraph->m_sizePic.cx;
  2137. dlg.m_nGridSize = m_pGraph->m_sizeGrid.cx;
  2138. dlg.m_clrBack = m_pGraph->m_clrBack;
  2139. dlg.m_bGrid = m_pGraph->m_bGrid;
  2140. if(dlg.DoModal() == IDOK)
  2141. {
  2142. m_pGraph->m_sizePic.cy = dlg.m_nPictureHeight;
  2143. m_pGraph->m_sizePic.cx = dlg.m_nPictureWidth;
  2144. m_pGraph->m_sizeGrid.cy = dlg.m_nGridSize;
  2145. m_pGraph->m_sizeGrid.cx = dlg.m_nGridSize;
  2146. m_pGraph->m_clrBack = dlg.m_clrBack;
  2147. m_pGraph->m_bGrid = dlg.m_bGrid;
  2148. m_bModified = TRUE;
  2149. }
  2150. RefreshScrollSizes();
  2151. }
  2152. void CIDEView::OnUpdateAlignBottom(CCmdUI* pCmdUI)
  2153. {
  2154. if((m_selection.GetCount()>1))
  2155. pCmdUI->Enable(TRUE);
  2156. else
  2157. pCmdUI->Enable(FALSE);
  2158. }
  2159. void CIDEView::OnUpdateAlignHcenter(CCmdUI* pCmdUI)
  2160. {
  2161. if((m_selection.GetCount()>1))
  2162. pCmdUI->Enable(TRUE);
  2163. else
  2164. pCmdUI->Enable(FALSE);
  2165. }
  2166. void CIDEView::OnUpdateAlignLeft(CCmdUI* pCmdUI)
  2167. {
  2168. if((m_selection.GetCount()>1))
  2169. pCmdUI->Enable(TRUE);
  2170. else
  2171. pCmdUI->Enable(FALSE);
  2172. }
  2173. void CIDEView::OnUpdateAlignRight(CCmdUI* pCmdUI)
  2174. {
  2175. if((m_selection.GetCount()>1))
  2176. pCmdUI->Enable(TRUE);
  2177. else
  2178. pCmdUI->Enable(FALSE);
  2179. }
  2180. void CIDEView::OnUpdateAlignTop(CCmdUI* pCmdUI)
  2181. {
  2182. if((m_selection.GetCount()>1))
  2183. pCmdUI->Enable(TRUE);
  2184. else
  2185. pCmdUI->Enable(FALSE);
  2186. }
  2187. void CIDEView::OnUpdateAlignVcenter(CCmdUI* pCmdUI)
  2188. {
  2189. if((m_selection.GetCount()>1))
  2190. pCmdUI->Enable(TRUE);
  2191. else
  2192. pCmdUI->Enable(FALSE);
  2193. }
  2194. void CIDEView::OnUpdateEditHinvert(CCmdUI* pCmdUI)
  2195. {
  2196. if((m_selection.GetCount()>0))
  2197. pCmdUI->Enable(TRUE);
  2198. else
  2199. pCmdUI->Enable(FALSE);
  2200. }
  2201. void CIDEView::OnUpdateEditMovetoback(CCmdUI* pCmdUI)
  2202. {
  2203. if((m_selection.GetCount()>0))
  2204. pCmdUI->Enable(TRUE);
  2205. else
  2206. pCmdUI->Enable(FALSE);
  2207. }
  2208. void CIDEView::OnUpdateEditMovetofront(CCmdUI* pCmdUI)
  2209. {
  2210. if((m_selection.GetCount()>0))
  2211. pCmdUI->Enable(TRUE);
  2212. else
  2213. pCmdUI->Enable(FALSE);
  2214. }
  2215. void CIDEView::OnUpdateEditVinvert(CCmdUI* pCmdUI)
  2216. {
  2217. if((m_selection.GetCount()>0))
  2218. pCmdUI->Enable(TRUE);
  2219. else
  2220. pCmdUI->Enable(FALSE);
  2221. }
  2222. void CIDEView::OnUpdateEditCopy(CCmdUI* pCmdUI)
  2223. {
  2224. if(m_selection.GetCount()>0)
  2225. pCmdUI->Enable(TRUE);
  2226. else
  2227. pCmdUI->Enable(FALSE);
  2228. }
  2229. void CIDEView::OnUpdateEditCut(CCmdUI* pCmdUI)
  2230. {
  2231. if(m_selection.GetCount()>0)
  2232. pCmdUI->Enable(TRUE);
  2233. else
  2234. pCmdUI->Enable(FALSE);
  2235. }
  2236. void CIDEView::OnUpdateEditClear(CCmdUI* pCmdUI)
  2237. {
  2238. if(m_selection.GetCount()>0)
  2239. pCmdUI->Enable(TRUE);
  2240. else
  2241. pCmdUI->Enable(FALSE);
  2242. }
  2243. void CIDEView::OnUpdateEditPaste(CCmdUI* pCmdUI)
  2244. {
  2245. #if 1
  2246. if(g_Copied.GetCount()>0)
  2247. pCmdUI->Enable(TRUE);
  2248. else
  2249. pCmdUI->Enable(FALSE);
  2250. #else
  2251. if(m_copied.GetCount()>0)
  2252. pCmdUI->Enable(TRUE);
  2253. else
  2254. pCmdUI->Enable(FALSE);
  2255. #endif
  2256. }
  2257. void CIDEView::OnDrawTline()
  2258. {
  2259. g_nElementNo = TlineShape;
  2260. }
  2261. void CIDEView::OnDrawText()
  2262. {
  2263. g_nElementNo = TextShape;
  2264. }
  2265. void CIDEView::OnDrawRect()
  2266. {
  2267. g_nElementNo = RectShape;
  2268. }
  2269. void CIDEView::OnDrawData()
  2270. {
  2271. g_nElementNo = DataShape;
  2272. }
  2273. void CIDEView::OnDrawBitmap()
  2274. {
  2275. g_nElementNo = BitmapShape;
  2276. }
  2277. void CIDEView::OnDrawCurve()
  2278. {
  2279. g_nElementNo = RealCurveShape;
  2280. }
  2281. void CIDEView::OnDrawWatch()
  2282. {
  2283. g_nElementNo = WatchShape;
  2284. }
  2285. void CIDEView::OnDrawBar()
  2286. {
  2287. g_nElementNo = BarShape;
  2288. }
  2289. void CIDEView::OnDraw3drect()
  2290. {
  2291. g_nElementNo = BUTTON;
  2292. }
  2293. void CIDEView::OnDraw3circle()
  2294. {
  2295. g_nElementNo = ThreeDCircleShape;
  2296. }
  2297. void CIDEView::OnDrawOCX()
  2298. {
  2299. g_nElementNo = OCX;
  2300. }
  2301. void CIDEView::OnDrawGIF()
  2302. {
  2303. g_nElementNo = GIF;
  2304. }
  2305. void CIDEView::OnDrawFlash()
  2306. {
  2307. g_nElementNo = FLASH;
  2308. }
  2309. void CIDEView::OnUpdatePointer(CCmdUI* pCmdUI)
  2310. {
  2311. if(g_nElementNo == 0)
  2312. pCmdUI->SetCheck(TRUE);
  2313. else
  2314. pCmdUI->SetCheck(FALSE);
  2315. }
  2316. void CIDEView::ChangeView()
  2317. {
  2318. if(g_strViewName != "")
  2319. {
  2320. if(m_bModified && !g_bStartRun )
  2321. {
  2322. if(MessageBox(g_strSaveModify,g_strSelect,MB_YESNO|MB_ICONQUESTION) == IDYES)
  2323. OnFileSave();
  2324. }
  2325. m_selection.RemoveAll();
  2326. m_freezed.RemoveAll();
  2327. m_pGraph->SetPicFile(g_strViewName);
  2328. m_pGraph->Load();
  2329. m_pGraph->SetView(this);
  2330. m_pCurActionObj = NULL;
  2331. m_nCurActionType = -1;
  2332. Invalidate(FALSE);
  2333. RefreshScrollSizes();
  2334. POINT point;
  2335. point.x = 0;
  2336. point.y = 0;
  2337. ScrollToPosition(point);
  2338. m_bModified = FALSE;
  2339. }
  2340. }
  2341. void CIDEView::OnTimer(UINT nIDEvent)
  2342. {
  2343. if (g_bRun)
  2344. {
  2345. #if VIEW_USE_THREAD
  2346. #else
  2347. if( m_pGraph )
  2348. {
  2349. m_pGraph->Fresh();
  2350. //Invalidate(FALSE);//chn 刷新
  2351. }
  2352. #endif
  2353. }
  2354. CScrollView::OnTimer(nIDEvent);
  2355. }
  2356. void CIDEView::OnUpdateDraw3circle(CCmdUI* pCmdUI)
  2357. {
  2358. if (g_bRun == TRUE) {
  2359. pCmdUI->Enable(FALSE);
  2360. }
  2361. else
  2362. pCmdUI->Enable(TRUE);
  2363. }
  2364. void CIDEView::OnUpdateDraw3drect(CCmdUI* pCmdUI)
  2365. {
  2366. if (g_bRun == TRUE) {
  2367. pCmdUI->Enable(FALSE);
  2368. }
  2369. else
  2370. pCmdUI->Enable(TRUE);
  2371. }
  2372. void CIDEView::OnUpdateDrawData(CCmdUI* pCmdUI)
  2373. {
  2374. if (g_bRun == TRUE) {
  2375. pCmdUI->Enable(FALSE);
  2376. }
  2377. else
  2378. pCmdUI->Enable(TRUE);
  2379. }
  2380. void CIDEView::OnUpdateDrawRect(CCmdUI* pCmdUI)
  2381. {
  2382. if (g_bRun == TRUE) {
  2383. pCmdUI->Enable(FALSE);
  2384. }
  2385. else
  2386. pCmdUI->Enable(TRUE);
  2387. }
  2388. void CIDEView::OnUpdateDrawText(CCmdUI* pCmdUI)
  2389. {
  2390. if (g_bRun == TRUE) {
  2391. pCmdUI->Enable(FALSE);
  2392. }
  2393. else
  2394. pCmdUI->Enable(TRUE);
  2395. }
  2396. void CIDEView::OnUpdateDrawTline(CCmdUI* pCmdUI)
  2397. {
  2398. if (g_bRun == TRUE) {
  2399. pCmdUI->Enable(FALSE);
  2400. }
  2401. else
  2402. pCmdUI->Enable(TRUE);
  2403. }
  2404. void CIDEView::OnUpdateDrawBitmap(CCmdUI* pCmdUI)
  2405. {
  2406. if (g_bRun == TRUE) {
  2407. pCmdUI->Enable(FALSE);
  2408. }
  2409. else
  2410. pCmdUI->Enable(TRUE);
  2411. }
  2412. void CIDEView::OnUpdateDrawCurve(CCmdUI* pCmdUI)
  2413. {
  2414. if (g_bRun == TRUE) {
  2415. pCmdUI->Enable(FALSE);
  2416. }
  2417. else
  2418. pCmdUI->Enable(TRUE);
  2419. }
  2420. void CIDEView::OnUpdateDrawWatch(CCmdUI* pCmdUI)
  2421. {
  2422. if (g_bRun == TRUE) {
  2423. pCmdUI->Enable(FALSE);
  2424. }
  2425. else
  2426. pCmdUI->Enable(TRUE);
  2427. }
  2428. void CIDEView::OnUpdateDrawBar(CCmdUI* pCmdUI)
  2429. {
  2430. if (g_bRun == TRUE) {
  2431. pCmdUI->Enable(FALSE);
  2432. }
  2433. else
  2434. pCmdUI->Enable(TRUE);
  2435. }
  2436. void CIDEView::OnRButtonDown(UINT nFlags, CPoint point)
  2437. {
  2438. if (!g_bRun)
  2439. {
  2440. CPoint tmpPoint;
  2441. GetCursorPos(&tmpPoint);
  2442. CMenu menu;
  2443. menu.LoadMenu(IDR_DRAW_POP);
  2444. menu.GetSubMenu(0)->TrackPopupMenu(TPM_LEFTALIGN, tmpPoint.x, tmpPoint.y,this);
  2445. }
  2446. else
  2447. {
  2448. CPoint local = point;
  2449. CDrawObj *pObj = ObjectAt(local);
  2450. if(pObj != NULL)
  2451. {
  2452. CString sVarName;
  2453. if( pObj->m_bVariant && pObj->m_strCaption!="" )
  2454. sVarName = pObj->m_strCaption;
  2455. else if( pObj->m_strDynShow!="" )
  2456. sVarName = GetVarNameFromGS( pObj->m_strDynShow );
  2457. else if( pObj->m_strDynForeCon!="" )
  2458. sVarName = GetVarNameFromGS( pObj->m_strDynForeCon );
  2459. else if( pObj->m_strDynBackCon!="" )
  2460. sVarName = GetVarNameFromGS( pObj->m_strDynBackCon );
  2461. else if( pObj->m_strDynLineCon!="" )
  2462. sVarName = GetVarNameFromGS( pObj->m_strDynLineCon );
  2463. else if( pObj->m_strHoriPos!="" )
  2464. sVarName = GetVarNameFromGS( pObj->m_strHoriPos );
  2465. else if( pObj->m_strHoriSize!="" )
  2466. sVarName = GetVarNameFromGS( pObj->m_strHoriSize );
  2467. else if( pObj->m_strVertiPos!="" )
  2468. sVarName = GetVarNameFromGS( pObj->m_strVertiPos );
  2469. else if( pObj->m_strVertiSize!="" )
  2470. sVarName = GetVarNameFromGS( pObj->m_strVertiSize );
  2471. else if( pObj->m_strCurrentCaption!="" )
  2472. sVarName = GetVarNameFromGS( pObj->m_strCurrentCaption );
  2473. if( pObj->IsKindOf( RUNTIME_CLASS(CDrawBitmap) ) && sVarName=="" )
  2474. {
  2475. if( ((CDrawBitmap *)pObj)->m_strDynCondition!="" )
  2476. sVarName = GetVarNameFromGS( ((CDrawBitmap *)pObj)->m_strDynCondition );
  2477. }
  2478. if( pObj->IsKindOf( RUNTIME_CLASS(CDrawGif) ) && sVarName=="" )
  2479. {
  2480. if( ((CDrawGif *)pObj)->m_strDynCondition!="" )
  2481. sVarName = GetVarNameFromGS( ((CDrawGif *)pObj)->m_strDynCondition );
  2482. }
  2483. if( sVarName!="" )
  2484. {
  2485. m_sVarName = sVarName;
  2486. CPoint tmpPoint;
  2487. GetCursorPos(&tmpPoint);
  2488. CMenu menu;
  2489. menu.LoadMenu(IDR_DRAW_POP);
  2490. menu.GetSubMenu(1)->TrackPopupMenu(TPM_LEFTALIGN, tmpPoint.x, tmpPoint.y,this);
  2491. }
  2492. }
  2493. }
  2494. CScrollView::OnRButtonDown(nFlags, point);
  2495. }
  2496. void CIDEView::OnEditSave()
  2497. {
  2498. OnFileSave();
  2499. }
  2500. void CIDEView::OnUpdateEditSave(CCmdUI* pCmdUI)
  2501. {
  2502. if(m_bModified)
  2503. pCmdUI->Enable(TRUE);
  2504. else
  2505. pCmdUI->Enable(FALSE);
  2506. }
  2507. BOOL CIDEView::OnEraseBkgnd(CDC* pDC)
  2508. {
  2509. return false;
  2510. }
  2511. void CIDEView::OnUpdatePicsize(CCmdUI* pCmdUI)
  2512. {
  2513. if (g_bRun == TRUE) {
  2514. pCmdUI->Enable(FALSE);
  2515. }
  2516. else
  2517. pCmdUI->Enable(TRUE);
  2518. }
  2519. void CIDEView::OnVerspace()
  2520. {
  2521. CDrawObj* pTop;
  2522. CDrawObj* pBottom;
  2523. int top = 2000;
  2524. int bottom = 0;
  2525. int heightSum = 0;
  2526. int alignCount = 0;
  2527. int nY = 0;
  2528. // 先取top, bottom两个图元;
  2529. POSITION pos = m_selection.GetHeadPosition();
  2530. while(pos != NULL)
  2531. {
  2532. CDrawObj* pObj = m_selection.GetNext(pos);
  2533. alignCount++;
  2534. pObj->m_bAligned = false;
  2535. CRect r = pObj->m_rect;
  2536. r.NormalizeRect();
  2537. if (r.top < top)
  2538. {
  2539. pTop = pObj;
  2540. top = r.top;
  2541. }
  2542. if (r.bottom > bottom)
  2543. {
  2544. pBottom = pObj;
  2545. bottom = r.bottom;
  2546. }
  2547. heightSum += r.Height();
  2548. }
  2549. pTop->m_bAligned = true;
  2550. pBottom->m_bAligned = true;
  2551. alignCount -= 2;
  2552. int space = bottom - top - heightSum;
  2553. int perSpace = space / (alignCount+1);
  2554. nY = top + pTop->m_rect.Height() + perSpace;
  2555. for (int i = 1; i <= alignCount; i++ )
  2556. {
  2557. POSITION pos = m_selection.GetHeadPosition();
  2558. CDrawObj* curObj;
  2559. int top1 = 2000;
  2560. while(pos != NULL)
  2561. {
  2562. CDrawObj* pObj = m_selection.GetNext(pos);
  2563. CRect rec = pObj->m_rect;
  2564. rec.NormalizeRect();
  2565. if ( !pObj->m_bAligned )
  2566. {
  2567. if ( rec.top < top1)
  2568. {
  2569. top1 = rec.top;
  2570. curObj = pObj;
  2571. }
  2572. }
  2573. }
  2574. CRect r = curObj->m_rect;
  2575. r.OffsetRect(0, nY - top1);
  2576. curObj->MoveTo(r);
  2577. curObj->m_bAligned = true;
  2578. nY += (perSpace + r.Height());
  2579. }
  2580. m_bModified = TRUE;
  2581. Invalidate(FALSE);
  2582. }
  2583. void CIDEView::OnUpdateVerspace(CCmdUI* pCmdUI)
  2584. {
  2585. if(m_selection.GetCount()>2)
  2586. pCmdUI->Enable(TRUE);
  2587. else
  2588. pCmdUI->Enable(FALSE);
  2589. }
  2590. void CIDEView::OnSamewidth()
  2591. {
  2592. CRect rect = GetAlignRect();
  2593. POSITION pos = m_selection.GetHeadPosition();
  2594. while(pos != NULL)
  2595. {
  2596. CDrawObj* pObj = m_selection.GetNext(pos);
  2597. CRect r = pObj->m_rect;
  2598. r.NormalizeRect();
  2599. r.right = r.left + (rect.right - rect.left);
  2600. pObj->m_rect = r;
  2601. m_bModified = TRUE;
  2602. }
  2603. Invalidate(FALSE);
  2604. }
  2605. void CIDEView::OnUpdateSamewidth(CCmdUI* pCmdUI)
  2606. {
  2607. if(m_selection.GetCount()>1)
  2608. pCmdUI->Enable(TRUE);
  2609. else
  2610. pCmdUI->Enable(FALSE);
  2611. }
  2612. void CIDEView::OnSameheight()
  2613. {
  2614. CRect rect = GetAlignRect();
  2615. POSITION pos = m_selection.GetHeadPosition();
  2616. while(pos != NULL)
  2617. {
  2618. CDrawObj* pObj = m_selection.GetNext(pos);
  2619. CRect r = pObj->m_rect;
  2620. r.NormalizeRect();
  2621. r.bottom = r.top + (rect.bottom - rect.top);
  2622. pObj->m_rect = r;
  2623. m_bModified = TRUE;
  2624. }
  2625. Invalidate(FALSE);
  2626. }
  2627. void CIDEView::OnHorspace()
  2628. {
  2629. CDrawObj* pLeft = NULL;
  2630. CDrawObj* pRight = NULL;
  2631. int left = 2000;
  2632. int right = 0;
  2633. int widthSum = 0;
  2634. int alignCount = 0;
  2635. int nX = 0;
  2636. // 先取top, bottom两个图元;
  2637. POSITION pos = m_selection.GetHeadPosition();
  2638. while(pos != NULL)
  2639. {
  2640. CDrawObj* pObj = m_selection.GetNext(pos);
  2641. alignCount++;
  2642. pObj->m_bAligned = false;
  2643. CRect r = pObj->m_rect;
  2644. r.NormalizeRect();
  2645. if (r.left < left)
  2646. {
  2647. pLeft = pObj;
  2648. left = r.left;
  2649. }
  2650. if (r.right > right)
  2651. {
  2652. pRight = pObj;
  2653. right = r.right;
  2654. }
  2655. widthSum += r.Width();
  2656. }
  2657. pLeft->m_bAligned = true;
  2658. pRight->m_bAligned = true;
  2659. alignCount -= 2;
  2660. int space = right - left - widthSum;
  2661. int perSpace = space / (alignCount+1);
  2662. nX = left + pLeft->m_rect.Width() + perSpace;
  2663. for (int i = 1; i <= alignCount; i++ )
  2664. {
  2665. POSITION pos = m_selection.GetHeadPosition();
  2666. CDrawObj* curObj;
  2667. int left1 = 2000;
  2668. while(pos != NULL)
  2669. {
  2670. CDrawObj* pObj = m_selection.GetNext(pos);
  2671. CRect rec = pObj->m_rect;
  2672. rec.NormalizeRect();
  2673. if ( !pObj->m_bAligned )
  2674. {
  2675. if ( rec.left < left1)
  2676. {
  2677. left1 = rec.left;
  2678. curObj = pObj;
  2679. }
  2680. }
  2681. }
  2682. CRect r = curObj->m_rect;
  2683. r.OffsetRect(nX - left1, 0);
  2684. curObj->MoveTo(r);
  2685. curObj->m_bAligned = true;
  2686. nX += (perSpace + r.Width());
  2687. }
  2688. m_bModified = TRUE;
  2689. Invalidate(FALSE);
  2690. }
  2691. void CIDEView::OnAllsame()
  2692. {
  2693. CRect rect = GetAlignRect();
  2694. POSITION pos = m_selection.GetHeadPosition();
  2695. while (pos != NULL)
  2696. {
  2697. CDrawObj* pObj = m_selection.GetNext(pos);
  2698. CRect r = pObj->m_rect;
  2699. r.NormalizeRect();
  2700. r.bottom = r.top + (rect.bottom - rect.top);
  2701. r.right = r.left + (rect.right - rect.left);
  2702. pObj->m_rect = r;
  2703. m_bModified = TRUE;
  2704. }
  2705. Invalidate(FALSE);
  2706. }
  2707. void CIDEView::OnUpdateSameheight(CCmdUI* pCmdUI)
  2708. {
  2709. if(m_selection.GetCount()>1)
  2710. pCmdUI->Enable(TRUE);
  2711. else
  2712. pCmdUI->Enable(FALSE);
  2713. }
  2714. void CIDEView::OnUpdateHorspace(CCmdUI* pCmdUI)
  2715. {
  2716. if(m_selection.GetCount()>2)
  2717. pCmdUI->Enable(TRUE);
  2718. else
  2719. pCmdUI->Enable(FALSE);
  2720. }
  2721. void CIDEView::OnUpdateAllsame(CCmdUI* pCmdUI)
  2722. {
  2723. if(m_selection.GetCount()>1)
  2724. pCmdUI->Enable(TRUE);
  2725. else
  2726. pCmdUI->Enable(FALSE);
  2727. }
  2728. void CIDEView::OnEndPrintPreview(CDC* pDC, CPrintInfo* pInfo, POINT point, CPreviewView* pView)
  2729. {
  2730. CScrollView::OnEndPrintPreview(pDC, pInfo, point, pView);
  2731. CMainFrame *pFrame = (CMainFrame*)AfxGetApp()->m_pMainWnd;
  2732. pFrame->SetWindowText(g_strStoneuIspcms);
  2733. pFrame->HideRunBar();
  2734. pFrame->ShowWindow(SW_SHOWMAXIMIZED);
  2735. pFrame->UpdateWindow();
  2736. pFrame->RecalcLayout();
  2737. }
  2738. void CIDEView::OnOpenpic()
  2739. {
  2740. CPicListDlg dlg;
  2741. if ( dlg.DoModal() == IDOK )
  2742. {
  2743. g_strViewName = _PICTUREDIR + dlg.m_strPicName;
  2744. g_strViewName = g_strViewName + ".view";
  2745. CMainFrame *pFrame = (CMainFrame*)AfxGetApp()->m_pMainWnd;
  2746. CString strPath;
  2747. strPath = g_strDirectory + CString("\\") + CString(g_strViewName);
  2748. pFrame->AddIDEView( dlg.m_strPicName, strPath );
  2749. }
  2750. }
  2751. void CIDEView::OnDrawArc()
  2752. {
  2753. g_nElementNo = ARC;
  2754. }
  2755. void CIDEView::OnDrawBreaker()
  2756. {
  2757. g_nElementNo = BREAKER;
  2758. }
  2759. void CIDEView::OnDrawFan()
  2760. {
  2761. g_nElementNo = FAN;
  2762. }
  2763. void CIDEView::OnDrawGrid()
  2764. {
  2765. g_nElementNo = GRID;
  2766. }
  2767. void CIDEView::OnDrawHiscurve()
  2768. {
  2769. g_nElementNo = HISCurveShape;
  2770. }
  2771. void CIDEView::OnDrawLine()
  2772. {
  2773. g_nElementNo = LINE;
  2774. }
  2775. void CIDEView::OnDrawPie()
  2776. {
  2777. g_nElementNo = PIE;
  2778. }
  2779. void CIDEView::OnDrawPipe()
  2780. {
  2781. g_nElementNo = PIPE;
  2782. }
  2783. void CIDEView::OnDrawPolygon()
  2784. {
  2785. g_nElementNo = POLYGON;
  2786. }
  2787. void CIDEView::OnDrawReport()
  2788. {
  2789. g_nElementNo = REPORT;
  2790. }
  2791. void CIDEView::OnDrawSinglebar()
  2792. {
  2793. g_nElementNo = SINGLEBAR;
  2794. }
  2795. void CIDEView::OnDrawTransfer()
  2796. {
  2797. g_nElementNo = TRANSFER;
  2798. }
  2799. void CIDEView::OnDrawYpipe()
  2800. {
  2801. g_nElementNo = YPIPE;
  2802. }
  2803. void CIDEView::OnDrawZheline()
  2804. {
  2805. g_nElementNo = ZHELINE;
  2806. }
  2807. void CIDEView::OnDrawZhepipe()
  2808. {
  2809. g_nElementNo = ZHEPIPE;
  2810. }
  2811. void CIDEView::OnDrawArrow()
  2812. {
  2813. g_nElementNo = ARROW;
  2814. }
  2815. void CIDEView::OnDrawEllipse()
  2816. {
  2817. g_nElementNo = ELLIPSE;
  2818. }
  2819. void CIDEView::OnDrawSwitch()
  2820. {
  2821. g_nElementNo = SWITCH;
  2822. }
  2823. void CIDEView::OnUpdateDrawSwitch(CCmdUI* pCmdUI)
  2824. {
  2825. pCmdUI->Enable(TRUE);
  2826. }
  2827. void CIDEView::OnUpdateDrawArc(CCmdUI* pCmdUI)
  2828. {
  2829. pCmdUI->Enable(TRUE);
  2830. }
  2831. void CIDEView::OnUpdateDrawArrow(CCmdUI* pCmdUI)
  2832. {
  2833. pCmdUI->Enable(TRUE);
  2834. }
  2835. void CIDEView::OnUpdateDrawBreaker(CCmdUI* pCmdUI)
  2836. {
  2837. pCmdUI->Enable(TRUE);
  2838. }
  2839. void CIDEView::OnUpdateDrawEllipse(CCmdUI* pCmdUI)
  2840. {
  2841. pCmdUI->Enable(TRUE);
  2842. }
  2843. void CIDEView::OnUpdateDrawFan(CCmdUI* pCmdUI)
  2844. {
  2845. pCmdUI->Enable(TRUE);
  2846. }
  2847. void CIDEView::OnUpdateDrawGrid(CCmdUI* pCmdUI)
  2848. {
  2849. pCmdUI->Enable(TRUE);
  2850. }
  2851. void CIDEView::OnUpdateDrawHiscurve(CCmdUI* pCmdUI)
  2852. {
  2853. pCmdUI->Enable(TRUE);
  2854. }
  2855. void CIDEView::OnUpdateDrawPie(CCmdUI* pCmdUI)
  2856. {
  2857. pCmdUI->Enable(TRUE);
  2858. }
  2859. void CIDEView::OnUpdateDrawPipe(CCmdUI* pCmdUI)
  2860. {
  2861. pCmdUI->Enable(TRUE);
  2862. }
  2863. void CIDEView::OnUpdateDrawPolygon(CCmdUI* pCmdUI)
  2864. {
  2865. pCmdUI->Enable(TRUE);
  2866. }
  2867. void CIDEView::OnUpdateDrawReport(CCmdUI* pCmdUI)
  2868. {
  2869. pCmdUI->Enable(TRUE);
  2870. }
  2871. void CIDEView::OnUpdateDrawSinglebar(CCmdUI* pCmdUI)
  2872. {
  2873. pCmdUI->Enable(TRUE);
  2874. }
  2875. void CIDEView::OnUpdateDrawTransfer(CCmdUI* pCmdUI)
  2876. {
  2877. pCmdUI->Enable(TRUE);
  2878. }
  2879. void CIDEView::OnUpdateDrawYpipe(CCmdUI* pCmdUI)
  2880. {
  2881. pCmdUI->Enable(TRUE);
  2882. }
  2883. void CIDEView::OnUpdateDrawZheline(CCmdUI* pCmdUI)
  2884. {
  2885. pCmdUI->Enable(TRUE);
  2886. }
  2887. void CIDEView::OnUpdateDrawZhepipe(CCmdUI* pCmdUI)
  2888. {
  2889. pCmdUI->Enable(TRUE);
  2890. }
  2891. void CIDEView::OnUpdateDrawLine(CCmdUI* pCmdUI)
  2892. {
  2893. pCmdUI->Enable(TRUE);
  2894. }
  2895. void CIDEView::OnDrawRoundrect()
  2896. {
  2897. g_nElementNo = ROUNDRECT;
  2898. }
  2899. void CIDEView::OnUpdateDrawRoundrect(CCmdUI* pCmdUI)
  2900. {
  2901. pCmdUI->Enable(TRUE);
  2902. }
  2903. void CIDEView::OnUpdateDrawOCX(CCmdUI* pCmdUI)
  2904. {
  2905. pCmdUI->Enable(TRUE);
  2906. }
  2907. void CIDEView::OnUpdateDrawGIF(CCmdUI* pCmdUI)
  2908. {
  2909. pCmdUI->Enable(TRUE);
  2910. }
  2911. void CIDEView::OnUpdateDrawFlash(CCmdUI* pCmdUI)
  2912. {
  2913. pCmdUI->Enable(TRUE);
  2914. }
  2915. void CIDEView::SetHisTime(CTime time)
  2916. {
  2917. m_tblTime = time;
  2918. POSITION pos = m_selection.GetHeadPosition();
  2919. while(pos != NULL)
  2920. {
  2921. CDrawObj* pObj = m_selection.GetNext(pos);
  2922. pObj->m_bHisFreshed = false;
  2923. }
  2924. }
  2925. void CIDEView::OnUpdateDiscombine(CCmdUI* pCmdUI)
  2926. {
  2927. if((m_selection.GetCount() == 1))
  2928. pCmdUI->Enable(TRUE);
  2929. else
  2930. pCmdUI->Enable(FALSE);
  2931. }
  2932. void CIDEView::OnUpdateCombine(CCmdUI* pCmdUI)
  2933. {
  2934. if((m_selection.GetCount()>1))
  2935. pCmdUI->Enable(TRUE);
  2936. else
  2937. pCmdUI->Enable(FALSE);
  2938. }
  2939. void CIDEView::OnCombine()
  2940. {
  2941. CDrawComposite* pTempObj = new CDrawComposite(m_selection);
  2942. pTempObj->m_pView = this;
  2943. POSITION pos = m_selection.GetHeadPosition();
  2944. while(pos != NULL)
  2945. {
  2946. CDrawObj* pObj = m_selection.GetNext(pos);
  2947. pObj->Invalidate();
  2948. Remove(pObj);
  2949. }
  2950. m_selection.RemoveAll();
  2951. if (pTempObj != NULL)
  2952. {
  2953. m_pGraph->m_DrawObjList.AddTail(pTempObj);
  2954. m_selection.AddTail(pTempObj);
  2955. }
  2956. }
  2957. // 分解组合图元
  2958. void CIDEView::OnDiscombine()
  2959. {
  2960. if (m_selection.GetCount() != 1)
  2961. {
  2962. MessageBox(g_strUnSelectEntity);
  2963. return;
  2964. }
  2965. CDrawObj* pObj = m_selection.GetHead();
  2966. if (!pObj->IsKindOf(RUNTIME_CLASS(CDrawComposite)))
  2967. {
  2968. MessageBox(g_strIsNotPrimitive);
  2969. return;
  2970. }
  2971. m_selection.RemoveAll();
  2972. // 分解并添加到画面
  2973. POSITION pos = (((CDrawComposite*)pObj)->m_ObjList).GetHeadPosition();
  2974. while(pos != NULL)
  2975. {
  2976. CDrawObj* pTmpObj = (((CDrawComposite*)pObj)->m_ObjList).GetNext(pos);
  2977. pTmpObj->m_pView = this;
  2978. m_pGraph->m_DrawObjList.AddTail(pTmpObj);
  2979. m_selection.AddTail(pTmpObj);
  2980. }
  2981. // 删除组合图元
  2982. pos = m_pGraph->m_DrawObjList.Find(pObj);
  2983. if (NULL != pos)
  2984. {
  2985. m_pGraph->m_DrawObjList.RemoveAt(pos);
  2986. }
  2987. // 选择
  2988. //tbd 内存泄漏
  2989. // delete pObj;
  2990. }
  2991. void CIDEView::OnProperty()
  2992. {
  2993. // TODO: 在此添加命令处理程序代码
  2994. if(CDrawObj::bRuning == TRUE) return;
  2995. if (m_selection.GetCount()<1)
  2996. {
  2997. return;
  2998. }
  2999. CClientDC dc(this);
  3000. OnPrepareDC(&dc);
  3001. //CPoint local = point;
  3002. //dc.DPtoLP(&local);
  3003. if ( (g_nElementNo = POLYGON || g_nElementNo == ZHELINE ) && m_tempObj != NULL && m_bPolygon)
  3004. {
  3005. // ((CDrawPoly*)m_tempObj)->AddPoint(local);
  3006. m_bPolygon = false;
  3007. ((CDrawPoly*)m_tempObj)->RecalcBounds();
  3008. CRect freshRect = m_tempObj->m_rect;
  3009. freshRect.NormalizeRect();
  3010. freshRect.InflateRect(4,4);
  3011. InvalidateRect(freshRect,FALSE);
  3012. m_tempObj = NULL;
  3013. g_nElementNo = 0;
  3014. }
  3015. else
  3016. {
  3017. if (m_selection.GetCount()>1)
  3018. {
  3019. COLORREF _clrFore; // 前景色
  3020. COLORREF _clrLine; // 线色
  3021. COLORREF _clrBack; // 背景色
  3022. COLORREF _clrFill; // 填充色
  3023. LOGFONT _logfont; // 字体
  3024. CString _strLineType; // 线型
  3025. int _nLineWidth; // 线宽
  3026. int _nFillMode; //填充類型
  3027. int nPosIndex=0;
  3028. POSITION pos = m_selection.GetHeadPosition();
  3029. while(pos != NULL)
  3030. {
  3031. CDrawObj* pObj = m_selection.GetNext(pos);
  3032. pObj->m_bModifyMore = TRUE;
  3033. if( nPosIndex==0 )
  3034. {
  3035. if ( pObj->OnAttrib() )
  3036. {
  3037. m_bModified = TRUE;
  3038. _clrFore = pObj->m_clrFore;
  3039. _clrLine = pObj->m_clrLine;
  3040. _clrBack = pObj->m_clrBack;
  3041. _clrFill = pObj->m_clrFill;
  3042. _logfont = pObj->m_logfont;
  3043. _strLineType = pObj->m_strLineType;
  3044. _nLineWidth = pObj->m_nLineWidth;
  3045. _nFillMode = pObj->m_nFillMode;
  3046. }
  3047. else
  3048. {
  3049. return;
  3050. }
  3051. }
  3052. else
  3053. {
  3054. pObj->m_clrFore = _clrFore;
  3055. pObj->m_clrLine = _clrLine;
  3056. pObj->m_clrBack = _clrBack;
  3057. pObj->m_clrFill = _clrFill;
  3058. pObj->m_logfont = _logfont;
  3059. pObj->m_strLineType = _strLineType;
  3060. pObj->m_nLineWidth = _nLineWidth;
  3061. pObj->m_nFillMode = _nFillMode;
  3062. }
  3063. CRect freshRect = pObj->m_rect;
  3064. freshRect.NormalizeRect();
  3065. freshRect.InflateRect(4,4);
  3066. InvalidateRect(freshRect,FALSE);
  3067. g_nElementNo = 0;
  3068. nPosIndex++;
  3069. }
  3070. }
  3071. else
  3072. {
  3073. POSITION pos = m_selection.GetHeadPosition();
  3074. CDrawObj *pObj = m_selection.GetNext(pos);
  3075. pObj->m_bModifyMore = FALSE;
  3076. if ( pObj->OnAttrib() )
  3077. m_bModified = TRUE;
  3078. CRect freshRect = pObj->m_rect;
  3079. freshRect.NormalizeRect();
  3080. freshRect.InflateRect(4,4);
  3081. InvalidateRect(freshRect,FALSE);
  3082. g_nElementNo = 0;
  3083. }
  3084. }
  3085. }
  3086. void CIDEView::OnUpdateProperty(CCmdUI *pCmdUI)
  3087. {
  3088. // TODO: 在此添加命令更新用户界面处理程序代码
  3089. }
  3090. void CIDEView::OnEditVar()
  3091. {
  3092. }
  3093. void CIDEView::OnUpdateEditVar(CCmdUI *pCmdUI)
  3094. {
  3095. // TODO: 在此添加命令更新用户界面处理程序代码
  3096. }
  3097. void CIDEView::OnRealTimeCurve()
  3098. {
  3099. CDlg_RealTimeCurve dlg;
  3100. dlg.m_sVarName = m_sVarName;
  3101. dlg.DoModal();
  3102. }
  3103. void CIDEView::OnUpdateRealTimeCurve(CCmdUI *pCmdUI)
  3104. {
  3105. // TODO: 在此添加命令更新用户界面处理程序代码
  3106. }
  3107. void CIDEView::OnClose()
  3108. {
  3109. // TODO: 在此添加消息处理程序代码和/或调用默认值
  3110. if(m_bModified)
  3111. {
  3112. if(MessageBox(g_strSaveModify,g_strSelect,MB_YESNO|MB_ICONQUESTION) == IDYES)
  3113. OnFileSave();
  3114. }
  3115. CScrollView::OnClose();
  3116. }
  3117. #if VIEW_USE_THREAD
  3118. DWORD WINAPI CIDEView::FreshGraphThread( void *pData )
  3119. {
  3120. CIDEView *pView = (CIDEView *)pData;
  3121. do
  3122. {
  3123. if( pView != NULL )
  3124. {
  3125. if( pView->m_pGraph != NULL )
  3126. {
  3127. pView->m_pGraph->Fresh();
  3128. //pView->Invalidate(FALSE);
  3129. }
  3130. }
  3131. Sleep(100);
  3132. }while( WaitForSingleObject( pView->m_hIDEViewRunObject, 125L ) == WAIT_TIMEOUT );
  3133. return 0;
  3134. }
  3135. #endif
  3136. void CIDEView::OnKillFocus(CWnd* pNewWnd)
  3137. {
  3138. CScrollView::OnKillFocus(pNewWnd);
  3139. // TODO: 在此处添加消息处理程序代码
  3140. //TRACE("Enter KillFocus\n");
  3141. }
  3142. void CIDEView::OnSetFocus(CWnd* pOldWnd)
  3143. {
  3144. CScrollView::OnSetFocus(pOldWnd);
  3145. // TODO: 在此处添加消息处理程序代码
  3146. //TRACE("Enter SetFocus\n");
  3147. }
  3148. void CIDEView::OnActivateView(BOOL bActivate, CView* pActivateView, CView* pDeactiveView)
  3149. {
  3150. // TODO: 在此添加专用代码和/或调用基类
  3151. CScrollView::OnActivateView(bActivate, pActivateView, pDeactiveView);
  3152. }
  3153. CString CIDEView::RegSearch(HKEY hKey, TCHAR rootKey[], CString path,CString sContent)
  3154. {
  3155. CString sRet;
  3156. DWORD numSubKey=0; //存放子键的项数
  3157. DWORD i; //计数
  3158. DWORD sizeSubKey; //子键大小
  3159. TCHAR subKey[255]; //子键名
  3160. /*打开hKey中的rootKey, hKey乃继承递归调用者之hKey, rootKey乃递归调用者之subKey*/
  3161. RegOpenKeyEx( hKey, //欲开之键柄
  3162. rootKey, //欲开之根键名
  3163. 0, //保留值,强制0
  3164. KEY_READ, //权限
  3165. &hKey); //打开子键后,返回键柄
  3166. ///*首先查当前键下的值们(表明是复数哈)是否有符合条件的*/
  3167. char lpWstr[MAX_PATH];
  3168. DWORD lpType = NULL;
  3169. DWORD maxBufSize = MAX_PATH;
  3170. if(RegQueryValueEx(hKey, NULL, NULL, &lpType, (LPBYTE)lpWstr, &maxBufSize) == ERROR_SUCCESS)
  3171. {
  3172. CString sGet(lpWstr);
  3173. if( -1!=sGet.Find( sContent ) && sGet.GetLength()>=5 && path.Find( "CLSID" )!=-1 )
  3174. {
  3175. RegCloseKey(hKey); //收尾工作是一定要做的,否则机器会异常的慢
  3176. sRet = path.Mid( 6,0x26 );
  3177. return sRet; //跳出递归
  3178. }
  3179. }
  3180. /*没有查到,则进入子键查询*/
  3181. else
  3182. {
  3183. /*首先查得当前键下的子键项数*/
  3184. RegQueryInfoKey( hKey,
  3185. NULL,
  3186. NULL,
  3187. NULL,
  3188. &numSubKey, //查得子键的项数
  3189. NULL,
  3190. NULL,
  3191. NULL,
  3192. NULL,
  3193. NULL,
  3194. NULL,
  3195. NULL);
  3196. /*如果子键数不为0,遍历子键*/
  3197. if (numSubKey)
  3198. {
  3199. for (i=0; i<numSubKey; i++)
  3200. {
  3201. subKey[0]='\0'; //该两行很重要,保证了每次循环的初始
  3202. sizeSubKey=255; //第一行清空子键,第二行赋缓冲区大小
  3203. RegEnumKeyEx( hKey, //键柄
  3204. i, //子键序号
  3205. subKey, //存入子键名
  3206. &sizeSubKey,//指明缓冲区大小
  3207. NULL,
  3208. NULL,
  3209. NULL,
  3210. NULL);
  3211. CString s;
  3212. s = RegSearch (hKey,subKey,path+subKey+"\\",sContent); //递归
  3213. if( s.GetLength()>10 )
  3214. {
  3215. sRet = s;//.Mid( 6,0x26 );
  3216. return sRet;
  3217. }
  3218. }
  3219. }
  3220. }
  3221. RegCloseKey(hKey); //收尾工作是一定要做的,否则机器会异常的慢
  3222. return sRet;
  3223. }
  3224. CString CIDEView::GetClsidbyName( CString sName )
  3225. {
  3226. CString sRet;
  3227. CString sPathName;
  3228. sPathName.Format( "%s",g_strDirectory );
  3229. sPathName += "\\ocx";
  3230. sPathName += "\\ocxList.txt";
  3231. CString sTemp;
  3232. CStdioFile File;
  3233. if(!File.Open(sPathName,CFile::modeRead))
  3234. File.Open(sPathName,CFile::modeCreate|CFile::modeRead);
  3235. while(File.ReadString(sTemp))//定义一个CString变量sTemp作为缓冲区
  3236. {
  3237. int nPos = sTemp.Find( sName );
  3238. if( nPos!=-1 )
  3239. {
  3240. sRet = sTemp.Mid( sName.GetLength()+1,sTemp.GetLength()-sName.GetLength() );
  3241. break;
  3242. }
  3243. }
  3244. File.Close();
  3245. return sRet;
  3246. }
  3247. void CIDEView::ShowOCX( CRect rect,CString sOcxPath,int iIndex,CString sPageName )
  3248. {
  3249. //g_strDirectory;
  3250. //把宽高写入ini
  3251. CHAR strFile[MAX_PATH + 1] = "";
  3252. memset(strFile, 0, sizeof(strFile));
  3253. wsprintf(strFile, "C:\\OCXRect.ini");
  3254. if( rect.left<0 )
  3255. rect.left = 0;
  3256. if( rect.top<0 )
  3257. rect.top = 0;
  3258. CString sW,sH,sIndex;
  3259. sW.Format( "%d",rect.Width() );
  3260. sH.Format( "%d",rect.Height() );
  3261. sIndex.Format("%d",iIndex );
  3262. WritePrivateProfileString("WH", "W", sW, strFile);
  3263. WritePrivateProfileString("WH", "H", sH, strFile);
  3264. WritePrivateProfileString("WH", "INDEX", sIndex, strFile);
  3265. WritePrivateProfileString("WH", "PageName", sPageName, strFile);
  3266. WritePrivateProfileString("Database", "ServerName", g_strServerName, strFile);
  3267. WritePrivateProfileString("Database", "DataBaseName", g_strDataBaseName, strFile);
  3268. WritePrivateProfileString("Database", "UserName", g_strUserName, strFile);
  3269. WritePrivateProfileString("Database", "Password", g_strPassword, strFile);
  3270. WritePrivateProfileString("Database", "DBType", g_strDBType, strFile);
  3271. ///////////////////////////////////////////////////////
  3272. CString sName;
  3273. for (int iPosFile = sOcxPath.GetLength() - 1; iPosFile >= 0; iPosFile--)
  3274. {
  3275. if (sOcxPath[iPosFile] == '\\')
  3276. {
  3277. sName = sOcxPath.Mid( iPosFile+1,sOcxPath.GetLength()-iPosFile-5 );
  3278. break;
  3279. }
  3280. }
  3281. CString sClsid = GetClsidbyName( sName );//RegSearch (HKEY_CLASSES_ROOT,"","",sName+" Control");//
  3282. //SToneu_Door_WG="{AED861D5-723E-4F31-AA24-0F20B382103E}";//
  3283. //StoneU_HC_OCX ="{80043A10-F014-4817-9832-38A38202E0B8}";//
  3284. //if( sClsid=="" )
  3285. //{
  3286. // if( RegisterOCX( sOcxPath ) )//注册OCX
  3287. // sClsid = RegSearch (HKEY_CLASSES_ROOT,"","",sName+" Control");
  3288. //}
  3289. if( sClsid!="" )
  3290. {
  3291. USES_CONVERSION;
  3292. CLSID clsid;
  3293. HRESULT hr = CLSIDFromString(T2OLE(sClsid), &clsid);
  3294. bool f;
  3295. static int ID = 62001;
  3296. int nRet = m_OcxWnd.CreateControl( clsid, _T("132"), WS_CHILD | WS_VISIBLE, rect, this,ID );
  3297. ID++;
  3298. if( nRet == 0 )
  3299. f = false;
  3300. else
  3301. f = true;
  3302. }
  3303. else
  3304. {
  3305. CString str;
  3306. str.Format( "请在 <\\Ocx\\ocxList.txt> 里填入控件的sClsid" );
  3307. MessageBox(str, g_strTip, MB_ICONWARNING);
  3308. }
  3309. }