IDEView.cpp 83 KB

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