123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732 |
- // VectorView.cpp : implementation of the CIDEView class
- //
- #include "stdafx.h"
- #include "IDEView.h"
- #include "PicSizeDlg.h"
- #include "gooddc.h"
- #include "graphdef.h"
- #include "MainFrm.h"
- #include "PicListDlg.h"
- #include ".\ideview.h"
- #include "BaseProDlg.h"
- #include "Dlg_RealTimeCurve.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- #pragma warning (disable: 4700)
- CDrawObjList g_Copied;
- /////////////////////////////////////////////////////////////////////////////
- // CIDEView
- IMPLEMENT_DYNCREATE(CIDEView, CScrollView)
- BEGIN_MESSAGE_MAP(CIDEView, CScrollView)
- //{{AFX_MSG_MAP(CIDEView)
- ON_WM_CREATE()
- ON_WM_DESTROY()
- ON_COMMAND(ID_EDIT_UNFREEZE, OnEditUnfreeze)
- ON_COMMAND(ID_EDIT_PASTE, OnEditPaste)
- ON_COMMAND(ID_EDIT_MOVETOFRONT, OnEditMovetofront)
- ON_COMMAND(ID_EDIT_MOVETOBACK, OnEditMovetoback)
- ON_COMMAND(ID_EDIT_HINVERT, OnEditHinvert)
- ON_COMMAND(ID_EDIT_FREEZE, OnEditFreeze)
- ON_COMMAND(ID_EDIT_CUT, OnEditCut)
- ON_COMMAND(ID_EDIT_COPY, OnEditCopy)
- ON_COMMAND(ID_EDIT_CLEAR, OnEditDelete)
- ON_COMMAND(ID_DESK_GRID, OnDeskGrid)
- ON_COMMAND(ID_ALIGN_TOP, OnAlignTop)
- ON_COMMAND(ID_ALIGN_VCENTER, OnAlignVcenter)
- ON_COMMAND(ID_ALIGN_RIGHT, OnAlignRight)
- ON_COMMAND(ID_ALIGN_LEFT, OnAlignLeft)
- ON_COMMAND(ID_ALIGN_HCENTER, OnAlignHcenter)
- ON_COMMAND(ID_ALIGN_BOTTOM, OnAlignBottom)
- ON_COMMAND(ID_EDIT_VINVERT, OnEditVinvert)
- ON_WM_MOUSEMOVE()
- ON_WM_LBUTTONDOWN()
- ON_WM_LBUTTONUP()
- ON_COMMAND(ID_POINTER, OnPointer)
- ON_WM_KEYDOWN()
- ON_COMMAND(ID_FILE_NEW, OnFileNew)
- ON_COMMAND(ID_FILE_OPEN, OnFileOpen)
- ON_COMMAND(ID_FILE_SAVE, OnFileSave)
- ON_COMMAND(ID_FILE_SAVE_AS, OnFileSaveAs)
- ON_COMMAND(ID_APP_EXIT, OnAppExit)
- ON_UPDATE_COMMAND_UI(ID_DESK_GRID, OnUpdateDeskGrid)
- ON_UPDATE_COMMAND_UI(ID_EDIT_FREEZE, OnUpdateEditFreeze)
- ON_COMMAND(ID_REDO, OnRedo)
- ON_COMMAND(ID_UNDO, OnUndo)
- ON_UPDATE_COMMAND_UI(ID_UNDO, OnUpdateUndo)
- ON_UPDATE_COMMAND_UI(ID_REDO, OnUpdateRedo)
- ON_COMMAND(ID_PICSIZE, OnPicsize)
- ON_UPDATE_COMMAND_UI(ID_ALIGN_BOTTOM, OnUpdateAlignBottom)
- ON_UPDATE_COMMAND_UI(ID_ALIGN_HCENTER, OnUpdateAlignHcenter)
- ON_UPDATE_COMMAND_UI(ID_ALIGN_LEFT, OnUpdateAlignLeft)
- ON_UPDATE_COMMAND_UI(ID_ALIGN_RIGHT, OnUpdateAlignRight)
- ON_UPDATE_COMMAND_UI(ID_ALIGN_TOP, OnUpdateAlignTop)
- ON_UPDATE_COMMAND_UI(ID_ALIGN_VCENTER, OnUpdateAlignVcenter)
- ON_UPDATE_COMMAND_UI(ID_EDIT_HINVERT, OnUpdateEditHinvert)
- ON_UPDATE_COMMAND_UI(ID_EDIT_MOVETOBACK, OnUpdateEditMovetoback)
- ON_UPDATE_COMMAND_UI(ID_EDIT_MOVETOFRONT, OnUpdateEditMovetofront)
- ON_UPDATE_COMMAND_UI(ID_EDIT_VINVERT, OnUpdateEditVinvert)
- ON_UPDATE_COMMAND_UI(ID_EDIT_COPY, OnUpdateEditCopy)
- ON_UPDATE_COMMAND_UI(ID_EDIT_CUT, OnUpdateEditCut)
- ON_UPDATE_COMMAND_UI(ID_EDIT_CLEAR, OnUpdateEditClear)
- ON_UPDATE_COMMAND_UI(ID_EDIT_PASTE, OnUpdateEditPaste)
- ON_COMMAND(ID_DRAW_TLINE, OnDrawTline)
- ON_COMMAND(ID_DRAW_TEXT, OnDrawText)
- ON_COMMAND(ID_DRAW_RECT, OnDrawRect)
- ON_COMMAND(ID_DRAW_DATA, OnDrawData)
- ON_COMMAND(ID_DRAW_BUTTON, OnDraw3drect)
- ON_COMMAND(ID_DRAW_3CIRCLE, OnDraw3circle)
- ON_UPDATE_COMMAND_UI(ID_POINTER, OnUpdatePointer)
- ON_WM_LBUTTONDBLCLK()
- ON_WM_TIMER()
- ON_UPDATE_COMMAND_UI(ID_DRAW_3CIRCLE, OnUpdateDraw3circle)
- ON_UPDATE_COMMAND_UI(ID_DRAW_BUTTON, OnUpdateDraw3drect)
- ON_UPDATE_COMMAND_UI(ID_DRAW_DATA, OnUpdateDrawData)
- ON_UPDATE_COMMAND_UI(ID_DRAW_TEXT, OnUpdateDrawText)
- ON_UPDATE_COMMAND_UI(ID_DRAW_TLINE, OnUpdateDrawTline)
- ON_WM_RBUTTONDOWN()
- ON_COMMAND(ID_EDIT_SAVE, OnEditSave)
- ON_UPDATE_COMMAND_UI(ID_EDIT_SAVE, OnUpdateEditSave)
- ON_WM_ERASEBKGND()
- ON_UPDATE_COMMAND_UI(ID_DRAW_RECT, OnUpdateDrawRect)
- ON_UPDATE_COMMAND_UI(ID_PICSIZE, OnUpdatePicsize)
- ON_COMMAND(ID_DRAW_BITMAP, OnDrawBitmap)
- ON_UPDATE_COMMAND_UI(ID_DRAW_BITMAP, OnUpdateDrawBitmap)
- ON_COMMAND(ID_DRAW_CURVE, OnDrawCurve)
- ON_UPDATE_COMMAND_UI(ID_DRAW_CURVE, OnUpdateDrawCurve)
- ON_COMMAND(ID_DRAW_WATCH, OnDrawWatch)
- ON_UPDATE_COMMAND_UI(ID_DRAW_WATCH, OnUpdateDrawWatch)
- ON_COMMAND(ID_DRAW_BAR, OnDrawBar)
- ON_UPDATE_COMMAND_UI(ID_DRAW_BAR, OnUpdateDrawBar)
- ON_COMMAND(ID_VERSPACE, OnVerspace)
- ON_UPDATE_COMMAND_UI(ID_VERSPACE, OnUpdateVerspace)
- ON_COMMAND(ID_SAMEWIDTH, OnSamewidth)
- ON_UPDATE_COMMAND_UI(ID_SAMEWIDTH, OnUpdateSamewidth)
- ON_COMMAND(ID_SAMEHEIGHT, OnSameheight)
- ON_UPDATE_COMMAND_UI(ID_SAMEHEIGHT, OnUpdateSameheight)
- ON_COMMAND(ID_HORSPACE, OnHorspace)
- ON_UPDATE_COMMAND_UI(ID_HORSPACE, OnUpdateHorspace)
- ON_COMMAND(ID_ALLSAME, OnAllsame)
- ON_UPDATE_COMMAND_UI(ID_ALLSAME, OnUpdateAllsame)
- ON_COMMAND(ID_OPENPIC, OnOpenpic)
- ON_COMMAND(ID_DRAW_ARC, OnDrawArc)
- ON_COMMAND(ID_DRAW_BREAKER, OnDrawBreaker)
- ON_COMMAND(ID_DRAW_FAN, OnDrawFan)
- ON_COMMAND(ID_DRAW_GRID, OnDrawGrid)
- ON_COMMAND(ID_DRAW_HISCURVE, OnDrawHiscurve)
- ON_COMMAND(ID_DRAW_LINE, OnDrawLine)
- ON_COMMAND(ID_DRAW_PIE, OnDrawPie)
- ON_COMMAND(ID_DRAW_PIPE, OnDrawPipe)
- ON_COMMAND(ID_DRAW_POLYGON, OnDrawPolygon)
- ON_COMMAND(ID_DRAW_REPORT, OnDrawReport)
- ON_COMMAND(ID_DRAW_SINGLEBAR, OnDrawSinglebar)
- ON_COMMAND(ID_DRAW_TRANSFER, OnDrawTransfer)
- ON_COMMAND(ID_DRAW_YPIPE, OnDrawYpipe)
- ON_COMMAND(ID_DRAW_ZHELINE, OnDrawZheline)
- ON_COMMAND(ID_DRAW_ZHEPIPE, OnDrawZhepipe)
- ON_COMMAND(ID_DRAW_ARROW, OnDrawArrow)
- ON_COMMAND(ID_DRAW_ELLIPSE, OnDrawEllipse)
- ON_COMMAND(ID_DRAW_SWITCH, OnDrawSwitch)
- ON_COMMAND(ID_DRAW_OCX, OnDrawOCX)
- ON_COMMAND(ID_DRAW_FLASH, OnDrawFlash)
- ON_COMMAND(ID_COMBINE, OnCombine)
- ON_COMMAND(ID_DISCOMBINE, OnDiscombine)
- ON_COMMAND(ID_DRAW_ROUNDRECT, OnDrawRoundrect)
- ON_COMMAND(ID_FILE_PRINT, OnFilePrint)
- ON_UPDATE_COMMAND_UI(ID_DRAW_SWITCH, OnUpdateDrawSwitch)
- ON_UPDATE_COMMAND_UI(ID_DRAW_ARC, OnUpdateDrawArc)
- ON_UPDATE_COMMAND_UI(ID_DRAW_ARROW, OnUpdateDrawArrow)
- ON_UPDATE_COMMAND_UI(ID_DRAW_BREAKER, OnUpdateDrawBreaker)
- ON_UPDATE_COMMAND_UI(ID_DRAW_ELLIPSE, OnUpdateDrawEllipse)
- ON_UPDATE_COMMAND_UI(ID_DRAW_FAN, OnUpdateDrawFan)
- ON_UPDATE_COMMAND_UI(ID_DRAW_GRID, OnUpdateDrawGrid)
- ON_UPDATE_COMMAND_UI(ID_DRAW_HISCURVE, OnUpdateDrawHiscurve)
- ON_UPDATE_COMMAND_UI(ID_DRAW_PIE, OnUpdateDrawPie)
- ON_UPDATE_COMMAND_UI(ID_DRAW_PIPE, OnUpdateDrawPipe)
- ON_UPDATE_COMMAND_UI(ID_DRAW_POLYGON, OnUpdateDrawPolygon)
- ON_UPDATE_COMMAND_UI(ID_DRAW_REPORT, OnUpdateDrawReport)
- ON_UPDATE_COMMAND_UI(ID_DRAW_SINGLEBAR, OnUpdateDrawSinglebar)
- ON_UPDATE_COMMAND_UI(ID_DRAW_TRANSFER, OnUpdateDrawTransfer)
- ON_UPDATE_COMMAND_UI(ID_DRAW_YPIPE, OnUpdateDrawYpipe)
- ON_UPDATE_COMMAND_UI(ID_DRAW_ZHELINE, OnUpdateDrawZheline)
- ON_UPDATE_COMMAND_UI(ID_DRAW_ZHEPIPE, OnUpdateDrawZhepipe)
- ON_UPDATE_COMMAND_UI(ID_DRAW_LINE, OnUpdateDrawLine)
- ON_UPDATE_COMMAND_UI(ID_DISCOMBINE, OnUpdateDiscombine)
- ON_UPDATE_COMMAND_UI(ID_COMBINE, OnUpdateCombine)
- ON_UPDATE_COMMAND_UI(ID_DRAW_ROUNDRECT, OnUpdateDrawRoundrect)
- ON_UPDATE_COMMAND_UI(ID_DRAW_OCX, OnUpdateDrawOCX)
- ON_UPDATE_COMMAND_UI(ID_DRAW_FLASH, OnUpdateDrawFlash)
- ON_WM_MOUSEWHEEL()
- //}}AFX_MSG_MAP
- // Standard printing commands
- ON_COMMAND(ID_FILE_PRINT, CScrollView::OnFilePrint)
- ON_COMMAND(ID_FILE_PRINT_DIRECT, CScrollView::OnFilePrint)
- ON_COMMAND(ID_FILE_PRINT_PREVIEW, CScrollView::OnFilePrintPreview)
- ON_COMMAND(ID_PROPERTY, OnProperty)
- ON_UPDATE_COMMAND_UI(ID_PROPERTY, OnUpdateProperty)
- ON_COMMAND(IDM_EDITVAR, OnEditVar)
- ON_UPDATE_COMMAND_UI(IDM_EDITVAR, OnUpdateEditVar)
- ON_COMMAND(IDM_REALTIMECURVE, OnRealTimeCurve)
- ON_UPDATE_COMMAND_UI(IDM_REALTIMECURVE, OnUpdateRealTimeCurve)
- ON_WM_CLOSE()
- ON_WM_KILLFOCUS()
- ON_WM_SETFOCUS()
- ON_WM_HSCROLL()
- ON_WM_RBUTTONDBLCLK()
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CIDEView construction/destruction
- CIDEView::CIDEView()
- {
- // TODO: add construction code here
- m_mouseState = FALSE;
- m_bDrag = FALSE;
- m_nDragHandle = 0;
- m_nBDragHandle = 0;
- m_bMoveElements = FALSE;
- m_bFreezed = FALSE;
- m_bRectSelect = FALSE;
- m_mouseRect = CRect(0,0,0,0);
- m_pCurActionObj = NULL;
- m_bPolygon = FALSE;
- //创建临时文件
- char tmpPathc[_MAX_PATH+1];
- GetTempPath(_MAX_PATH,tmpPathc);
- CString tmpPath = tmpPathc;
- ::CreateDirectory(tmpPath+"\\VDTemp",NULL);
- CGraph* pGraph = new CGraph(CSize(0,0));
- pGraph->m_strPicFile = _T(tmpPath+"\\VDTemp\\"+"\\First.ed");
- pGraph->Store();
- pGraph->m_strPicFile = _T(tmpPath+"\\VDTemp\\"+"\\Second.ed");
- pGraph->Store();
- pGraph->m_strPicFile = _T(tmpPath+"\\VDTemp\\"+"\\Third.ed");
- pGraph->Store();
- pGraph->m_strPicFile = _T(tmpPath+"\\VDTemp\\"+"\\Forth.ed");
- pGraph->Store();
- pGraph->m_strPicFile = _T(tmpPath+"\\VDTemp\\"+"\\Fifth.ed");
- pGraph->Store();
- pGraph->m_strPicFile = _T(tmpPath+"\\VDTemp\\"+"\\Six.ed");
- pGraph->Store();
- delete pGraph;
- m_nRudoPosition = 0;
- m_nCanUndoTimes = 0;
- m_nCanRedoTimes = 0;
- m_tblTime = CTime::GetCurrentTime();
- m_bOcxCreate = false;
- m_bIsHaveOCX = false;//是否有OCX
- m_bModified = FALSE;
- }
- CIDEView::~CIDEView()
- {
- int test=0;
- }
- BOOL CIDEView::PreCreateWindow(CREATESTRUCT& cs)
- {
- // TODO: Modify the Window class or styles here by modifying
- // the CREATESTRUCT cs
- return CScrollView::PreCreateWindow(cs);
- }
- /////////////////////////////////////////////////////////////////////////////
- // CIDEView drawing
- void CIDEView::OnDraw(CDC* pDC)
- {
- CIDEDoc* pDoc = GetDocument();
- ASSERT_VALID(pDoc);
- // TODO: add draw code for native data here
- //if( !m_bIsHaveOCX )
- {
- // 1.创建内存DC;
- CRect rect=NULL;
- CGoodDC dc;
- dc.Create(pDC);
- CRect rectClip;
- dc.GetClipBox(&rectClip);
- dc.FillSolidRect(rectClip,RGB(128,128,128));
- LAYOUTSTRUCT layout;
- CRect m_rect = layout.rect;
- CString sOCXPath;
- int nOcxIndex=0;
- // 2.在指定的DC环境设备上绘制所有的图元;
- rect = m_pGraph->Draw(&dc,sOCXPath,nOcxIndex);
-
- // 3.编辑状态下,显示选中图元的手势边框;
- if(/*m_bHandle*/g_bRun == FALSE)
- {// 编辑状态选中时,显示的选中的边框;
- POSITION pos = m_selection.GetHeadPosition();
- while(pos != NULL)
- {
- CDrawObj* pObj = m_selection.GetNext(pos);
- pObj->DrawTracker(&dc);
- }
- }
- // 画响应动作的图元的外框;
- //if (m_pCurActionObj != NULL )
- //{
- // m_pCurActionObj->DrawFrame(&dc);
- //}
- // 4.编辑状态下,以虚线框显示区选时的矩形范围;
- CPen dotpen;
- dotpen.CreatePen(PS_DOT, 1, RGB(195,195,195));
- CPen* oldobj = dc.SelectObject(&dotpen);
- // 区选图元时显示的4条边框;
- dc.MoveTo(m_mouseRect.left,m_mouseRect.top);
- dc.LineTo(m_mouseRect.right,m_mouseRect.top);
- dc.LineTo(m_mouseRect.right,m_mouseRect.bottom);
- dc.LineTo(m_mouseRect.left,m_mouseRect.bottom);
- dc.LineTo(m_mouseRect.left,m_mouseRect.top);
- dc.SelectObject(oldobj);
- if( rect.Width()>0 && rect.Height()>0 && g_bRun && nOcxIndex>=0 && nOcxIndex<=9 )
- {
- if( !m_bOcxCreate && sOCXPath!="" )
- {
- m_bOcxCreate = true;
- ShowOCX( rect,sOCXPath,nOcxIndex,g_sCurrentPageName );
- }
- dc.Destroy( );
- }
- else
- dc.Destroy();
- DeleteObject( dotpen );
- }
- }
- /////////////////////////////////////////////////////////////////////////////
- // CIDEView printing
- BOOL CIDEView::OnPreparePrinting(CPrintInfo* pInfo)
- {
- // default preparation
- pInfo->SetMinPage(1);
- pInfo->SetMaxPage(1);
- return DoPreparePrinting(pInfo);
- }
- void CIDEView::OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo)
- {
- // TODO: add extra initialization before printing
- CString sTemp;
- int nTemp=0;
- if(m_pGraph->m_Type == 0)
- {
- int nOffsetX = pDC->GetDeviceCaps(PHYSICALOFFSETX);
- int nOffsetY = pDC->GetDeviceCaps(PHYSICALOFFSETY);
- int nLogPixelX = pDC->GetDeviceCaps(LOGPIXELSX);
- int nLogPixelY = pDC->GetDeviceCaps(LOGPIXELSY);
- pDC->SetMapMode(MM_ISOTROPIC);
- pDC->SetWindowExt(100,100);
- pDC->SetViewportExt(nLogPixelX,nLogPixelY);
- pDC->SetViewportOrg(-nOffsetX,-nOffsetY);
- m_pGraph->Draw(pDC,sTemp,nTemp);
- }
- else
- {
- CSize size = m_pGraph->m_sizePic;
- int nHScale = pInfo->m_rectDraw.Width() / size.cx;
- int nVScale = pInfo->m_rectDraw.Height() / size.cy;
- int nScale = min(nHScale,nVScale);
- pDC->SetMapMode(MM_ISOTROPIC);
- pDC->SetWindowExt(1000,1000);
- pDC->SetViewportExt(1000*nScale,1000*nScale);
- int nHOffset = pInfo->m_rectDraw.Width() - nScale*size.cx;
- int nVOffset = pInfo->m_rectDraw.Height() - nScale*size.cy;
- pDC->SetViewportOrg(nHOffset/2,nVOffset/2);
- m_pGraph->Print(pDC);
- }
- }
- void CIDEView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
- {
- // TODO: add cleanup after printing
- }
- /////////////////////////////////////////////////////////////////////////////
- // CIDEView diagnostics
- #ifdef _DEBUG
- void CIDEView::AssertValid() const
- {
- CScrollView::AssertValid();
- }
- void CIDEView::Dump(CDumpContext& dc) const
- {
- CScrollView::Dump(dc);
- }
- CIDEDoc* CIDEView::GetDocument() // non-debug version is inline
- {
- ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CIDEDoc)));
- return (CIDEDoc*)m_pDocument;
- }
- #endif //_DEBUG
- /////////////////////////////////////////////////////////////////////////////
- // CIDEView message handlers
- BOOL CIDEView::Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext)
- {
- // TODO: Add your specialized code here and/or call the base class
-
- return CWnd::Create(lpszClassName, lpszWindowName, dwStyle, rect, pParentWnd, nID, pContext);
- }
- int CIDEView::OnCreate(LPCREATESTRUCT lpCreateStruct)
- {
- if (CScrollView::OnCreate(lpCreateStruct) == -1)
- {
- return -1;
- }
- m_bMove = TRUE;
- m_bHandle = TRUE;
- m_bModified = FALSE;
- m_pointMouse = CPoint(0,0);
- CString strPicFile = AfxGetApp()->m_lpCmdLine;
- if(!strPicFile.IsEmpty()) m_bMove = FALSE;
- m_pGraph = new CGraph(CSize(0,0));
- m_pGraph->SetPicFile(strPicFile);
- m_pGraph->SetView(this);
- m_pGraph->Load();
- RefreshScrollSizes();
- //CWnd *pWnd = GetParent(); ////下面这段子框架全屏幕显示
- //RECT rect;
- //WINDOWPLACEMENT wp,oldwp;
- //POINT pmin,pmax;
- //GetWindowPlacement(&oldwp);
- //if(pWnd != NULL)
- // pWnd-> GetClientRect(&rect);
- //
- //rect.bottom = 900;
- //pmax.x = rect.right ;
- //pmax.y = rect.bottom ;
- //pmin = oldwp.ptMinPosition ;
- //wp.length = sizeof(WINDOWPLACEMENT);
- //wp.flags = WPF_RESTORETOMAXIMIZED;
- //wp.showCmd = SW_SHOWMAXIMIZED;
- //wp.rcNormalPosition = rect;
- //SetWindowPlacement(&wp); ////上面这段子框架全屏幕显示
- SetTimer(3, 1000, NULL);
- return 0;
- }
- void CIDEView::OnDestroy()
- {
- CScrollView::OnDestroy();
-
- #if VIEW_USE_THREAD
- MTVERIFY( SetEvent( m_hFreshGraphObject ) );
- MTVERIFY( SetEvent( m_hIDEViewRunObject ) );
- MTVERIFY( WaitForSingleObject( m_hFreshGraphThread, INFINITE ) != WAIT_FAILED );
- MTVERIFY( CloseHandle( m_hFreshGraphThread ) );
- m_hFreshGraphThread = NULL;
- MTVERIFY( CloseHandle( m_hIDEViewRunObject ) );
- MTVERIFY( CloseHandle( m_hFreshGraphObject ) );
- m_hFreshGraphObject = NULL;
- DeleteCriticalSection( &m_csFreshGraph );
- #endif
- // TODO: Add your message handler code here
- POSITION pos = m_copied.GetHeadPosition();
- while(pos != NULL)
- {
- CDrawObj *pObj = m_copied.GetNext(pos);
- delete pObj;
- }
- m_copied.RemoveAll();
- pos = g_Copied.GetHeadPosition();
- while(pos != NULL)
- {
- CDrawObj *pObj = g_Copied.GetNext(pos);
- delete pObj;
- }
- g_Copied.RemoveAll();
- pos = m_deleted.GetHeadPosition();
- while(pos != NULL)
- {
- CDrawObj *pObj = m_deleted.GetNext(pos);
- delete pObj;
- }
- m_deleted.RemoveAll();
-
- delete m_pGraph;
- m_pGraph = NULL;
- // TODO: Add your message handler code here
- }
- void CIDEView::OnEditUnfreeze()
- {
- POSITION pos = m_selection.GetHeadPosition();
- if( pos!=NULL )
- {
- while( pos != NULL)
- {
- CDrawObj* pObj = m_selection.GetNext(pos);
- pObj->m_bOnMove = false;
- }
- }
- else
- {
- m_bFreezed = FALSE;
- }
- }
- void CIDEView::OnEditPaste()
- {
- // TODO: Add your command handler code here
- #if 1
- m_selection.RemoveAll();
- POSITION pos = g_Copied.GetHeadPosition();
- while(pos != NULL)
- {
- CDrawObj *pObj = g_Copied.GetNext(pos);
- CDrawObj *pNewObj = pObj->Clone();
- pObj->m_rect.OffsetRect(20,20);
- pNewObj->m_rect.OffsetRect(20,20);
- if (pNewObj->IsKindOf( RUNTIME_CLASS(CDrawPoly) ))
- {
- int nPointCount = ((CDrawPoly*)pNewObj)->m_nPoints;
- for (int i = 0; i<nPointCount; i++)
- {
- ((CDrawPoly*)pNewObj)->m_points[i] += CSize(20,20);
- ((CDrawPoly*)pObj)->m_points[i] += CSize(20,20);
- }
- }
- pNewObj->m_pView = this;
- m_pGraph->m_DrawObjList.AddTail(pNewObj);
- m_selection.AddTail(pNewObj);
- }
- Invalidate(FALSE);
- m_bModified = TRUE;
- #else
- m_selection.RemoveAll();
- POSITION pos = m_copied.GetHeadPosition();
- while(pos != NULL)
- {
- CDrawObj *pObj = m_copied.GetNext(pos);
- CDrawObj *pNewObj = pObj->Clone();
- pObj->m_rect.OffsetRect(20,20);
- pNewObj->m_rect.OffsetRect(20,20);
- if (pNewObj->IsKindOf( RUNTIME_CLASS(CDrawPoly) ))
- {
- int nPointCount = ((CDrawPoly*)pNewObj)->m_nPoints;
- for (int i = 0; i<nPointCount; i++)
- {
- ((CDrawPoly*)pNewObj)->m_points[i] += CSize(20,20);
- ((CDrawPoly*)pObj)->m_points[i] += CSize(20,20);
- }
- }
- m_pGraph->m_DrawObjList.AddTail(pNewObj);
- m_selection.AddTail(pNewObj);
- }
- Invalidate(FALSE);
- m_bModified = TRUE;
- #endif
- }
- void CIDEView::OnEditMovetofront()
- {
- // TODO: Add your command handler code here
- POSITION pos = m_selection.GetHeadPosition();
- while(pos != NULL)
- {
- CDrawObj* pObj = m_selection.GetNext(pos);
- POSITION pos0 = m_pGraph->m_DrawObjList.Find(pObj);
- m_pGraph->m_DrawObjList.RemoveAt(pos0);
- m_pGraph->m_DrawObjList.AddTail(pObj);
- pObj->Invalidate();
- }
- Invalidate(FALSE);
- m_bModified = TRUE;
- }
- void CIDEView::OnEditMovetoback()
- {
- // TODO: Add your command handler code here
- POSITION pos = m_selection.GetTailPosition();
- while(pos != NULL)
- {
- CDrawObj* pObj = m_selection.GetPrev(pos);
- POSITION pos0 = m_pGraph->m_DrawObjList.Find(pObj);
- m_pGraph->m_DrawObjList.RemoveAt(pos0);
- m_pGraph->m_DrawObjList.AddHead(pObj);
- pObj->Invalidate();
- }
- Invalidate(FALSE);
- m_bModified = TRUE;
- }
- void CIDEView::OnEditHinvert()
- {
- // TODO: Add your command handler code here
- POSITION pos = m_selection.GetHeadPosition();
- while(pos != NULL)
- {
- CDrawObj *pObj = m_selection.GetNext(pos);
- int temp = pObj->m_rect.left;
- pObj->m_rect.left = pObj->m_rect.right;
- pObj->m_rect.right = temp;
- pObj->Invalidate();
- m_bModified = TRUE;
- }
- Invalidate(FALSE);
- m_bModified = TRUE;
- }
- void CIDEView::OnEditFreeze()
- {
- // TODO: Add your command handler code here
- CRect freshRect; // 需要刷新的区域
- POSITION pos = m_selection.GetHeadPosition();
- if( pos!=NULL )
- {
- while( pos != NULL)
- {
- CDrawObj* pObj = m_selection.GetNext(pos);
- pObj->m_bOnMove = true;
- }
- }
- else
- {
- m_bFreezed = !m_bFreezed;
- }
- }
- void CIDEView::OnEditCut()
- {
- // TODO: Add your command handler code here
- OnEditCopy();
- OnEditDelete();
- Invalidate(FALSE);
- }
- void CIDEView::OnEditCopy()
- {
- // TODO: Add your command handler code here
- #if 1
- // 复制前,先清除之前的;
- POSITION pos = g_Copied.GetHeadPosition();
- while(pos != NULL)
- {
- CDrawObj *pObj = g_Copied.GetNext(pos);
- delete pObj;
- }
- g_Copied.RemoveAll();
- pos = m_selection.GetHeadPosition();
- while(pos != NULL)
- {
- CDrawObj* pObj = m_selection.GetNext(pos);
- CDrawObj *pNewObj = pObj->Clone();
- g_Copied.AddTail(pNewObj);
- }
- #else
- POSITION pos = m_copied.GetHeadPosition();
- while(pos != NULL)
- {
- CDrawObj *pObj = m_copied.GetNext(pos);
- delete pObj;
- }
- m_copied.RemoveAll();
- pos = m_selection.GetHeadPosition();
- while(pos != NULL)
- {
- CDrawObj* pObj = m_selection.GetNext(pos);
- CDrawObj *pNewObj = pObj->Clone();
- m_copied.AddTail(pNewObj);
- }
- #endif
- }
- void CIDEView::OnEditDelete()
- {
- POSITION pos = m_deleted.GetHeadPosition();
- while(pos != NULL)
- {
- CDrawObj* pObj = m_deleted.GetNext(pos);
- delete pObj;
- }
- m_deleted.RemoveAll();
- #if 0
- pos = m_selection.GetHeadPosition();
- while(pos != NULL)
- {
- CDrawObj* pObj = m_selection.GetNext(pos);
- pObj->Invalidate();
- Remove(pObj);
- m_deleted.AddTail(pObj);
- }
- m_selection.RemoveAll();
- #endif
- for(POSITION pos = m_selection.GetHeadPosition();pos!=NULL;)
- {
- POSITION pos1 = pos ; //要在这里做一个备份
- CDrawObj* pObj = m_selection.GetNext(pos);//他会改变 pos的值
- pObj->Invalidate();
- Remove(pObj);
- m_deleted.AddTail(pObj);
- }
- m_selection.RemoveAll();
- m_bModified = TRUE;
- }
- void CIDEView::OnDeskGrid()
- {
- m_pGraph->m_bGrid = !m_pGraph->m_bGrid;
- m_bModified = TRUE;
- Invalidate(FALSE);
- }
- void CIDEView::OnAlignTop()
- {
- CRect rect = GetAlignRect();
- POSITION pos = m_selection.GetHeadPosition();
- while(pos != NULL)
- {
- CDrawObj* pObj = m_selection.GetNext(pos);
- CRect r = pObj->m_rect;
- r.OffsetRect(0, rect.top - min(r.top, r.bottom));
- pObj->MoveTo(r);
- m_bModified = TRUE;
- }
- Invalidate(FALSE);
- }
- void CIDEView::OnAlignVcenter()
- {
- CRect rect = GetAlignRect();
- int y0 = rect.top + rect.Height() / 2;
- POSITION pos = m_selection.GetTailPosition();
- m_selection.GetPrev(pos);
- while(pos != NULL)
- {
- CDrawObj* pObj = m_selection.GetPrev(pos);
- CRect r = pObj->m_rect;
- int y = r.top + r.Height() / 2;
- r.OffsetRect(0, y0-y);
- pObj->MoveTo(r);
- m_bModified = TRUE;
- }
- Invalidate(FALSE);
- }
- void CIDEView::OnAlignRight()
- {
- CRect rect = GetAlignRect();
- POSITION pos = m_selection.GetHeadPosition();
- while(pos != NULL)
- {
- CDrawObj* pObj = m_selection.GetNext(pos);
- CRect r = pObj->m_rect;
- r.OffsetRect(rect.right - max(r.left, r.right), 0);
- pObj->MoveTo(r);
- m_bModified = TRUE;
- }
- Invalidate(FALSE);
-
- }
- void CIDEView::OnAlignLeft()
- {
- CRect rect = GetAlignRect();
- POSITION pos = m_selection.GetHeadPosition();
- while(pos != NULL)
- {
- CDrawObj* pObj = m_selection.GetNext(pos);
- CRect r = pObj->m_rect;
- r.OffsetRect(rect.left - min(r.left, r.right), 0);
- pObj->MoveTo(r);
- m_bModified = TRUE;
- }
- Invalidate(FALSE);
- }
- void CIDEView::OnAlignHcenter()
- {
- CRect rect = GetAlignRect();
- int x0 = rect.left + rect.Width() / 2;
- POSITION pos = m_selection.GetTailPosition();
- m_selection.GetPrev(pos);
- while(pos != NULL)
- {
- CDrawObj* pObj = m_selection.GetPrev(pos);
- CRect r = pObj->m_rect;
- int x = r.left + r.Width() / 2;
- r.OffsetRect(x0-x, 0);
- pObj->MoveTo(r);
- m_bModified = TRUE;
- }
- Invalidate(FALSE);
- }
- void CIDEView::OnAlignBottom()
- {
- CRect rect = GetAlignRect();
- POSITION pos = m_selection.GetHeadPosition();
- while(pos != NULL)
- {
- CDrawObj* pObj = m_selection.GetNext(pos);
- CRect r = pObj->m_rect;
- r.OffsetRect(0, rect.bottom - max(r.top, r.bottom));
- pObj->MoveTo(r);
- m_bModified = TRUE;
- }
- Invalidate(FALSE);
- }
- void CIDEView::OnEditVinvert()
- {
- POSITION pos = m_selection.GetHeadPosition();
- while(pos != NULL)
- {
- CDrawObj *pObj = m_selection.GetNext(pos);
- int temp = pObj->m_rect.top;
- pObj->m_rect.top = pObj->m_rect.bottom;
- pObj->m_rect.bottom = temp;
- pObj->Invalidate();
- m_bModified = TRUE;
- }
- Invalidate(FALSE);
- }
- void CIDEView::OnMouseMove(UINT nFlags, CPoint point)
- {
- if ( m_mouseState )
- _tprintf(_T("按住鼠标移动:x:%d, y:%d\n"), point.x, point.y);
- if(CDrawObj::bRuning == TRUE)
- {
- POSITION pos = m_pGraph->m_DrawObjList.GetHeadPosition();
- while(pos != NULL)
- {
- CDrawObj* pObj = m_pGraph->m_DrawObjList.GetNext(pos);
-
- if ( (pObj->m_bOnButtonDown) && 0!=pObj->m_rect.PtInRect(point) && pObj->m_bShow )
- {
- HCURSOR hCursor;
- hCursor = AfxGetApp() -> LoadCursor(IDC_HANDCUR);
- SetCursor(hCursor);
- break;
- }
- }
- // 运行状态下,做动作响应处理
- //CClientDC dc(this);
- //OnPrepareDC(&dc);
- //CPoint local = point;
- //dc.DPtoLP(&local);
- //CDrawObj* tmp = ObjectAt(local);
- //if ( tmp != NULL ) //该图元响应move动作
- //{
- // if (tmp->m_bOnMove)
- // {
- // m_nCurActionType = MOUSE_MOVE;
- // m_pCurActionObj = tmp;
- // tmp->ProcessAction(MOUSE_MOVE);
- // }
- // if (tmp->IsKindOf( RUNTIME_CLASS(CDrawButton) ) ||
- // ( tmp->IsKindOf( RUNTIME_CLASS(CDrawBitmap) ) &&
- // ( tmp->m_downAction.m_nActionType == LINK_COMMOND || tmp->m_downAction.m_nActionType == SET_COMMOND ||
- // //tmp->m_downAction.m_nActionType == YT_COMMOND || tmp->m_downAction.m_nActionType == YK_COMMOND ||
- // tmp->m_downAction.m_nActionType == EXIT_COMMOND || tmp->m_downAction.m_nActionType == EXTERN_COMMOND) ) )
- // {
- // //::SetCursor(LoadCursor(NULL,(char*) IDC_HAND));
- // m_pCurActionObj = tmp;
- // }
- //}
- //else
- //{
- // m_pCurActionObj = NULL;
- //}
- return;
- }
- CClientDC dc(this);
- OnPrepareDC(&dc);
- CPoint local = point;
- dc.DPtoLP(&local);
- CSize offset = point-local;
- m_pointMouse = local;
- bool bFresh = false;
-
- if (m_mouseState == TRUE) // 鼠标按下;
- {
- if ((g_nElementNo != 0)&&(m_tempObj != NULL) ) //添加新的图元;
- {
- //画新图元的外形;
- m_tempObj->m_rect = CRect(m_startPoint,m_pointMouse);
- m_bModified = TRUE;
- CRect freshRect = m_tempObj->m_rect;
- freshRect.NormalizeRect();
- CRect lastRect = CRect(m_lastPoint,m_lastPoint+CSize(4,4));
- lastRect.NormalizeRect();
- freshRect.UnionRect(freshRect,lastRect);
- freshRect.InflateRect(4,4);
- freshRect.OffsetRect(offset);
- InvalidateRect(freshRect,FALSE);
- }
- else if (m_bDrag == TRUE) // 改变图元大小;
- {
- m_selection.GetHead()->MoveHandleTo(m_nBDragHandle,local);
- SetCursor(m_selection.GetHead()->GetHandleCursor());
- m_bModified = TRUE;
-
- CRect freshRect = m_selection.GetHead()->m_rect;
- freshRect.NormalizeRect();
- CRect lastRect = CRect(m_lastPoint,m_lastPoint+CSize(4,4));
- lastRect.NormalizeRect();
- freshRect.UnionRect(freshRect,lastRect);
- freshRect.InflateRect(4,4);
- freshRect.OffsetRect(offset);
- InvalidateRect(freshRect,FALSE);
- }
- else if (m_bRectSelect == TRUE) // 区选图元;
- {
- m_mouseRect = CRect(m_startPoint,local);
- CRect freshRect = m_mouseRect; // 需要刷新的区域;
- freshRect.NormalizeRect();
- CRect lastRect = CRect(m_startPoint,m_lastPoint);
- lastRect.NormalizeRect();
- freshRect.UnionRect(freshRect,lastRect);
- freshRect.InflateRect(4,4);
- freshRect.OffsetRect(offset);
- InvalidateRect(freshRect,FALSE);
- }
- }
-
- // 如果鼠标没按下,则判断是否到选中图元(一个)的边上了,是的话,改变图标;
- if (m_mouseState == FALSE)
- {
- if ((g_nElementNo == 0) && (m_selection.GetCount() == 1))
- {
- m_nDragHandle = m_selection.GetHead()->HitTest(local);
- if ( (m_nDragHandle>0)&&(m_nDragHandle<9) )
- {
- SetCursor(m_selection.GetHead()->GetHandleCursor());
- }
- }
- }
-
- if((m_bMoveElements == TRUE)&&(!m_bFreezed)) // 移动一个或多个图元;
- {
- HCURSOR hCursor;
- hCursor = AfxGetApp() -> LoadCursor(IDC_CURSOR1);
- SetCursor(hCursor);
-
- CRect freshRect; // 需要刷新的区域;
- bool bFirst = true;
- POSITION pos = m_selection.GetHeadPosition();
- while( pos != NULL)
- {
- CDrawObj* pObj = m_selection.GetNext(pos);
- if( pObj->m_bOnMove )
- continue;
- CRect rect = pObj->m_rect;
- if (bFirst)
- {
- freshRect = rect;
- freshRect.InflateRect(4,4);
- }
- else
- freshRect.UnionRect(freshRect, rect);
- CPoint delta = CPoint(local-m_lastPoint);
- rect += delta;
- pObj->MoveTo(rect);
- rect.NormalizeRect();
- freshRect.UnionRect(freshRect, rect);
- freshRect.InflateRect(4,4);
- m_bModified = TRUE;
- bFirst = false;
- InvalidateRect(freshRect,FALSE);
- }
- }
- CString str;
- // 要访问类CMainFrame,需要将mainfrm.h文件引入;
- CMainFrame * pFrame = (CMainFrame *) AfxGetApp()->m_pMainWnd;
- CStatusBar * pStatus = (CStatusBar *) &pFrame->m_wndStatusBar;
- str.Format (g_strLogicDoorinate, local.x, local.y);
- pStatus->SetPaneText(1, str);
- // 根据情况,刷新部分区域;
- if (bFresh )
- Invalidate(FALSE);
- m_lastPoint = local;
- CScrollView::OnMouseMove(nFlags, point);
- }
- long CIDEView::OnOutbarNotify(WPARAM wParam, LPARAM lParam)
- {
- return 0;
- }
- void CIDEView::OnLButtonDown(UINT nFlags, CPoint point) // 鼠标按下:选择或画;
- {
- if(CDrawObj::bRuning == TRUE)
- {
- // 运行状态下,做动作响应处理;
- CClientDC dc(this);
- OnPrepareDC(&dc);
- CPoint local = point;
- dc.DPtoLP(&local);
- CDrawObj* tmp = ObjectAt(local);
- if ( tmp != NULL && 1) //该图元响应click动作;
- {
- if (tmp->m_bOnButtonDown && tmp->m_bShow )
- {
- //AfxMessageBox( tmp->m_strCaption );
- m_nCurActionType = MOUSE_CLICK_DOWN;
- m_pCurActionObj = tmp;
- tmp->ProcessAction(MOUSE_CLICK_DOWN);
- }
- }
- else
- {
- m_pCurActionObj = NULL;
- }
- return;
- }
- CClientDC dc(this);
- OnPrepareDC(&dc);
- CPoint local = point;
- dc.DPtoLP(&local);
- // 鼠标按下时,还原拖动为FALSE;
- m_bDrag = FALSE;
- // 鼠标按下时,设置鼠标状态为TURE表示按下;
- m_mouseState = TRUE;
- m_startPoint = local;
- m_lastPoint = local;
- if (ObjectAt(local))
- _tprintf(_T("按下鼠标:x:%d, y:%d\n"), point.x, point.y);
- if (g_nElementNo != 0)
- {// 生成一个图元;
- if ( g_nElementNo == POLYGON || g_nElementNo == ZHELINE)
- {
- if ( m_bPolygon )
- {// 如果是折线(折线需要多次按下松开鼠标);
- ((CDrawPoly*)m_tempObj)->AddPoint(local);
- ((CDrawPoly*)m_tempObj)->RecalcBounds();
- CRect freshRect = m_tempObj->m_rect;
- freshRect.NormalizeRect();
- freshRect.InflateRect(4,4);
- InvalidateRect(freshRect,FALSE);
- }
- else
- {// 如果不是折线,只需要按下和松开鼠标一次;
- m_selection.RemoveAll();
- // 根据类型创建新图元;
- m_tempObj = CreateDrawObjbyNo(g_nElementNo);
- if (m_tempObj != NULL)
- {
- m_pGraph->m_DrawObjList.AddTail(m_tempObj);
- m_selection.AddTail(m_tempObj);
- ((CDrawPoly*)m_tempObj)->AddPoint(local);
- m_bPolygon = true;
- }
- }
- }
- else
- {
- m_selection.RemoveAll();
- m_tempObj = CreateDrawObjbyNo(g_nElementNo); /**/
- if (m_tempObj != NULL)
- {
- m_pGraph->m_DrawObjList.AddTail(m_tempObj);
- m_selection.AddTail(m_tempObj);
- }
- }
- }
- else if(m_nDragHandle == 0)
- {// 选择一个图元;
- CDrawObj *pObj = ObjectAt(local);
- if(pObj != NULL)
- {
- //selectMode = move;
- if(!IsSelected(pObj))
- Select(pObj, (nFlags & MK_CONTROL) != 0);
- else if((nFlags & MK_CONTROL) != 0)
- {
- POSITION ipos = m_selection.Find(pObj);
- if(ipos != NULL) m_selection.RemoveAt(ipos);
- } //去掉selection中的该图元;
- m_bMoveElements = TRUE;
- }
- else if((nFlags & MK_CONTROL) == 0)
- {
- m_selection.RemoveAll();
- m_bMoveElements = FALSE;
- m_bRectSelect = TRUE; //rectselect 区域选;
- }
- }
- else // 拉动一个图元;
- {
- m_bDrag = TRUE;
- m_nBDragHandle = m_nDragHandle;
- }
- //Invalidate(FALSE);
- CScrollView::OnLButtonDown(nFlags, point);
- }
- /************************************************************************/
- /* 函数:[5/11/2016 IT];
- /* 描述:;
- /* 参数:;
- /* [IN] :;
- /* [OUT] :;
- /* [IN/OUT] :;
- /* 返回:void;
- /* 注意:1.生成图元时放开鼠标;2.选中时放开鼠标;3.拖动时放开鼠标;
- /* 示例:;
- /*
- /* 修改:;
- /* 日期:;
- /* 内容:;
- /************************************************************************/
- void CIDEView::OnLButtonUp(UINT nFlags, CPoint point) // 松开鼠标,完成画或移动或变形;
- {
- if(CDrawObj::bRuning == TRUE)
- {
- m_pCurActionObj = NULL;
- // 运行状态下,做动作响应处理
- CClientDC dc(this);
- OnPrepareDC(&dc);
- CPoint local = point;
- dc.DPtoLP(&local);
- CDrawObj* tmp = ObjectAt(point);
- if ( tmp != NULL && tmp->m_bOnButtonUp && tmp->m_bShow ) //该图元响应click动作
- {
- m_nCurActionType = MOUSE_CLICK_UP;
- m_pCurActionObj = tmp;
- if (tmp->m_bOnButtonUp)
- {
- tmp->ProcessAction(MOUSE_CLICK_UP);
- }
- }
- else
- {
- m_pCurActionObj = NULL;
- }
- return;
- }
- CClientDC dc(this);
- OnPrepareDC(&dc);
- CPoint local = point;
- dc.DPtoLP(&local);
- m_mouseState = FALSE;
- m_endPoint = local;
-
- if (ObjectAt(local))
- _tprintf(_T("松开鼠标:x:%d, y:%d\n"), point.x, point.y);
- // 图元类型不为空,且图元对象不为空,完成新图元;
- if ((g_nElementNo != 0)&&(m_tempObj != NULL) )
- {//添加新图元;
- if ( (g_nElementNo == POLYGON || g_nElementNo == ZHELINE )&& m_bPolygon)
- {// 如果是折线,不完成图元;
- ;
- }
- else
- {
- // 图元大小;
- m_tempObj->m_rect = CRect(m_startPoint,m_endPoint);
- if ((abs(CPoint(m_endPoint-m_startPoint).x)<6) && (abs(CPoint(m_endPoint-m_startPoint).y)<6))
- {// 如果生成的图元区域过小,删除图元,认为不生成;
- Remove(m_tempObj);
- delete m_tempObj;
- m_tempObj = NULL;
- g_nElementNo = 0;
- }
- else // 图元添加成功了,做临时文件处理;
- {
- if (m_nRudoPosition == 0) //上一次也是编辑;
- {
- ExchangeSave();
- if (m_nCanUndoTimes<5)
- {
- m_nCanUndoTimes++;
- }
- }
- else //上一次不是编辑;
- {
- FileProcess();
- }
- m_nRudoPosition = 0;
- m_nCanRedoTimes = 0;
- }
- }
- }
-
- if (m_bRectSelect) //选中一堆图元;
- {
- m_mouseRect.NormalizeRect();
- ObjectIn();
- }
- if((m_bMoveElements == TRUE)&&(!m_bFreezed)) //移动,也要临时文件记录;
- {
- if (m_nRudoPosition == 0) //上一次也是编辑;
- {
- ExchangeSave();
- }
- else //上一次不是编辑;
- {
- FileProcess();
- }
- m_nRudoPosition = 0;
- m_nCanRedoTimes = 0;
- }
-
- if(m_bDrag)
- {// 放开拖动;
- if (m_nRudoPosition == 0) //上一次也是编辑;
- {
- ExchangeSave();
- }
- else //上一次不是编辑;
- {
- FileProcess();
- }
- m_nRudoPosition = 0;
- m_nCanRedoTimes = 0;
- }
- m_bMoveElements = FALSE;
- m_bDrag = FALSE;
- m_mouseRect = CRect(0,0,0,0);
- m_bRectSelect = FALSE;
- Invalidate(FALSE);
- CScrollView::OnLButtonUp(nFlags, point);
- }
- void CIDEView::OnRButtonDblClk(UINT nFlags, CPoint point)
- {
- // TODO: 在此添加消息处理程序代码和/或调用默认值
- CScrollView::OnRButtonDblClk(nFlags, point);
- }
- //属性设定
- void CIDEView::OnLButtonDblClk(UINT nFlags, CPoint point)
- {
- if(CDrawObj::bRuning == TRUE )
- {
- //CClientDC dc(this);
- //OnPrepareDC(&dc);
- CPoint local = point;
- //dc.DPtoLP(&local);
-
- CDrawObj *pObj = ObjectAt(local);
- if(pObj != NULL)
- {
- CString sVarName;
- if( pObj->m_bVariant && pObj->m_strCaption!="" )
- sVarName = pObj->m_strCaption;
- else if( pObj->m_strDynShow!="" )
- sVarName = GetVarNameFromGS( pObj->m_strDynShow );
- else if( pObj->m_strDynForeCon!="" )
- sVarName = GetVarNameFromGS( pObj->m_strDynForeCon );
- else if( pObj->m_strDynBackCon!="" )
- sVarName = GetVarNameFromGS( pObj->m_strDynBackCon );
- else if( pObj->m_strDynLineCon!="" )
- sVarName = GetVarNameFromGS( pObj->m_strDynLineCon );
- else if( pObj->m_strHoriPos!="" )
- sVarName = GetVarNameFromGS( pObj->m_strHoriPos );
- else if( pObj->m_strHoriSize!="" )
- sVarName = GetVarNameFromGS( pObj->m_strHoriSize );
- else if( pObj->m_strVertiPos!="" )
- sVarName = GetVarNameFromGS( pObj->m_strVertiPos );
- else if( pObj->m_strVertiSize!="" )
- sVarName = GetVarNameFromGS( pObj->m_strVertiSize );
- else if( pObj->m_strCurrentCaption!="" )
- sVarName = GetVarNameFromGS( pObj->m_strCurrentCaption );
-
- if( pObj->IsKindOf( RUNTIME_CLASS(CDrawBitmap) ) && sVarName=="" )
- {
- if( ((CDrawBitmap *)pObj)->m_strDynCondition!="" )
- sVarName = GetVarNameFromGS( ((CDrawBitmap *)pObj)->m_strDynCondition );
- }
- if( pObj->IsKindOf( RUNTIME_CLASS(CDrawGif) ) && sVarName=="" )
- {
- if( ((CDrawGif *)pObj)->m_strDynCondition!="" )
- sVarName = GetVarNameFromGS( ((CDrawGif *)pObj)->m_strDynCondition );
- }
- if( sVarName!="" )
- {
-
- }
- }
- return;
- }
- if (m_selection.GetCount()<1) {
- return;
- }
-
- CClientDC dc(this);
- OnPrepareDC(&dc);
- CPoint local = point;
- dc.DPtoLP(&local);
- if ( (g_nElementNo = POLYGON || g_nElementNo == ZHELINE ) && m_tempObj != NULL && m_bPolygon)
- {
- ((CDrawPoly*)m_tempObj)->AddPoint(local);
- m_bPolygon = false;
- ((CDrawPoly*)m_tempObj)->RecalcBounds();
- CRect freshRect = m_tempObj->m_rect;
- freshRect.NormalizeRect();
- freshRect.InflateRect(4,4);
- InvalidateRect(freshRect,FALSE);
- m_tempObj = NULL;
- g_nElementNo = 0;
- }
- else
- {
- if (m_selection.GetCount()>1)
- {
- COLORREF _clrFore; // 前景色
- COLORREF _clrLine; // 线色
- COLORREF _clrBack; // 背景色
- COLORREF _clrFill; // 填充色
- LOGFONT _logfont; // 字体
- CString _strLineType; // 线型
- int _nLineWidth; // 线宽
- int _nFillMode; //填充類型
- int nPosIndex=0;
- POSITION pos = m_selection.GetHeadPosition();
- while(pos != NULL)
- {
- CDrawObj* pObj = m_selection.GetNext(pos);
- pObj->m_bModifyMore = TRUE;
-
- if( nPosIndex==0 )
- {
- if ( pObj->OnAttrib() )
- {
- m_bModified = TRUE;
- _clrFore = pObj->m_clrFore;
- _clrLine = pObj->m_clrLine;
- _clrBack = pObj->m_clrBack;
- _clrFill = pObj->m_clrFill;
- _logfont = pObj->m_logfont;
- _strLineType = pObj->m_strLineType;
- _nLineWidth = pObj->m_nLineWidth;
- _nFillMode = pObj->m_nFillMode;
- }
- else
- {
- return;
- }
- }
- else
- {
- pObj->m_clrFore = _clrFore;
- pObj->m_clrLine = _clrLine;
- pObj->m_clrBack = _clrBack;
- pObj->m_clrFill = _clrFill;
- pObj->m_logfont = _logfont;
- pObj->m_strLineType = _strLineType;
- pObj->m_nLineWidth = _nLineWidth;
- pObj->m_nFillMode = _nFillMode;
- }
- CRect freshRect = pObj->m_rect;
- freshRect.NormalizeRect();
- freshRect.InflateRect(4,4);
- InvalidateRect(freshRect,FALSE);
- g_nElementNo = 0;
- nPosIndex++;
- }
- }
- else
- {
- POSITION pos = m_selection.GetHeadPosition();
- CDrawObj *pObj = m_selection.GetNext(pos);
- pObj->m_bModifyMore = FALSE;
- if ( pObj->OnAttrib() )
- m_bModified = TRUE;
- CRect freshRect = pObj->m_rect;
- freshRect.NormalizeRect();
- freshRect.InflateRect(4,4);
- InvalidateRect(freshRect,FALSE);
- g_nElementNo = 0;
- }
- }
- CScrollView::OnLButtonDblClk(nFlags, point);
- }
- // 判断是有效变量名
- BOOL CIDEView::IsValidChar(char chr)
- {
- if ( chr >= '0' && chr <= '9')
- return TRUE;
- else if ((chr >= 'A' && chr <= 'Z') || (chr >= 'a' && chr <= 'z') )
- return TRUE;
- else if (chr == '_')
- return TRUE;
- else
- return FALSE;
- }
- //从组合公式中找出变量名加入到画面结构中
- CString CIDEView::GetVarNameFromGS( CString sGS )
- {
- //LOG4C((LOG_NOTICE, "GetVarFromGSAddToStruct sGS :%s", sGS));
- //sGS = "(HG7053_DI10>=3)OR(HG7053_LinkStatus<=33)";
- //sGS = "((HG7053_DI10>=3))";
- //sGS = "(HG7053_DI10>=3)AND(HG7053_LinkStatus<=33)OR(HG7053_DI15<3)";
- int nLen = sGS.GetLength();
- int nPos1=0,nPos2=0;
- int nPos3=0,nPos4=0;
- CString sTemp,s1,s2,s3;
- CString sGS2[10];
- int nCount=0;
-
- //OR AND NOT
- for( int i=0;i<nLen;i++ )
- {
- if( sGS.Mid( i,2)=="OR" )
- {
- sGS2[nCount++] = sGS.Mid( nPos1,i-nPos1 );
- nPos1 = i+2;
- }
- if( (sGS.Mid( i,3)=="AND" || sGS.Mid( i,3)=="NOT") )
- {
- sGS2[nCount++] = sGS.Mid( nPos1,i-nPos1 );
- nPos1 = i+3;
- }
- }
- if( nPos1<nLen )
- {
- sGS2[nCount++] = sGS.Mid( nPos1,nLen-nPos1 );
- }
- for( int iGSIndex=0;iGSIndex<nCount;iGSIndex++ )
- {
- nPos3=0;
- nPos4=0;
- nLen = sGS2[iGSIndex].GetLength();
- if( !IsValidChar( sGS2[iGSIndex][0] ) )
- {
- if( IsValidChar( sGS2[iGSIndex][1] ) )
- nPos3 = 1;
- else
- nPos3 = 2;
- for( int i=nPos3;i<nLen;i++ )
- {
- if( !IsValidChar( sGS2[iGSIndex][i] ) )
- {
- nPos4 = i-0;
- break;
- }
- }
- sTemp = sGS2[iGSIndex].Mid( nPos3,nPos4-nPos3 );
- }
- else
- {
- for( int i=nPos3;i<nLen;i++ )
- {
- if( !IsValidChar( sGS2[iGSIndex][i] ) )
- {
- nPos4 = i-0;
- break;
- }
- }
- sTemp = sGS2[iGSIndex].Mid( nPos3,nPos4-nPos3 );
- }
- }
- return sTemp;
- }
- CDrawObj * CIDEView::CreateDrawObjbyNo(int objNo)
- {
- if (objNo == TlineShape)
- {
- CDrawTLine * temp = new CDrawTLine();
- temp->m_pView = this;
- CDrawObj * ele = (CDrawObj *)temp;
- return ele;
- }
- if (objNo == TextShape)
- {
- CDrawText * temp = new CDrawText();
- temp->m_pView = this;
- CDrawObj * ele = (CDrawObj *)temp;
- return ele;
- }
- if (objNo == RectShape)
- {
- CDrawRect * temp = new CDrawRect();
- temp->m_pView = this;
- CDrawObj * ele = (CDrawObj *)temp;
- return ele;
- }
- if (objNo == DataShape)
- {
- CDrawDatabox * temp = new CDrawDatabox();
- temp->m_pView = this;
- CDrawObj * ele = (CDrawObj *)temp;
- return ele;
- }
- if (objNo == BUTTON)
- {
- CDrawButton * temp = new CDrawButton();
- temp->m_pView = this;
- CDrawObj * ele = (CDrawObj *)temp;
- return ele;
- }
- if (objNo == ThreeDCircleShape)
- {
- CDraw3dCircle * temp = new CDraw3dCircle();
- temp->m_pView = this;
- CDrawObj * ele = (CDrawObj *)temp;
- return ele;
- }
- if (objNo == RealCurveShape)
- {
- CDrawCurve * temp = new CDrawCurve();
- temp->m_pView = this;
- CDrawObj * ele = (CDrawObj *)temp;
- return ele;
- }
- if (objNo == BarShape)
- {
- CDrawBar * temp = new CDrawBar();
- temp->m_pView = this;
- CDrawObj * ele = (CDrawObj *)temp;
- return ele;
- }
- if (objNo == ELLIPSE)
- {
- CDrawOval * temp = new CDrawOval();
- temp->m_pView = this;
- CDrawObj * ele = (CDrawObj *)temp;
- return ele;
- }
- if (objNo == LINE)
- {
- CDrawLine * temp = new CDrawLine();
- temp->m_pView = this;
- CDrawObj * ele = (CDrawObj *)temp;
- return ele;
- }
- if (objNo == BREAKER)
- {
- CDrawBreaker * temp = new CDrawBreaker();
- temp->m_pView = this;
- CDrawObj * ele = (CDrawObj *)temp;
- return ele;
- }
- if (objNo == SWITCH)
- {
- CDrawSwitch * temp = new CDrawSwitch();
- temp->m_pView = this;
- CDrawObj * ele = (CDrawObj *)temp;
- return ele;
- }
- if (objNo == GRID)
- {
- CDrawGrid * temp = new CDrawGrid();
- temp->m_pView = this;
- CDrawObj * ele = (CDrawObj *)temp;
- return ele;
- }
- if (objNo == BitmapShape)
- {
- CDrawBitmap * temp = new CDrawBitmap();
- temp->m_pView = this;
- CDrawObj * ele = (CDrawObj *)temp;
- return ele;
- }
- if( objNo == GifShape )
- {
- CDrawGif* temp = new CDrawGif();
- temp->m_pView = this;
- CDrawObj* ele = (CDrawObj *)temp;
- return ele;
- }
- if (objNo == TRANSFER)
- {
- CDrawTransfer * temp = new CDrawTransfer();
- temp->m_pView = this;
- CDrawObj * ele = (CDrawObj *)temp;
- return ele;
- }
- if (objNo == ARC)
- {
- CDrawArc * temp = new CDrawArc();
- temp->m_pView = this;
- CDrawObj * ele = (CDrawObj *)temp;
- return ele;
- }
- if (objNo == ARROW)
- {
- CDrawArrow * temp = new CDrawArrow();
- temp->m_pView = this;
- CDrawObj * ele = (CDrawObj *)temp;
- return ele;
- }
- if (objNo == POLYGON)
- {
- CDrawPoly * temp = new CDrawPoly();
- temp->m_pView = this;
- CDrawObj * ele = (CDrawObj *)temp;
- return ele;
- }
- if (objNo == ZHELINE)
- {
- CDrawMLine * temp = new CDrawMLine();
- temp->m_pView = this;
- CDrawObj * ele = (CDrawObj *)temp;
- return ele;
- }
- if (objNo == PIPE)
- {
- CDrawPipe * temp = new CDrawPipe();
- temp->m_pView = this;
- CDrawObj * ele = (CDrawObj *)temp;
- return ele;
- }
- if (objNo == ZHEPIPE)
- {
- CDrawZhePipe * temp = new CDrawZhePipe();
- temp->m_pView = this;
- CDrawObj * ele = (CDrawObj *)temp;
- return ele;
- }
- if ( objNo == YPIPE)
- {
- CDrawYPipe * temp = new CDrawYPipe();
- temp->m_pView = this;
- CDrawObj * ele = (CDrawObj *)temp;
- return ele;
- }
- if ( objNo == WatchShape)
- {
- CDrawWatch * temp = new CDrawWatch();
- temp->m_pView = this;
- CDrawObj * ele = (CDrawObj *)temp;
- return ele;
- }
- if ( objNo == SINGLEBAR)
- {
- CDrawSingleBar * temp = new CDrawSingleBar();
- temp->m_pView = this;
- CDrawObj * ele = (CDrawObj *)temp;
- return ele;
- }
- if ( objNo == ROUNDRECT )
- {
- CDrawRoundRect * temp = new CDrawRoundRect();
- temp->m_pView = this;
- CDrawObj * ele = (CDrawObj *)temp;
- return ele;
- }
- if ( objNo == PIE )
- {
- CDrawPie* temp = new CDrawPie();
- temp->m_pView = this;
- CDrawObj * ele = (CDrawObj *)temp;
- return ele;
- }
- if ( objNo == FAN )
- {
- CDrawFan* temp = new CDrawFan();
- temp->m_pView = this;
- CDrawObj * ele = (CDrawObj *)temp;
- return ele;
- }
- if ( objNo == HISCurveShape )
- {
- CDrawHisCurve* temp = new CDrawHisCurve();
- temp->m_pView = this;
- CDrawObj * ele = (CDrawObj *)temp;
- return ele;
- }
- if ( objNo == REPORT )
- {
- CDrawTable* temp = new CDrawTable();
- temp->m_pView = this;
- CDrawObj * ele = (CDrawObj *)temp;
- return ele;
- }
- if ( objNo == OCX )
- {
- CDrawOCX* temp = new CDrawOCX();
- temp->m_pView = this;
- CDrawObj * ele = (CDrawObj *)temp;
- return ele;
- }
- if ( objNo == GIF )
- {
- CDrawGif* temp = new CDrawGif();
- temp->m_pView = this;
- CDrawObj * ele = (CDrawObj *)temp;
- return ele;
- }
- if ( objNo == FLASH )
- {
- CDrawFlash* temp = new CDrawFlash();
- temp->m_pView = this;
- CDrawObj * ele = (CDrawObj *)temp;
- return ele;
- }
-
- //if ( objNo == FLASH )
- //{
- // CDrawFlash* temp = new CDrawFlash();
- // temp->m_pView = this;
- // CDrawObj * ele = (CDrawObj *)temp;
- // return ele;
- //}
- return NULL;
- }
- void CIDEView::OnPointer()
- {
- g_nElementNo = 0;
- }
- void CIDEView::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
- {
- int n = nRepCnt;
- BOOL bShiftDown = (GetKeyState(VK_SHIFT)&0xf0);
- if(!bShiftDown)
- {
- if(GetKeyState(VK_CONTROL)&0xf0)
- {
- n *= 10;
- }
- }
- switch(nChar)
- {
- case VK_UP:
- if(bShiftDown) KeyMove(0,0,0,-n);
- else KeyMove(0,-n,0,-n);
- m_bModified = TRUE;
- break;
- case VK_DOWN:
- if(bShiftDown) KeyMove(0,0,0,n);
- else KeyMove(0,n,0,n);
- m_bModified = TRUE;
- break;
- case VK_LEFT:
- if(bShiftDown) KeyMove(0,0,-n,0);
- else KeyMove(-n,0,-n,0);
- m_bModified = TRUE;
- break;
- case VK_RIGHT:
- if(bShiftDown) KeyMove(0,0,n,0);
- else KeyMove(n,0,n,0);
- m_bModified = TRUE;
- break;
- case VK_DELETE:
- #if 0
- POSITION pos = m_selection.GetHeadPosition();
- while(pos != NULL)
- {
- CDrawObj *pObj = m_selection.GetNext(pos);
- Remove(pObj);
- delete pObj;
- m_bModified = TRUE;
- }
- m_selection.RemoveAll();
- #endif
- for(POSITION pos = m_selection.GetHeadPosition();pos!=NULL;)
- {
- POSITION pos1 = pos ; //要在这里做一个备份
- CDrawObj *pObj = m_selection.GetNext(pos);//他会改变 pos的值
- Remove(pObj);
- if( pObj != NULL )
- {
- delete pObj;
- pObj = NULL;
- }
- //m_selection.RemoveAt(pos1);
- m_bModified = TRUE;
- }
- m_selection.RemoveAll();
- break;
- }
- Invalidate(FALSE);
- CScrollView::OnKeyDown(nChar, nRepCnt, nFlags);
- }
- void CIDEView::KeyMove(int x1,int y1,int x2,int y2)
- {
- POSITION pos = m_selection.GetHeadPosition();
- while(pos != NULL)
- {
- CDrawObj* pObj = m_selection.GetNext(pos);
- CRect rect = pObj->m_rect;
- if(rect.left<rect.right)
- {
- rect.left += x1;
- rect.right += x2;
- }
- else
- {
- rect.left += x2;
- rect.right += x1;
- }
- if(rect.top<rect.bottom)
- {
- rect.top += y1;
- rect.bottom += y2;
- }
- else
- {
- rect.top += y2;
- rect.bottom += y1;
- }
- pObj->MoveTo(rect);
- m_bModified = TRUE;
- }
- }
- CDrawObj* CIDEView::ObjectAt(CPoint point)
- {
- CRect rect(point, CSize(1, 1));
- POSITION pos = m_pGraph->m_DrawObjList.GetTailPosition();
- while(pos != NULL)
- {
- CDrawObj* pObj = m_pGraph->m_DrawObjList.GetPrev(pos);
- if( pObj->Intersects(rect) && pObj->m_bShow )
- return pObj;
- }
- return NULL;
- }
- BOOL CIDEView::IsSelected(CDrawObj* pDrawObj)
- {
- return m_selection.Find((CObject *)pDrawObj) != NULL;
- }
- void CIDEView::Select(CDrawObj* pObj, BOOL bAdd)
- {
- if(!bAdd)
- {
- POSITION pos = m_selection.GetHeadPosition();
- while(pos != NULL)
- {
- CDrawObj* pObj = m_selection.GetNext(pos);
- pObj->Invalidate();
- }
- m_selection.RemoveAll();
- }
- if(pObj == NULL||IsSelected(pObj)) return;
- {
- m_selection.AddTail(pObj);
- pObj->Invalidate();
- }
- }
- void CIDEView::Remove(CDrawObj* pObj)
- {
- POSITION pos;
- pos = m_selection.Find(pObj);
- if(pos != NULL) m_selection.RemoveAt(pos);
- pos = m_pGraph->m_DrawObjList.Find(pObj);
- if(pos != NULL) m_pGraph->m_DrawObjList.RemoveAt(pos);
- m_bModified = TRUE;
- }
- void CIDEView::OnFileNew()
- {
- if(m_bModified)
- {
- if(MessageBox(g_strSaveModify,g_strSelect,MB_YESNO|MB_ICONQUESTION) == IDYES)
- OnFileSave();
- }
- m_selection.RemoveAll();
- m_freezed.RemoveAll();
- m_pGraph->SetPicFile("");
- m_pGraph->Load();
- Invalidate(FALSE);
- POINT point;
- point.x = 0;
- point.y = 0;
- ScrollToPosition(point);
- m_bModified = TRUE;
- }
- void CIDEView::OnFileOpen()
- {
- if(m_bModified)
- {
- if(MessageBox(g_strSaveModify,g_strSelect,MB_YESNO|MB_ICONQUESTION) == IDYES)
- OnFileSave();
- }
- DWORD dwFlags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT;
- CString strFindPicFile = "";
- LPSTR lpszFile = (char*)(const char*)strFindPicFile;
- LPSTR lpszFilter = (char *)(LPCTSTR)g_strPictureFile2;
- CFileDialog dlg(TRUE,".view",lpszFile,dwFlags,lpszFilter);
- if(dlg.DoModal() == IDOK)
- {
- m_selection.RemoveAll();
- m_freezed.RemoveAll();
- CString strPicFile = dlg.GetPathName();
- ASSERT(!strPicFile.IsEmpty());
- m_pGraph->SetPicFile(strPicFile);
- m_pGraph->Load();
- //应该保存
- char tmpPathc[_MAX_PATH+1];
- GetTempPath(_MAX_PATH,tmpPathc);
- CString tmpPath = tmpPathc;
- CString oldFile = m_pGraph->m_strPicFile;
- m_pGraph->m_strPicFile = _T(tmpPath+"\\VDTemp\\"+"\\first.ed");
- m_pGraph->Store();
- m_pGraph->m_strPicFile = oldFile;
- RefreshScrollSizes();
- POINT point;
- point.x = 0;
- point.y = 0;
- ScrollToPosition(point);
- m_bModified = FALSE;
- }
- }
- void CIDEView::OnFileSave()
- {
- if(m_pGraph->m_strPicFile.IsEmpty())
- OnFileSaveAs();
- else
- {
- CRect rect = CRect(CPoint(0,0),m_pGraph->m_sizePic);
- POSITION pos = m_pGraph->m_DrawObjList.GetHeadPosition();
- while(pos != NULL)
- {
- CDrawObj *pObj = m_pGraph->m_DrawObjList.GetNext(pos);
- CRect r = pObj->m_rect;
- r.NormalizeRect();
- if((r & rect).IsRectEmpty())
- {
- Remove(pObj);
- delete pObj;
- }
- }
- m_pGraph->Store();
- m_bModified = FALSE;
- }
- }
- void CIDEView::FileSave()
- {
- if(m_pGraph->m_strPicFile.IsEmpty())
- OnFileSaveAs();
- else
- {
- CRect rect = CRect(CPoint(0,0),m_pGraph->m_sizePic);
- POSITION pos = m_pGraph->m_DrawObjList.GetHeadPosition();
- while(pos != NULL)
- {
- CDrawObj *pObj = m_pGraph->m_DrawObjList.GetNext(pos);
- CRect r = pObj->m_rect;
- r.NormalizeRect();
- if((r & rect).IsRectEmpty())
- {
- Remove(pObj);
- delete pObj;
- }
- }
- m_pGraph->Store();
- m_bModified = FALSE;
- }
- }
- void CIDEView::OnFileSaveAs()
- {
- DWORD dwFlags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT;
- CString strFindPicFile = "";
- LPSTR lpszFile = (char*)(const char*)strFindPicFile;
- LPSTR lpszFilter = (char *)(LPCTSTR)g_strPictureFile2;
- CFileDialog dlg(FALSE,".view",lpszFile,dwFlags,lpszFilter);
- if(dlg.DoModal() == IDOK)
- {
- CString strPicFile = dlg.GetPathName();
- ASSERT(!strPicFile.IsEmpty());
- m_pGraph->SetPicFile(strPicFile);
- OnFileSave();
- }
- }
- void CIDEView::RefreshScrollSizes(void)
- {
- CSize sizeTotal = m_pGraph->m_sizePic;
- CSize sizePage = CSize(200,200);
- CSize sizeLine = CSize(10,10);
- SetScrollSizes(MM_TEXT,sizeTotal,sizePage,sizeLine);
- Invalidate(FALSE);
- }
- void CIDEView::OnAppExit()
- {
- if(m_bModified)
- {
- if(MessageBox(g_strSaveModify,g_strSelect,MB_YESNO|MB_ICONQUESTION) == IDYES)
- OnFileSave();
- }
- CMainFrame *pMainFrm=(CMainFrame*)AfxGetApp()->m_pMainWnd;
- pMainFrm->OnSuperEnd();
- }
- CRect CIDEView::GetAlignRect(void)
- {
- CDrawObj* pObj = m_selection.GetTail();
- CRect rect = pObj->m_rect;
- rect.NormalizeRect();
- return rect;
- }
- void CIDEView::OnPrint(CDC* pDC, CPrintInfo* pInfo)
- {
- CString sTemp;
- int nTemp=0;
- if(m_pGraph->m_Type == 0)
- {
- int nOffsetX = pDC->GetDeviceCaps(PHYSICALOFFSETX);
- int nOffsetY = pDC->GetDeviceCaps(PHYSICALOFFSETY);
- int nLogPixelX = pDC->GetDeviceCaps(LOGPIXELSX);
- int nLogPixelY = pDC->GetDeviceCaps(LOGPIXELSY);
- pDC->SetMapMode(MM_ISOTROPIC);
- pDC->SetWindowExt(100,100);
- pDC->SetViewportExt(nLogPixelX,nLogPixelY);
- pDC->SetViewportOrg(-nOffsetX,-nOffsetY);
- m_pGraph->Draw(pDC,sTemp,nTemp);
- }
- else
- {
- CSize size = m_pGraph->m_sizePic;
- int nHScale = pInfo->m_rectDraw.Width() / size.cx;
- int nVScale = pInfo->m_rectDraw.Height() / size.cy;
- int nScale = min(nHScale,nVScale);
- pDC->SetMapMode(MM_ISOTROPIC);
- pDC->SetWindowExt(1000,1000);
- pDC->SetViewportExt(1000*nScale,1000*nScale);
- int nHOffset = pInfo->m_rectDraw.Width() - nScale*size.cx;
- int nVOffset = pInfo->m_rectDraw.Height() - nScale*size.cy;
- pDC->SetViewportOrg(nHOffset/2,nVOffset/2);
- m_pGraph->Print(pDC);
- }
- }
- void CIDEView::OnUpdateDeskGrid(CCmdUI* pCmdUI)
- {
- if ( g_bRun ) {
- pCmdUI->Enable(FALSE);
- }
- else
- pCmdUI->Enable(TRUE);
- pCmdUI->SetCheck(m_pGraph->m_bGrid);
- }
- void CIDEView::OnUpdateEditFreeze(CCmdUI* pCmdUI)
- {
- pCmdUI->SetCheck(m_bFreezed);
- }
- //选出载鼠标拖动区域的图元
- void CIDEView::ObjectIn()
- {
- POSITION pos = m_pGraph->m_DrawObjList.GetTailPosition();
- while(pos != NULL)
- {
- CDrawObj* pObj = m_pGraph->m_DrawObjList.GetPrev(pos);
- CRect r = pObj->m_rect;
- r.NormalizeRect();
- if ((r.left>m_mouseRect.left)&&(r.right<m_mouseRect.right)
- &&(r.bottom<m_mouseRect.bottom)&&(r.top>m_mouseRect.top))
- m_selection.AddTail(pObj);
- }
- }
- //用作do/redo的
- void CIDEView::ExchangeSave()
- {
- char tmpPathc[_MAX_PATH+1];
- GetTempPath(_MAX_PATH,tmpPathc);
- CString tmpPath = tmpPathc;
- CFile::Remove(_T(tmpPath+"\\VDTemp\\"+"\\Six.ed"));
- CFile::Rename(_T(tmpPath+"\\VDTemp\\"+"\\Fifth.ed"),_T(tmpPath+"\\VDTemp\\"+"\\Six.ed"));
- CFile::Rename(_T(tmpPath+"\\VDTemp\\"+"\\Forth.ed"),_T(tmpPath+"\\VDTemp\\"+"\\Fifth.ed"));
- CFile::Rename(_T(tmpPath+"\\VDTemp\\"+"\\Third.ed"),_T(tmpPath+"\\VDTemp\\"+"\\Forth.ed"));
- CFile::Rename(_T(tmpPath+"\\VDTemp\\"+"\\Second.ed"),_T(tmpPath+"\\VDTemp\\"+"\\Third.ed"));
- CFile::Rename(_T(tmpPath+"\\VDTemp\\"+"\\First.ed"),_T(tmpPath+"\\VDTemp\\"+"\\Second.ed"));
- CString oldFile = m_pGraph->m_strPicFile;
- m_pGraph->m_strPicFile = _T(tmpPath+"\\VDTemp\\"+"\\First.ed");
- m_pGraph->Store();
- m_pGraph->m_strPicFile = oldFile;
- }
- void CIDEView::OnRedo() // 重做;
- {
- POSITION pos = m_selection.GetHeadPosition();
- while(pos != NULL)
- {
- CDrawObj* pObj = m_selection.GetNext(pos);
- pObj->Invalidate();
- }
- m_selection.RemoveAll();
- char tmpPathc[_MAX_PATH+1];
- GetTempPath(_MAX_PATH,tmpPathc);
- CString tmpPath = tmpPathc;
- CString oldFile = m_pGraph->m_strPicFile;
- if (m_nRudoPosition == -1)
- m_pGraph->m_strPicFile = _T(tmpPath+"\\VDTemp\\"+"\\first.ed");
- else if (m_nRudoPosition == -2)
- m_pGraph->m_strPicFile = _T(tmpPath+"\\VDTemp\\"+"\\second.ed");
- else if (m_nRudoPosition == -3)
- m_pGraph->m_strPicFile = _T(tmpPath+"\\VDTemp\\"+"\\third.ed");
- else if (m_nRudoPosition == -4)
- m_pGraph->m_strPicFile = _T(tmpPath+"\\VDTemp\\"+"\\forth.ed");
- else if (m_nRudoPosition == -5)
- m_pGraph->m_strPicFile = _T(tmpPath+"\\VDTemp\\"+"\\fifth.ed");
- else
- return;
- m_pGraph->Load();
- m_pGraph->m_strPicFile = oldFile;
- m_nRudoPosition++;
- m_nCanUndoTimes++;
- m_nCanRedoTimes--;
- Invalidate(FALSE);
- }
- void CIDEView::OnUndo() // 撤销;
- {
- POSITION pos = m_selection.GetHeadPosition();
- while(pos != NULL)
- {
- CDrawObj* pObj = m_selection.GetNext(pos);
- pObj->Invalidate();
- }
- m_selection.RemoveAll();
- char tmpPathc[_MAX_PATH+1];
- GetTempPath(_MAX_PATH,tmpPathc);
- CString tmpPath = tmpPathc;
- CString oldFile = m_pGraph->m_strPicFile;
- if (m_nRudoPosition == 0)
- m_pGraph->m_strPicFile = _T(tmpPath+"\\VDTemp\\"+"\\second.ed");
- if (m_nRudoPosition == -1)
- m_pGraph->m_strPicFile = _T(tmpPath+"\\VDTemp\\"+"\\third.ed");
- if (m_nRudoPosition == -2)
- m_pGraph->m_strPicFile = _T(tmpPath+"\\VDTemp\\"+"\\forth.ed");
- if (m_nRudoPosition == -3)
- m_pGraph->m_strPicFile = _T(tmpPath+"\\VDTemp\\"+"\\fifth.ed");
- if (m_nRudoPosition == -4)
- m_pGraph->m_strPicFile = _T(tmpPath+"\\VDTemp\\"+"\\six.ed");
- if(m_nRudoPosition == -5) return;
- m_pGraph->Load();
- m_pGraph->m_strPicFile = oldFile;
- m_nRudoPosition--;
- m_nCanUndoTimes--;
- m_nCanRedoTimes++;
- Invalidate(FALSE);
- }
- void CIDEView::FileProcess()
- {
- char tmpPathc[_MAX_PATH+1];
- GetTempPath(_MAX_PATH,tmpPathc);
- CString tmpPath = tmpPathc;
- if(m_nRudoPosition == -1)
- {
- CString oldFile = m_pGraph->m_strPicFile;
- m_pGraph->m_strPicFile = _T(tmpPath+"\\VDTemp\\"+"\\first.ed");
- m_pGraph->Store();
- m_pGraph->m_strPicFile = oldFile;
- }
-
- if(m_nRudoPosition == -2)
- {
- CFile::Remove(_T(tmpPath+"\\VDTemp\\"+"\\Second.ed"));
- CFile::Rename(_T(tmpPath+"\\VDTemp\\"+"\\Third.ed"),_T(tmpPath+"\\VDTemp\\"+"\\second.ed"));
- CFile::Rename(_T(tmpPath+"\\VDTemp\\"+"\\Forth.ed"),_T(tmpPath+"\\VDTemp\\"+"\\third.ed"));
- CFile::Rename(_T(tmpPath+"\\VDTemp\\"+"\\Fifth.ed"),_T(tmpPath+"\\VDTemp\\"+"\\forth.ed"));
- CFile::Rename(_T(tmpPath+"\\VDTemp\\"+"\\Six.ed"),_T(tmpPath+"\\VDTemp\\"+"\\fifth.ed"));
- CFile file6(_T(tmpPath+"\\VDTemp\\"+"\\Six.ed"),CFile::modeReadWrite|CFile::modeCreate);
- file6.Close();
- CString oldFile = m_pGraph->m_strPicFile;
- if (m_nRudoPosition == 0)
- m_pGraph->m_strPicFile = _T(tmpPath+"\\VDTemp\\"+"\\first.ed");
- m_pGraph->Store();
- m_pGraph->m_strPicFile = oldFile;
- }
- if(m_nRudoPosition == -3)
- {
- CFile::Remove(_T(tmpPath+"\\VDTemp\\"+"\\Second.ed"));
- CFile::Remove(_T(tmpPath+"\\VDTemp\\"+"\\Third.ed"));
- CFile::Rename(_T(tmpPath+"\\VDTemp\\"+"\\Forth.ed"),_T(tmpPath+"\\VDTemp\\"+"\\second.ed"));
- CFile::Rename(_T(tmpPath+"\\VDTemp\\"+"\\Fifth.ed"),_T(tmpPath+"\\VDTemp\\"+"\\third.ed"));
- CFile::Rename(_T(tmpPath+"\\VDTemp\\"+"\\Six.ed"),_T(tmpPath+"\\VDTemp\\"+"\\forth.ed"));
- CFile file6(_T(tmpPath+"\\VDTemp\\"+"\\Six.ed"),CFile::modeReadWrite|CFile::modeCreate);
- file6.Close();
- CFile file5(_T(tmpPath+"\\VDTemp\\"+"\\fifth.ed"),CFile::modeReadWrite|CFile::modeCreate);
- file5.Close();
- CString oldFile = m_pGraph->m_strPicFile;
- if (m_nRudoPosition == 0)
- m_pGraph->m_strPicFile = _T(tmpPath+"\\VDTemp\\"+"\\first.ed");
- m_pGraph->Store();
- m_pGraph->m_strPicFile = oldFile;
- }
-
- if(m_nRudoPosition == -4)
- {
- CFile::Remove(_T(tmpPath+"\\VDTemp\\"+"\\Second.ed"));
- CFile::Remove(_T(tmpPath+"\\VDTemp\\"+"\\third.ed"));
- CFile::Remove(_T(tmpPath+"\\VDTemp\\"+"\\Forth.ed"));
- CFile::Rename(_T(tmpPath+"\\VDTemp\\"+"\\fifth.ed"),_T(tmpPath+"\\VDTemp\\"+"\\second.ed"));
- CFile::Rename(_T(tmpPath+"\\VDTemp\\"+"\\six.ed"),_T(tmpPath+"\\VDTemp\\"+"\\third.ed"));
- CFile::Rename(_T(tmpPath+"\\VDTemp\\"+"\\Fifth.ed"),_T(tmpPath+"\\VDTemp\\"+"\\forth.ed"));
- CFile::Rename(_T(tmpPath+"\\VDTemp\\"+"\\Six.ed"),_T(tmpPath+"\\VDTemp\\"+"\\fifth.ed"));
- CFile file4(_T(tmpPath+"\\VDTemp\\"+"\\forth.ed"),CFile::modeReadWrite|CFile::modeCreate);
- file4.Close();
- CFile file6(_T(tmpPath+"\\VDTemp\\"+"\\Six.ed"),CFile::modeReadWrite|CFile::modeCreate);
- file6.Close();
- CFile file5(_T(tmpPath+"\\VDTemp\\"+"\\fifth.ed"),CFile::modeReadWrite|CFile::modeCreate);
- file5.Close();
- CString oldFile = m_pGraph->m_strPicFile;
- if (m_nRudoPosition == 0)
- m_pGraph->m_strPicFile = _T(tmpPath+"\\VDTemp\\"+"\\first.ed");
- m_pGraph->Store();
- m_pGraph->m_strPicFile = oldFile;
- }
-
- if(m_nRudoPosition == -5)
- {
- CFile::Remove(_T(tmpPath+"\\VDTemp\\"+"\\Second.ed"));
- CFile::Remove(_T(tmpPath+"\\VDTemp\\"+"\\third.ed"));
- CFile::Remove(_T(tmpPath+"\\VDTemp\\"+"\\Forth.ed"));
- CFile::Remove(_T(tmpPath+"\\VDTemp\\"+"\\fifth.ed"));
- CFile::Rename(_T(tmpPath+"\\VDTemp\\"+"\\six.ed"),_T(tmpPath+"\\VDTemp\\"+"\\second.ed"));
- CFile file4(_T(tmpPath+"\\VDTemp\\"+"\\forth.ed"),CFile::modeReadWrite|CFile::modeCreate);
- file4.Close();
- CFile file6(_T(tmpPath+"\\VDTemp\\"+"\\Six.ed"),CFile::modeReadWrite|CFile::modeCreate);
- file6.Close();
- CFile file5(_T(tmpPath+"\\VDTemp\\"+"\\fifth.ed"),CFile::modeReadWrite|CFile::modeCreate);
- file5.Close();
- CFile file3(_T(tmpPath+"\\VDTemp\\"+"\\third.ed"),CFile::modeReadWrite|CFile::modeCreate);
- file3.Close();
- CString oldFile = m_pGraph->m_strPicFile;
- if (m_nRudoPosition == 0)
- m_pGraph->m_strPicFile = _T(tmpPath+"\\VDTemp\\"+"\\first.ed");
- m_pGraph->Store();
- m_pGraph->m_strPicFile = oldFile;
- }
- }
- void CIDEView::OnUpdateUndo(CCmdUI* pCmdUI)
- {
- if (g_bRun == FALSE && m_nCanUndoTimes) {
- pCmdUI->Enable(TRUE);
- }
- else
- pCmdUI->Enable(FALSE);
- }
- void CIDEView::OnUpdateRedo(CCmdUI* pCmdUI)
- {
- if (g_bRun == FALSE && m_nCanRedoTimes) {
- pCmdUI->Enable(TRUE);
- }
- else
- pCmdUI->Enable(FALSE);
- }
- void CIDEView::OnPicsize()
- {
- CPicSizeDlg dlg;
- dlg.m_nPictureHeight = m_pGraph->m_sizePic.cy;
- dlg.m_nPictureWidth = m_pGraph->m_sizePic.cx;
- dlg.m_nGridSize = m_pGraph->m_sizeGrid.cx;
- dlg.m_clrBack = m_pGraph->m_clrBack;
- dlg.m_bGrid = m_pGraph->m_bGrid;
- if(dlg.DoModal() == IDOK)
- {
- m_pGraph->m_sizePic.cy = dlg.m_nPictureHeight;
- m_pGraph->m_sizePic.cx = dlg.m_nPictureWidth;
- m_pGraph->m_sizeGrid.cy = dlg.m_nGridSize;
- m_pGraph->m_sizeGrid.cx = dlg.m_nGridSize;
- m_pGraph->m_clrBack = dlg.m_clrBack;
- m_pGraph->m_bGrid = dlg.m_bGrid;
- m_bModified = TRUE;
- }
- RefreshScrollSizes();
- }
- void CIDEView::OnUpdateAlignBottom(CCmdUI* pCmdUI)
- {
- if((m_selection.GetCount()>1))
- pCmdUI->Enable(TRUE);
- else
- pCmdUI->Enable(FALSE);
- }
- void CIDEView::OnUpdateAlignHcenter(CCmdUI* pCmdUI)
- {
- if((m_selection.GetCount()>1))
- pCmdUI->Enable(TRUE);
- else
- pCmdUI->Enable(FALSE);
- }
- void CIDEView::OnUpdateAlignLeft(CCmdUI* pCmdUI)
- {
- if((m_selection.GetCount()>1))
- pCmdUI->Enable(TRUE);
- else
- pCmdUI->Enable(FALSE);
- }
- void CIDEView::OnUpdateAlignRight(CCmdUI* pCmdUI)
- {
- if((m_selection.GetCount()>1))
- pCmdUI->Enable(TRUE);
- else
- pCmdUI->Enable(FALSE);
- }
- void CIDEView::OnUpdateAlignTop(CCmdUI* pCmdUI)
- {
- if((m_selection.GetCount()>1))
- pCmdUI->Enable(TRUE);
- else
- pCmdUI->Enable(FALSE);
- }
- void CIDEView::OnUpdateAlignVcenter(CCmdUI* pCmdUI)
- {
- if((m_selection.GetCount()>1))
- pCmdUI->Enable(TRUE);
- else
- pCmdUI->Enable(FALSE);
- }
- void CIDEView::OnUpdateEditHinvert(CCmdUI* pCmdUI)
- {
- if((m_selection.GetCount()>0))
- pCmdUI->Enable(TRUE);
- else
- pCmdUI->Enable(FALSE);
- }
- void CIDEView::OnUpdateEditMovetoback(CCmdUI* pCmdUI)
- {
- if((m_selection.GetCount()>0))
- pCmdUI->Enable(TRUE);
- else
- pCmdUI->Enable(FALSE);
- }
- void CIDEView::OnUpdateEditMovetofront(CCmdUI* pCmdUI)
- {
- if((m_selection.GetCount()>0))
- pCmdUI->Enable(TRUE);
- else
- pCmdUI->Enable(FALSE);
- }
- void CIDEView::OnUpdateEditVinvert(CCmdUI* pCmdUI)
- {
- if((m_selection.GetCount()>0))
- pCmdUI->Enable(TRUE);
- else
- pCmdUI->Enable(FALSE);
- }
- void CIDEView::OnUpdateEditCopy(CCmdUI* pCmdUI)
- {
- if(m_selection.GetCount()>0)
- pCmdUI->Enable(TRUE);
- else
- pCmdUI->Enable(FALSE);
- }
- void CIDEView::OnUpdateEditCut(CCmdUI* pCmdUI)
- {
- if(m_selection.GetCount()>0)
- pCmdUI->Enable(TRUE);
- else
- pCmdUI->Enable(FALSE);
- }
- void CIDEView::OnUpdateEditClear(CCmdUI* pCmdUI)
- {
- if(m_selection.GetCount()>0)
- pCmdUI->Enable(TRUE);
- else
- pCmdUI->Enable(FALSE);
- }
- void CIDEView::OnUpdateEditPaste(CCmdUI* pCmdUI)
- {
- #if 1
- if(g_Copied.GetCount()>0)
- pCmdUI->Enable(TRUE);
- else
- pCmdUI->Enable(FALSE);
- #else
- if(m_copied.GetCount()>0)
- pCmdUI->Enable(TRUE);
- else
- pCmdUI->Enable(FALSE);
- #endif
- }
- void CIDEView::OnDrawTline()
- {
- g_nElementNo = TlineShape;
- }
- void CIDEView::OnDrawText()
- {
- g_nElementNo = TextShape;
- }
- void CIDEView::OnDrawRect()
- {
- g_nElementNo = RectShape;
- }
- void CIDEView::OnDrawData()
- {
- g_nElementNo = DataShape;
- }
- void CIDEView::OnDrawBitmap()
- {
- g_nElementNo = BitmapShape;
- }
- void CIDEView::OnDrawCurve()
- {
- g_nElementNo = RealCurveShape;
- }
- void CIDEView::OnDrawWatch()
- {
- g_nElementNo = WatchShape;
- }
- void CIDEView::OnDrawBar()
- {
- g_nElementNo = BarShape;
- }
- void CIDEView::OnDraw3drect()
- {
- g_nElementNo = BUTTON;
- }
- void CIDEView::OnDraw3circle()
- {
- g_nElementNo = ThreeDCircleShape;
- }
- void CIDEView::OnDrawOCX()
- {
- g_nElementNo = OCX;
- }
- void CIDEView::OnDrawGIF()
- {
- g_nElementNo = GIF;
- }
- void CIDEView::OnDrawFlash()
- {
- g_nElementNo = FLASH;
- }
- void CIDEView::OnUpdatePointer(CCmdUI* pCmdUI)
- {
- if(g_nElementNo == 0)
- pCmdUI->SetCheck(TRUE);
- else
- pCmdUI->SetCheck(FALSE);
- }
- void CIDEView::ChangeView()
- {
- if(g_strViewName != "")
- {
- if(m_bModified && !g_bStartRun )
- {
- if(MessageBox(g_strSaveModify,g_strSelect,MB_YESNO|MB_ICONQUESTION) == IDYES)
- OnFileSave();
- }
- m_selection.RemoveAll();
- m_freezed.RemoveAll();
- m_pGraph->SetPicFile(g_strViewName);
- m_pGraph->Load();
- m_pGraph->SetView(this);
- m_pCurActionObj = NULL;
- m_nCurActionType = -1;
- Invalidate(FALSE);
- RefreshScrollSizes();
- POINT point;
- point.x = 0;
- point.y = 0;
- ScrollToPosition(point);
- m_bModified = FALSE;
- }
- }
- void CIDEView::OnTimer(UINT nIDEvent)
- {
- if (g_bRun)
- {
- #if VIEW_USE_THREAD
- #else
- if( m_pGraph )
- {
- m_pGraph->Fresh();
- //Invalidate(FALSE);//chn 刷新
- }
- #endif
- }
- CScrollView::OnTimer(nIDEvent);
- }
- void CIDEView::OnUpdateDraw3circle(CCmdUI* pCmdUI)
- {
- if (g_bRun == TRUE) {
- pCmdUI->Enable(FALSE);
- }
- else
- pCmdUI->Enable(TRUE);
- }
- void CIDEView::OnUpdateDraw3drect(CCmdUI* pCmdUI)
- {
- if (g_bRun == TRUE) {
- pCmdUI->Enable(FALSE);
- }
- else
- pCmdUI->Enable(TRUE);
- }
- void CIDEView::OnUpdateDrawData(CCmdUI* pCmdUI)
- {
- if (g_bRun == TRUE) {
- pCmdUI->Enable(FALSE);
- }
- else
- pCmdUI->Enable(TRUE);
- }
- void CIDEView::OnUpdateDrawRect(CCmdUI* pCmdUI)
- {
- if (g_bRun == TRUE) {
- pCmdUI->Enable(FALSE);
- }
- else
- pCmdUI->Enable(TRUE);
- }
- void CIDEView::OnUpdateDrawText(CCmdUI* pCmdUI)
- {
- if (g_bRun == TRUE) {
- pCmdUI->Enable(FALSE);
- }
- else
- pCmdUI->Enable(TRUE);
- }
- void CIDEView::OnUpdateDrawTline(CCmdUI* pCmdUI)
- {
- if (g_bRun == TRUE) {
- pCmdUI->Enable(FALSE);
- }
- else
- pCmdUI->Enable(TRUE);
- }
- void CIDEView::OnUpdateDrawBitmap(CCmdUI* pCmdUI)
- {
- if (g_bRun == TRUE) {
- pCmdUI->Enable(FALSE);
- }
- else
- pCmdUI->Enable(TRUE);
- }
- void CIDEView::OnUpdateDrawCurve(CCmdUI* pCmdUI)
- {
- if (g_bRun == TRUE) {
- pCmdUI->Enable(FALSE);
- }
- else
- pCmdUI->Enable(TRUE);
- }
- void CIDEView::OnUpdateDrawWatch(CCmdUI* pCmdUI)
- {
- if (g_bRun == TRUE) {
- pCmdUI->Enable(FALSE);
- }
- else
- pCmdUI->Enable(TRUE);
- }
- void CIDEView::OnUpdateDrawBar(CCmdUI* pCmdUI)
- {
- if (g_bRun == TRUE) {
- pCmdUI->Enable(FALSE);
- }
- else
- pCmdUI->Enable(TRUE);
- }
- void CIDEView::OnRButtonDown(UINT nFlags, CPoint point)
- {
- if (!g_bRun)
- {
- CPoint tmpPoint;
- GetCursorPos(&tmpPoint);
- CMenu menu;
- menu.LoadMenu(IDR_DRAW_POP);
- menu.GetSubMenu(0)->TrackPopupMenu(TPM_LEFTALIGN, tmpPoint.x, tmpPoint.y,this);
- }
- else
- {
- CPoint local = point;
- CDrawObj *pObj = ObjectAt(local);
- if(pObj != NULL)
- {
- CString sVarName;
- if( pObj->m_bVariant && pObj->m_strCaption!="" )
- sVarName = pObj->m_strCaption;
- else if( pObj->m_strDynShow!="" )
- sVarName = GetVarNameFromGS( pObj->m_strDynShow );
- else if( pObj->m_strDynForeCon!="" )
- sVarName = GetVarNameFromGS( pObj->m_strDynForeCon );
- else if( pObj->m_strDynBackCon!="" )
- sVarName = GetVarNameFromGS( pObj->m_strDynBackCon );
- else if( pObj->m_strDynLineCon!="" )
- sVarName = GetVarNameFromGS( pObj->m_strDynLineCon );
- else if( pObj->m_strHoriPos!="" )
- sVarName = GetVarNameFromGS( pObj->m_strHoriPos );
- else if( pObj->m_strHoriSize!="" )
- sVarName = GetVarNameFromGS( pObj->m_strHoriSize );
- else if( pObj->m_strVertiPos!="" )
- sVarName = GetVarNameFromGS( pObj->m_strVertiPos );
- else if( pObj->m_strVertiSize!="" )
- sVarName = GetVarNameFromGS( pObj->m_strVertiSize );
- else if( pObj->m_strCurrentCaption!="" )
- sVarName = GetVarNameFromGS( pObj->m_strCurrentCaption );
-
- if( pObj->IsKindOf( RUNTIME_CLASS(CDrawBitmap) ) && sVarName=="" )
- {
- if( ((CDrawBitmap *)pObj)->m_strDynCondition!="" )
- sVarName = GetVarNameFromGS( ((CDrawBitmap *)pObj)->m_strDynCondition );
- }
- if( pObj->IsKindOf( RUNTIME_CLASS(CDrawGif) ) && sVarName=="" )
- {
- if( ((CDrawGif *)pObj)->m_strDynCondition!="" )
- sVarName = GetVarNameFromGS( ((CDrawGif *)pObj)->m_strDynCondition );
- }
- if( sVarName!="" )
- {
- m_sVarName = sVarName;
- CPoint tmpPoint;
- GetCursorPos(&tmpPoint);
- CMenu menu;
- menu.LoadMenu(IDR_DRAW_POP);
- menu.GetSubMenu(1)->TrackPopupMenu(TPM_LEFTALIGN, tmpPoint.x, tmpPoint.y,this);
- }
- }
- }
- CScrollView::OnRButtonDown(nFlags, point);
- }
- void CIDEView::OnEditSave()
- {
- OnFileSave();
- }
- void CIDEView::OnUpdateEditSave(CCmdUI* pCmdUI)
- {
- if(m_bModified)
- pCmdUI->Enable(TRUE);
- else
- pCmdUI->Enable(FALSE);
- }
- BOOL CIDEView::OnEraseBkgnd(CDC* pDC)
- {
- return false;
- }
- void CIDEView::OnUpdatePicsize(CCmdUI* pCmdUI)
- {
- if (g_bRun == TRUE) {
- pCmdUI->Enable(FALSE);
- }
- else
- pCmdUI->Enable(TRUE);
- }
- void CIDEView::OnVerspace()
- {
- CDrawObj* pTop;
- CDrawObj* pBottom;
- int top = 2000;
- int bottom = 0;
- int heightSum = 0;
- int alignCount = 0;
- int nY = 0;
- // 先取top, bottom两个图元;
- POSITION pos = m_selection.GetHeadPosition();
- while(pos != NULL)
- {
- CDrawObj* pObj = m_selection.GetNext(pos);
- alignCount++;
- pObj->m_bAligned = false;
- CRect r = pObj->m_rect;
- r.NormalizeRect();
- if (r.top < top)
- {
- pTop = pObj;
- top = r.top;
- }
- if (r.bottom > bottom)
- {
- pBottom = pObj;
- bottom = r.bottom;
- }
- heightSum += r.Height();
- }
- pTop->m_bAligned = true;
- pBottom->m_bAligned = true;
- alignCount -= 2;
- int space = bottom - top - heightSum;
- int perSpace = space / (alignCount+1);
- nY = top + pTop->m_rect.Height() + perSpace;
-
- for (int i = 1; i <= alignCount; i++ )
- {
- POSITION pos = m_selection.GetHeadPosition();
- CDrawObj* curObj;
- int top1 = 2000;
- while(pos != NULL)
- {
- CDrawObj* pObj = m_selection.GetNext(pos);
- CRect rec = pObj->m_rect;
- rec.NormalizeRect();
- if ( !pObj->m_bAligned )
- {
- if ( rec.top < top1)
- {
- top1 = rec.top;
- curObj = pObj;
- }
- }
- }
-
- CRect r = curObj->m_rect;
- r.OffsetRect(0, nY - top1);
- curObj->MoveTo(r);
- curObj->m_bAligned = true;
- nY += (perSpace + r.Height());
- }
- m_bModified = TRUE;
- Invalidate(FALSE);
- }
- void CIDEView::OnUpdateVerspace(CCmdUI* pCmdUI)
- {
- if(m_selection.GetCount()>2)
- pCmdUI->Enable(TRUE);
- else
- pCmdUI->Enable(FALSE);
- }
- void CIDEView::OnSamewidth()
- {
- CRect rect = GetAlignRect();
- POSITION pos = m_selection.GetHeadPosition();
- while(pos != NULL)
- {
- CDrawObj* pObj = m_selection.GetNext(pos);
- CRect r = pObj->m_rect;
- r.NormalizeRect();
- r.right = r.left + (rect.right - rect.left);
- pObj->m_rect = r;
- m_bModified = TRUE;
- }
- Invalidate(FALSE);
- }
- void CIDEView::OnUpdateSamewidth(CCmdUI* pCmdUI)
- {
- if(m_selection.GetCount()>1)
- pCmdUI->Enable(TRUE);
- else
- pCmdUI->Enable(FALSE);
- }
- void CIDEView::OnSameheight()
- {
- CRect rect = GetAlignRect();
- POSITION pos = m_selection.GetHeadPosition();
- while(pos != NULL)
- {
- CDrawObj* pObj = m_selection.GetNext(pos);
- CRect r = pObj->m_rect;
- r.NormalizeRect();
- r.bottom = r.top + (rect.bottom - rect.top);
- pObj->m_rect = r;
- m_bModified = TRUE;
- }
- Invalidate(FALSE);
- }
- void CIDEView::OnHorspace()
- {
- CDrawObj* pLeft = NULL;
- CDrawObj* pRight = NULL;
- int left = 2000;
- int right = 0;
- int widthSum = 0;
- int alignCount = 0;
- int nX = 0;
- // 先取top, bottom两个图元;
- POSITION pos = m_selection.GetHeadPosition();
- while(pos != NULL)
- {
- CDrawObj* pObj = m_selection.GetNext(pos);
- alignCount++;
- pObj->m_bAligned = false;
- CRect r = pObj->m_rect;
- r.NormalizeRect();
- if (r.left < left)
- {
- pLeft = pObj;
- left = r.left;
- }
- if (r.right > right)
- {
- pRight = pObj;
- right = r.right;
- }
- widthSum += r.Width();
- }
- pLeft->m_bAligned = true;
- pRight->m_bAligned = true;
- alignCount -= 2;
- int space = right - left - widthSum;
- int perSpace = space / (alignCount+1);
- nX = left + pLeft->m_rect.Width() + perSpace;
-
- for (int i = 1; i <= alignCount; i++ )
- {
- POSITION pos = m_selection.GetHeadPosition();
- CDrawObj* curObj;
- int left1 = 2000;
- while(pos != NULL)
- {
- CDrawObj* pObj = m_selection.GetNext(pos);
- CRect rec = pObj->m_rect;
- rec.NormalizeRect();
- if ( !pObj->m_bAligned )
- {
- if ( rec.left < left1)
- {
- left1 = rec.left;
- curObj = pObj;
- }
- }
- }
-
- CRect r = curObj->m_rect;
- r.OffsetRect(nX - left1, 0);
- curObj->MoveTo(r);
- curObj->m_bAligned = true;
- nX += (perSpace + r.Width());
- }
- m_bModified = TRUE;
- Invalidate(FALSE);
- }
- void CIDEView::OnAllsame()
- {
- CRect rect = GetAlignRect();
- POSITION pos = m_selection.GetHeadPosition();
- while (pos != NULL)
- {
- CDrawObj* pObj = m_selection.GetNext(pos);
- CRect r = pObj->m_rect;
- r.NormalizeRect();
- r.bottom = r.top + (rect.bottom - rect.top);
- r.right = r.left + (rect.right - rect.left);
- pObj->m_rect = r;
- m_bModified = TRUE;
- }
- Invalidate(FALSE);
- }
- void CIDEView::OnUpdateSameheight(CCmdUI* pCmdUI)
- {
- if(m_selection.GetCount()>1)
- pCmdUI->Enable(TRUE);
- else
- pCmdUI->Enable(FALSE);
- }
- void CIDEView::OnUpdateHorspace(CCmdUI* pCmdUI)
- {
- if(m_selection.GetCount()>2)
- pCmdUI->Enable(TRUE);
- else
- pCmdUI->Enable(FALSE);
- }
- void CIDEView::OnUpdateAllsame(CCmdUI* pCmdUI)
- {
- if(m_selection.GetCount()>1)
- pCmdUI->Enable(TRUE);
- else
- pCmdUI->Enable(FALSE);
- }
- void CIDEView::OnEndPrintPreview(CDC* pDC, CPrintInfo* pInfo, POINT point, CPreviewView* pView)
- {
- CScrollView::OnEndPrintPreview(pDC, pInfo, point, pView);
- CMainFrame *pFrame = (CMainFrame*)AfxGetApp()->m_pMainWnd;
- pFrame->SetWindowText(g_strStoneuIspcms);
- pFrame->HideRunBar();
- pFrame->ShowWindow(SW_SHOWMAXIMIZED);
- pFrame->UpdateWindow();
- pFrame->RecalcLayout();
- }
- void CIDEView::OnOpenpic()
- {
- CPicListDlg dlg;
- if ( dlg.DoModal() == IDOK )
- {
- g_strViewName = _PICTUREDIR + dlg.m_strPicName;
- g_strViewName = g_strViewName + ".view";
- CMainFrame *pFrame = (CMainFrame*)AfxGetApp()->m_pMainWnd;
- CString strPath;
- strPath = g_strDirectory + CString("\\") + CString(g_strViewName);
- pFrame->AddIDEView( dlg.m_strPicName, strPath );
- }
- }
- void CIDEView::OnDrawArc()
- {
- g_nElementNo = ARC;
-
- }
- void CIDEView::OnDrawBreaker()
- {
- g_nElementNo = BREAKER;
-
- }
- void CIDEView::OnDrawFan()
- {
- g_nElementNo = FAN;
-
- }
- void CIDEView::OnDrawGrid()
- {
- g_nElementNo = GRID;
-
- }
- void CIDEView::OnDrawHiscurve()
- {
- g_nElementNo = HISCurveShape;
-
- }
- void CIDEView::OnDrawLine()
- {
- g_nElementNo = LINE;
-
- }
- void CIDEView::OnDrawPie()
- {
- g_nElementNo = PIE;
-
- }
- void CIDEView::OnDrawPipe()
- {
- g_nElementNo = PIPE;
- }
- void CIDEView::OnDrawPolygon()
- {
- g_nElementNo = POLYGON;
-
- }
- void CIDEView::OnDrawReport()
- {
- g_nElementNo = REPORT;
-
- }
- void CIDEView::OnDrawSinglebar()
- {
- g_nElementNo = SINGLEBAR;
-
- }
- void CIDEView::OnDrawTransfer()
- {
- g_nElementNo = TRANSFER;
-
- }
- void CIDEView::OnDrawYpipe()
- {
- g_nElementNo = YPIPE;
-
- }
- void CIDEView::OnDrawZheline()
- {
- g_nElementNo = ZHELINE;
- }
- void CIDEView::OnDrawZhepipe()
- {
- g_nElementNo = ZHEPIPE;
- }
- void CIDEView::OnDrawArrow()
- {
- g_nElementNo = ARROW;
- }
- void CIDEView::OnDrawEllipse()
- {
- g_nElementNo = ELLIPSE;
- }
- void CIDEView::OnDrawSwitch()
- {
- g_nElementNo = SWITCH;
- }
- void CIDEView::OnUpdateDrawSwitch(CCmdUI* pCmdUI)
- {
- pCmdUI->Enable(TRUE);
- }
- void CIDEView::OnUpdateDrawArc(CCmdUI* pCmdUI)
- {
- pCmdUI->Enable(TRUE);
-
- }
- void CIDEView::OnUpdateDrawArrow(CCmdUI* pCmdUI)
- {
- pCmdUI->Enable(TRUE);
-
- }
- void CIDEView::OnUpdateDrawBreaker(CCmdUI* pCmdUI)
- {
- pCmdUI->Enable(TRUE);
-
- }
- void CIDEView::OnUpdateDrawEllipse(CCmdUI* pCmdUI)
- {
- pCmdUI->Enable(TRUE);
-
- }
- void CIDEView::OnUpdateDrawFan(CCmdUI* pCmdUI)
- {
- pCmdUI->Enable(TRUE);
-
- }
- void CIDEView::OnUpdateDrawGrid(CCmdUI* pCmdUI)
- {
- pCmdUI->Enable(TRUE);
-
- }
- void CIDEView::OnUpdateDrawHiscurve(CCmdUI* pCmdUI)
- {
- pCmdUI->Enable(TRUE);
-
- }
- void CIDEView::OnUpdateDrawPie(CCmdUI* pCmdUI)
- {
- pCmdUI->Enable(TRUE);
-
- }
- void CIDEView::OnUpdateDrawPipe(CCmdUI* pCmdUI)
- {
- pCmdUI->Enable(TRUE);
-
- }
- void CIDEView::OnUpdateDrawPolygon(CCmdUI* pCmdUI)
- {
- pCmdUI->Enable(TRUE);
-
- }
- void CIDEView::OnUpdateDrawReport(CCmdUI* pCmdUI)
- {
- pCmdUI->Enable(TRUE);
-
- }
- void CIDEView::OnUpdateDrawSinglebar(CCmdUI* pCmdUI)
- {
- pCmdUI->Enable(TRUE);
-
- }
- void CIDEView::OnUpdateDrawTransfer(CCmdUI* pCmdUI)
- {
- pCmdUI->Enable(TRUE);
-
- }
- void CIDEView::OnUpdateDrawYpipe(CCmdUI* pCmdUI)
- {
- pCmdUI->Enable(TRUE);
-
- }
- void CIDEView::OnUpdateDrawZheline(CCmdUI* pCmdUI)
- {
- pCmdUI->Enable(TRUE);
-
- }
- void CIDEView::OnUpdateDrawZhepipe(CCmdUI* pCmdUI)
- {
- pCmdUI->Enable(TRUE);
-
- }
- void CIDEView::OnUpdateDrawLine(CCmdUI* pCmdUI)
- {
- pCmdUI->Enable(TRUE);
- }
- void CIDEView::OnDrawRoundrect()
- {
- g_nElementNo = ROUNDRECT;
- }
- void CIDEView::OnUpdateDrawRoundrect(CCmdUI* pCmdUI)
- {
- pCmdUI->Enable(TRUE);
- }
- void CIDEView::OnUpdateDrawOCX(CCmdUI* pCmdUI)
- {
- pCmdUI->Enable(TRUE);
- }
- void CIDEView::OnUpdateDrawGIF(CCmdUI* pCmdUI)
- {
- pCmdUI->Enable(TRUE);
- }
- void CIDEView::OnUpdateDrawFlash(CCmdUI* pCmdUI)
- {
- pCmdUI->Enable(TRUE);
- }
- void CIDEView::SetHisTime(CTime time)
- {
- m_tblTime = time;
- POSITION pos = m_selection.GetHeadPosition();
- while(pos != NULL)
- {
- CDrawObj* pObj = m_selection.GetNext(pos);
- pObj->m_bHisFreshed = false;
- }
- }
- void CIDEView::OnUpdateDiscombine(CCmdUI* pCmdUI)
- {
- if((m_selection.GetCount() == 1))
- pCmdUI->Enable(TRUE);
- else
- pCmdUI->Enable(FALSE);
- }
- void CIDEView::OnUpdateCombine(CCmdUI* pCmdUI)
- {
- if((m_selection.GetCount()>1))
- pCmdUI->Enable(TRUE);
- else
- pCmdUI->Enable(FALSE);
- }
- void CIDEView::OnCombine()
- {
- CDrawComposite* pTempObj = new CDrawComposite(m_selection);
- pTempObj->m_pView = this;
-
- POSITION pos = m_selection.GetHeadPosition();
- while(pos != NULL)
- {
- CDrawObj* pObj = m_selection.GetNext(pos);
- pObj->Invalidate();
- Remove(pObj);
- }
- m_selection.RemoveAll();
- if (pTempObj != NULL)
- {
- m_pGraph->m_DrawObjList.AddTail(pTempObj);
- m_selection.AddTail(pTempObj);
- }
- }
- // 分解组合图元
- void CIDEView::OnDiscombine()
- {
- if (m_selection.GetCount() != 1)
- {
- MessageBox(g_strUnSelectEntity);
- return;
- }
- CDrawObj* pObj = m_selection.GetHead();
- if (!pObj->IsKindOf(RUNTIME_CLASS(CDrawComposite)))
- {
- MessageBox(g_strIsNotPrimitive);
- return;
- }
- m_selection.RemoveAll();
- // 分解并添加到画面
- POSITION pos = (((CDrawComposite*)pObj)->m_ObjList).GetHeadPosition();
- while(pos != NULL)
- {
- CDrawObj* pTmpObj = (((CDrawComposite*)pObj)->m_ObjList).GetNext(pos);
- pTmpObj->m_pView = this;
- m_pGraph->m_DrawObjList.AddTail(pTmpObj);
- m_selection.AddTail(pTmpObj);
- }
-
- // 删除组合图元
- pos = m_pGraph->m_DrawObjList.Find(pObj);
- if (NULL != pos)
- {
- m_pGraph->m_DrawObjList.RemoveAt(pos);
- }
- // 选择
-
- //tbd 内存泄漏
- // delete pObj;
- }
- void CIDEView::OnProperty()
- {
- // TODO: 在此添加命令处理程序代码
- if(CDrawObj::bRuning == TRUE) return;
- if (m_selection.GetCount()<1)
- {
- return;
- }
-
- CClientDC dc(this);
- OnPrepareDC(&dc);
- //CPoint local = point;
- //dc.DPtoLP(&local);
- if ( (g_nElementNo = POLYGON || g_nElementNo == ZHELINE ) && m_tempObj != NULL && m_bPolygon)
- {
- // ((CDrawPoly*)m_tempObj)->AddPoint(local);
- m_bPolygon = false;
- ((CDrawPoly*)m_tempObj)->RecalcBounds();
- CRect freshRect = m_tempObj->m_rect;
- freshRect.NormalizeRect();
- freshRect.InflateRect(4,4);
- InvalidateRect(freshRect,FALSE);
- m_tempObj = NULL;
- g_nElementNo = 0;
- }
- else
- {
- if (m_selection.GetCount()>1)
- {
- COLORREF _clrFore; // 前景色
- COLORREF _clrLine; // 线色
- COLORREF _clrBack; // 背景色
- COLORREF _clrFill; // 填充色
- LOGFONT _logfont; // 字体
- CString _strLineType; // 线型
- int _nLineWidth; // 线宽
- int _nFillMode; //填充類型
- int nPosIndex=0;
- POSITION pos = m_selection.GetHeadPosition();
- while(pos != NULL)
- {
- CDrawObj* pObj = m_selection.GetNext(pos);
- pObj->m_bModifyMore = TRUE;
-
- if( nPosIndex==0 )
- {
- if ( pObj->OnAttrib() )
- {
- m_bModified = TRUE;
- _clrFore = pObj->m_clrFore;
- _clrLine = pObj->m_clrLine;
- _clrBack = pObj->m_clrBack;
- _clrFill = pObj->m_clrFill;
- _logfont = pObj->m_logfont;
- _strLineType = pObj->m_strLineType;
- _nLineWidth = pObj->m_nLineWidth;
- _nFillMode = pObj->m_nFillMode;
- }
- else
- {
- return;
- }
- }
- else
- {
- pObj->m_clrFore = _clrFore;
- pObj->m_clrLine = _clrLine;
- pObj->m_clrBack = _clrBack;
- pObj->m_clrFill = _clrFill;
- pObj->m_logfont = _logfont;
- pObj->m_strLineType = _strLineType;
- pObj->m_nLineWidth = _nLineWidth;
- pObj->m_nFillMode = _nFillMode;
- }
- CRect freshRect = pObj->m_rect;
- freshRect.NormalizeRect();
- freshRect.InflateRect(4,4);
- InvalidateRect(freshRect,FALSE);
- g_nElementNo = 0;
- nPosIndex++;
- }
- }
- else
- {
- POSITION pos = m_selection.GetHeadPosition();
- CDrawObj *pObj = m_selection.GetNext(pos);
- pObj->m_bModifyMore = FALSE;
- if ( pObj->OnAttrib() )
- m_bModified = TRUE;
- CRect freshRect = pObj->m_rect;
- freshRect.NormalizeRect();
- freshRect.InflateRect(4,4);
- InvalidateRect(freshRect,FALSE);
- g_nElementNo = 0;
- }
- }
- }
- void CIDEView::OnUpdateProperty(CCmdUI *pCmdUI)
- {
- // TODO: 在此添加命令更新用户界面处理程序代码
- }
- void CIDEView::OnEditVar()
- {
-
- }
- void CIDEView::OnUpdateEditVar(CCmdUI *pCmdUI)
- {
- // TODO: 在此添加命令更新用户界面处理程序代码
- }
- void CIDEView::OnRealTimeCurve()
- {
- CDlg_RealTimeCurve dlg;
- dlg.m_sVarName = m_sVarName;
- dlg.DoModal();
- }
- void CIDEView::OnUpdateRealTimeCurve(CCmdUI *pCmdUI)
- {
- // TODO: 在此添加命令更新用户界面处理程序代码
- }
- void CIDEView::OnClose()
- {
- // TODO: 在此添加消息处理程序代码和/或调用默认值
- if(m_bModified)
- {
- if(MessageBox(g_strSaveModify,g_strSelect,MB_YESNO|MB_ICONQUESTION) == IDYES)
- OnFileSave();
- }
- CScrollView::OnClose();
- }
- #if VIEW_USE_THREAD
- DWORD WINAPI CIDEView::FreshGraphThread( void *pData )
- {
- CIDEView *pView = (CIDEView *)pData;
-
- do
- {
- if( pView != NULL )
- {
- if( pView->m_pGraph != NULL )
- {
- pView->m_pGraph->Fresh();
- //pView->Invalidate(FALSE);
- }
- }
- Sleep(100);
- }while( WaitForSingleObject( pView->m_hIDEViewRunObject, 125L ) == WAIT_TIMEOUT );
- return 0;
- }
- #endif
- void CIDEView::OnKillFocus(CWnd* pNewWnd)
- {
- CScrollView::OnKillFocus(pNewWnd);
- // TODO: 在此处添加消息处理程序代码
- //TRACE("Enter KillFocus\n");
- }
- void CIDEView::OnSetFocus(CWnd* pOldWnd)
- {
- CScrollView::OnSetFocus(pOldWnd);
- // TODO: 在此处添加消息处理程序代码
- //TRACE("Enter SetFocus\n");
- }
- void CIDEView::OnActivateView(BOOL bActivate, CView* pActivateView, CView* pDeactiveView)
- {
- // TODO: 在此添加专用代码和/或调用基类
- CScrollView::OnActivateView(bActivate, pActivateView, pDeactiveView);
- }
- CString CIDEView::RegSearch(HKEY hKey, TCHAR rootKey[], CString path,CString sContent)
- {
- CString sRet;
- DWORD numSubKey=0; //存放子键的项数
- DWORD i; //计数
- DWORD sizeSubKey; //子键大小
- TCHAR subKey[255]; //子键名
- /*打开hKey中的rootKey, hKey乃继承递归调用者之hKey, rootKey乃递归调用者之subKey*/
- RegOpenKeyEx( hKey, //欲开之键柄
- rootKey, //欲开之根键名
- 0, //保留值,强制0
- KEY_READ, //权限
- &hKey); //打开子键后,返回键柄
- ///*首先查当前键下的值们(表明是复数哈)是否有符合条件的*/
- char lpWstr[MAX_PATH];
- DWORD lpType = NULL;
- DWORD maxBufSize = MAX_PATH;
- if(RegQueryValueEx(hKey, NULL, NULL, &lpType, (LPBYTE)lpWstr, &maxBufSize) == ERROR_SUCCESS)
- {
- CString sGet(lpWstr);
- if( -1!=sGet.Find( sContent ) && sGet.GetLength()>=5 && path.Find( "CLSID" )!=-1 )
- {
- RegCloseKey(hKey); //收尾工作是一定要做的,否则机器会异常的慢
- sRet = path.Mid( 6,0x26 );
- return sRet; //跳出递归
- }
- }
- /*没有查到,则进入子键查询*/
- else
- {
- /*首先查得当前键下的子键项数*/
- RegQueryInfoKey( hKey,
- NULL,
- NULL,
- NULL,
- &numSubKey, //查得子键的项数
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL);
-
- /*如果子键数不为0,遍历子键*/
- if (numSubKey)
- {
- for (i=0; i<numSubKey; i++)
- {
- subKey[0]='\0'; //该两行很重要,保证了每次循环的初始
- sizeSubKey=255; //第一行清空子键,第二行赋缓冲区大小
- RegEnumKeyEx( hKey, //键柄
- i, //子键序号
- subKey, //存入子键名
- &sizeSubKey,//指明缓冲区大小
- NULL,
- NULL,
- NULL,
- NULL);
- CString s;
- s = RegSearch (hKey,subKey,path+subKey+"\\",sContent); //递归
- if( s.GetLength()>10 )
- {
- sRet = s;//.Mid( 6,0x26 );
- return sRet;
- }
- }
- }
- }
- RegCloseKey(hKey); //收尾工作是一定要做的,否则机器会异常的慢
- return sRet;
- }
- CString CIDEView::GetClsidbyName( CString sName )
- {
- CString sRet;
- CString sPathName;
- sPathName.Format( "%s",g_strDirectory );
- sPathName += "\\ocx";
- sPathName += "\\ocxList.txt";
- CString sTemp;
- CStdioFile File;
-
- if(!File.Open(sPathName,CFile::modeRead))
- File.Open(sPathName,CFile::modeCreate|CFile::modeRead);
- while(File.ReadString(sTemp))//定义一个CString变量sTemp作为缓冲区
- {
- int nPos = sTemp.Find( sName );
- if( nPos!=-1 )
- {
- sRet = sTemp.Mid( sName.GetLength()+1,sTemp.GetLength()-sName.GetLength() );
- break;
- }
- }
- File.Close();
- return sRet;
- }
- void CIDEView::ShowOCX( CRect rect,CString sOcxPath,int iIndex,CString sPageName )
- {
- //g_strDirectory;
- //把宽高写入ini
- CHAR strFile[MAX_PATH + 1] = "";
- memset(strFile, 0, sizeof(strFile));
- wsprintf(strFile, "C:\\OCXRect.ini");
- if( rect.left<0 )
- rect.left = 0;
- if( rect.top<0 )
- rect.top = 0;
- CString sW,sH,sIndex;
- sW.Format( "%d",rect.Width() );
- sH.Format( "%d",rect.Height() );
- sIndex.Format("%d",iIndex );
- WritePrivateProfileString("WH", "W", sW, strFile);
- WritePrivateProfileString("WH", "H", sH, strFile);
- WritePrivateProfileString("WH", "INDEX", sIndex, strFile);
- WritePrivateProfileString("WH", "PageName", sPageName, strFile);
- WritePrivateProfileString("Database", "ServerName", g_strServerName, strFile);
- WritePrivateProfileString("Database", "DataBaseName", g_strDataBaseName, strFile);
- WritePrivateProfileString("Database", "UserName", g_strUserName, strFile);
- WritePrivateProfileString("Database", "Password", g_strPassword, strFile);
- WritePrivateProfileString("Database", "DBType", g_strDBType, strFile);
- ///////////////////////////////////////////////////////
- CString sName;
- for (int iPosFile = sOcxPath.GetLength() - 1; iPosFile >= 0; iPosFile--)
- {
- if (sOcxPath[iPosFile] == '\\')
- {
- sName = sOcxPath.Mid( iPosFile+1,sOcxPath.GetLength()-iPosFile-5 );
- break;
- }
- }
- CString sClsid = GetClsidbyName( sName );//RegSearch (HKEY_CLASSES_ROOT,"","",sName+" Control");//
- //SToneu_Door_WG="{AED861D5-723E-4F31-AA24-0F20B382103E}";//
- //StoneU_HC_OCX ="{80043A10-F014-4817-9832-38A38202E0B8}";//
- //if( sClsid=="" )
- //{
- // if( RegisterOCX( sOcxPath ) )//注册OCX
- // sClsid = RegSearch (HKEY_CLASSES_ROOT,"","",sName+" Control");
- //}
- if( sClsid!="" )
- {
- USES_CONVERSION;
- CLSID clsid;
- HRESULT hr = CLSIDFromString(T2OLE(sClsid), &clsid);
- bool f;
- static int ID = 62001;
- int nRet = m_OcxWnd.CreateControl( clsid, _T("132"), WS_CHILD | WS_VISIBLE, rect, this,ID );
- ID++;
- if( nRet == 0 )
- f = false;
- else
- f = true;
- }
- else
- {
- CString str;
- str.Format( "请在 <\\Ocx\\ocxList.txt> 里填入控件的sClsid" );
- MessageBox(str, g_strTip, MB_ICONWARNING);
- }
- }
|