星火微课系统客户端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

XHMicroLessonSystemWindow.xaml.cs 209KB

4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737
  1. using Aspose.Slides;
  2. using Aspose.Words;
  3. using Aspose.Words.Saving;
  4. using ComeCapture;
  5. using Common.system;
  6. using System;
  7. using System.Collections.Generic;
  8. using System.Diagnostics;
  9. using System.Drawing;
  10. using System.Drawing.Imaging;
  11. using System.IO;
  12. using System.Linq;
  13. using System.Text;
  14. using System.Threading;
  15. using System.Windows;
  16. using System.Windows.Controls;
  17. using System.Windows.Controls.Primitives;
  18. using System.Windows.Forms;
  19. using System.Windows.Ink;
  20. using System.Windows.Input;
  21. using System.Windows.Media;
  22. using System.Windows.Media.Imaging;
  23. using System.Windows.Threading;
  24. using TStudyDigitalPen.HID;
  25. using XHWK.Model;
  26. using XHWK.WKTool.DAL;
  27. using XHWK.WKTool.UControl;
  28. namespace XHWK.WKTool
  29. {
  30. /// <summary>
  31. /// 主页面
  32. /// </summary>
  33. public partial class XHMicroLessonSystemWindow : Window
  34. {
  35. #region 字段
  36. private FolderBrowserDialog Ofd;
  37. private DialogResult Result;
  38. public BlackboardNew myblackboard;
  39. private System.Windows.Forms.DialogResult result;
  40. private System.Windows.Forms.OpenFileDialog ofd;
  41. //声明一个 DrawingAttributes 类型的变量
  42. private DrawingAttributes drawingAttributes;
  43. private Model_Video VideoInfo = null;
  44. ////定义事件
  45. //public event ChangeTextHandler ChangeTextEvent;
  46. //定义委托
  47. public delegate void ChangeTextHandler(string text);
  48. //定义委托
  49. public delegate void ChangeTextHandlers(string text, int i);
  50. /// <summary>
  51. /// 图片
  52. /// </summary>
  53. private string[] ImgPDFPath = new string[300];
  54. /// <summary>
  55. /// 当前颜色
  56. /// </summary>
  57. private System.Windows.Media.Color Color = System.Windows.Media.Colors.Red;
  58. /// <summary>
  59. /// 笔迹粗细
  60. /// </summary>
  61. private int PenSize = 2;
  62. private DispatcherTimer t = null;
  63. /// <summary>
  64. /// 计时器状态
  65. /// </summary>
  66. private enum State
  67. {
  68. Start,
  69. Pause,
  70. End
  71. }
  72. /// <summary>
  73. /// 状态
  74. /// </summary>
  75. private State _state = State.End;
  76. /// <summary>
  77. /// 计时用
  78. /// </summary>
  79. private TimeSpan _timeSpan = new TimeSpan(0, 0, 0, 0, 0);
  80. #region 上传
  81. /// <summary>
  82. /// 视频模型
  83. /// </summary>
  84. private List<Model_Video> model_VideoList = null;
  85. /// <summary>
  86. /// 数据列表
  87. /// </summary>
  88. internal FileDirectoryData pageData = new FileDirectoryData();
  89. /// <summary>
  90. /// 下标
  91. /// </summary>
  92. private int Subscript = 0;
  93. /// <summary>
  94. /// 是否是修改状态
  95. /// </summary>
  96. private bool IsModify = false;
  97. #endregion
  98. private double screeHeight = SystemParameters.FullPrimaryScreenHeight;
  99. private double screeWidth = SystemParameters.FullPrimaryScreenWidth;
  100. #endregion
  101. #region 初始化
  102. /// <summary>
  103. /// 主页面
  104. /// </summary>
  105. public XHMicroLessonSystemWindow()
  106. {
  107. new Aspose.Pdf.License().SetLicense(new MemoryStream(Convert.FromBase64String("PExpY2Vuc2U+CiAgPERhdGE+CiAgICA8TGljZW5zZWRUbz5TdXpob3UgQXVuYm94IFNvZnR3YXJlIENvLiwgTHRkLjwvTGljZW5zZWRUbz4KICAgIDxFbWFpbFRvPnNhbGVzQGF1bnRlYy5jb208L0VtYWlsVG8+CiAgICA8TGljZW5zZVR5cGU+RGV2ZWxvcGVyIE9FTTwvTGljZW5zZVR5cGU+CiAgICA8TGljZW5zZU5vdGU+TGltaXRlZCB0byAxIGRldmVsb3BlciwgdW5saW1pdGVkIHBoeXNpY2FsIGxvY2F0aW9uczwvTGljZW5zZU5vdGU+CiAgICA8T3JkZXJJRD4xOTA4MjYwODA3NTM8L09yZGVySUQ+CiAgICA8VXNlcklEPjEzNDk3NjAwNjwvVXNlcklEPgogICAgPE9FTT5UaGlzIGlzIGEgcmVkaXN0cmlidXRhYmxlIGxpY2Vuc2U8L09FTT4KICAgIDxQcm9kdWN0cz4KICAgICAgPFByb2R1Y3Q+QXNwb3NlLlRvdGFsIGZvciAuTkVUPC9Qcm9kdWN0PgogICAgPC9Qcm9kdWN0cz4KICAgIDxFZGl0aW9uVHlwZT5FbnRlcnByaXNlPC9FZGl0aW9uVHlwZT4KICAgIDxTZXJpYWxOdW1iZXI+M2U0NGRlMzAtZmNkMi00MTA2LWIzNWQtNDZjNmEzNzE1ZmMyPC9TZXJpYWxOdW1iZXI+CiAgICA8U3Vic2NyaXB0aW9uRXhwaXJ5PjIwMjAwODI3PC9TdWJzY3JpcHRpb25FeHBpcnk+CiAgICA8TGljZW5zZVZlcnNpb24+My4wPC9MaWNlbnNlVmVyc2lvbj4KICAgIDxMaWNlbnNlSW5zdHJ1Y3Rpb25zPmh0dHBzOi8vcHVyY2hhc2UuYXNwb3NlLmNvbS9wb2xpY2llcy91c2UtbGljZW5zZTwvTGljZW5zZUluc3RydWN0aW9ucz4KICA8L0RhdGE+CiAgPFNpZ25hdHVyZT53UGJtNUt3ZTYvRFZXWFNIY1o4d2FiVEFQQXlSR0pEOGI3L00zVkV4YWZpQnd5U2h3YWtrNGI5N2c2eGtnTjhtbUFGY3J0c0cwd1ZDcnp6MytVYk9iQjRYUndTZWxsTFdXeXNDL0haTDNpN01SMC9jZUFxaVZFOU0rWndOQkR4RnlRbE9uYTFQajhQMzhzR1grQ3ZsemJLZFZPZXk1S3A2dDN5c0dqYWtaL1E9PC9TaWduYXR1cmU+CjwvTGljZW5zZT4=")));
  108. new Aspose.Slides.License().SetLicense(new MemoryStream(Convert.FromBase64String("PExpY2Vuc2U+CiAgPERhdGE+CiAgICA8TGljZW5zZWRUbz5TdXpob3UgQXVuYm94IFNvZnR3YXJlIENvLiwgTHRkLjwvTGljZW5zZWRUbz4KICAgIDxFbWFpbFRvPnNhbGVzQGF1bnRlYy5jb208L0VtYWlsVG8+CiAgICA8TGljZW5zZVR5cGU+RGV2ZWxvcGVyIE9FTTwvTGljZW5zZVR5cGU+CiAgICA8TGljZW5zZU5vdGU+TGltaXRlZCB0byAxIGRldmVsb3BlciwgdW5saW1pdGVkIHBoeXNpY2FsIGxvY2F0aW9uczwvTGljZW5zZU5vdGU+CiAgICA8T3JkZXJJRD4xOTA4MjYwODA3NTM8L09yZGVySUQ+CiAgICA8VXNlcklEPjEzNDk3NjAwNjwvVXNlcklEPgogICAgPE9FTT5UaGlzIGlzIGEgcmVkaXN0cmlidXRhYmxlIGxpY2Vuc2U8L09FTT4KICAgIDxQcm9kdWN0cz4KICAgICAgPFByb2R1Y3Q+QXNwb3NlLlRvdGFsIGZvciAuTkVUPC9Qcm9kdWN0PgogICAgPC9Qcm9kdWN0cz4KICAgIDxFZGl0aW9uVHlwZT5FbnRlcnByaXNlPC9FZGl0aW9uVHlwZT4KICAgIDxTZXJpYWxOdW1iZXI+M2U0NGRlMzAtZmNkMi00MTA2LWIzNWQtNDZjNmEzNzE1ZmMyPC9TZXJpYWxOdW1iZXI+CiAgICA8U3Vic2NyaXB0aW9uRXhwaXJ5PjIwMjAwODI3PC9TdWJzY3JpcHRpb25FeHBpcnk+CiAgICA8TGljZW5zZVZlcnNpb24+My4wPC9MaWNlbnNlVmVyc2lvbj4KICAgIDxMaWNlbnNlSW5zdHJ1Y3Rpb25zPmh0dHBzOi8vcHVyY2hhc2UuYXNwb3NlLmNvbS9wb2xpY2llcy91c2UtbGljZW5zZTwvTGljZW5zZUluc3RydWN0aW9ucz4KICA8L0RhdGE+CiAgPFNpZ25hdHVyZT53UGJtNUt3ZTYvRFZXWFNIY1o4d2FiVEFQQXlSR0pEOGI3L00zVkV4YWZpQnd5U2h3YWtrNGI5N2c2eGtnTjhtbUFGY3J0c0cwd1ZDcnp6MytVYk9iQjRYUndTZWxsTFdXeXNDL0haTDNpN01SMC9jZUFxaVZFOU0rWndOQkR4RnlRbE9uYTFQajhQMzhzR1grQ3ZsemJLZFZPZXk1S3A2dDN5c0dqYWtaL1E9PC9TaWduYXR1cmU+CjwvTGljZW5zZT4=")));
  109. InitializeComponent();
  110. double proportion = 1036.0 / 1290.0;
  111. Width = (PrimaryScreen.ScaleWorkingAreaSize.Height) / proportion - (BorderThickness.Left + BorderThickness.Right);
  112. Height = PrimaryScreen.ScaleWorkingAreaSize.Height - (BorderThickness.Top + BorderThickness.Bottom);
  113. GridContent.Width = Width - 14;
  114. GridContent.Height = Height;
  115. #region 读取本地配置
  116. if (File.Exists(APP.dataPath + "interfaceAddress.txt")) //若不为空
  117. {
  118. APP.apiUrl = System.IO.File.ReadAllText(APP.dataPath + "interfaceAddress.txt", Encoding.Default);
  119. }
  120. if (File.Exists(APP.dataPath + "imageUploadAddress.txt")) //若不为空
  121. {
  122. APP.uploadUrl = System.IO.File.ReadAllText(APP.dataPath + "imageUploadAddress.txt", Encoding.Default);
  123. }
  124. if (File.Exists(APP.dataPath + "pictureShowsAddress.txt")) //若不为空
  125. {
  126. APP.showImageUrl = System.IO.File.ReadAllText(APP.dataPath + "pictureShowsAddress.txt", Encoding.Default);
  127. }
  128. #endregion
  129. //GridMain.Height= PrimaryScreen.ScaleScreenSize().Height - 40;
  130. //this.Top = (screeHeight - this.Height) / 2;
  131. //this.Left = (screeWidth - this.Width) / 2;
  132. ResizeMode = System.Windows.ResizeMode.CanMinimize;
  133. btnPrint.IsEnabled = false;
  134. myblackboard = new BlackboardNew(blackboard_canvas);
  135. APP.pageData.pagenum = 0;
  136. APP.pageData.currpage = 0;
  137. DataContext = APP.pageData;
  138. //APP.SaveDraw();//画板模型第一页初始化
  139. APP.PageDrawList = new List<Model_DrawData>();
  140. Model_DrawData model_DrawData = new Model_DrawData
  141. {
  142. PageNum = APP.pageData.currpage
  143. };
  144. APP.PageDrawList.Add(model_DrawData);
  145. txbv.Text = "v" + FileToolsCommon.GetConfigValue("VersionName");
  146. txbStoragePath.Content = FileToolsCommon.GetConfigValue("VideoType");
  147. if (FileToolsCommon.GetConfigValue("IsSound").Equals("true"))
  148. {
  149. rbnY.IsChecked = true;
  150. }
  151. else
  152. {
  153. rbnN.IsChecked = true;
  154. }
  155. txbStoragePath.Content = FileToolsCommon.GetConfigValue("VideoSavePath");
  156. Initialize();
  157. InitPen();
  158. }
  159. /// <summary>
  160. /// 初始化
  161. /// </summary>
  162. public void Initialize()
  163. {
  164. #region 数据初始化
  165. APP.pageData.pagenum = 0;
  166. APP.pageData.currpage = APP.pageData.pagenum;
  167. btnStop.IsEnabled = false;//停止录制按钮不可点击
  168. #endregion
  169. APP.CameraPosition = FileToolsCommon.GetConfigValue("CameraPosition");
  170. //创建 DrawingAttributes 类的一个实例
  171. drawingAttributes = new DrawingAttributes();
  172. //将 InkCanvas 的 DefaultDrawingAttributes 属性的值赋成创建的 DrawingAttributes 类的对象的引用
  173. //InkCanvas 通过 DefaultDrawingAttributes 属性来获取墨迹的各种设置,该属性的类型为 DrawingAttributes 型
  174. blackboard_canvas.DefaultDrawingAttributes = drawingAttributes;
  175. blackboard_canvas.UseCustomCursor = true;
  176. drawingAttributes.FitToCurve = true;
  177. drawingAttributes.IgnorePressure = false;
  178. drawingAttributes.Width = PenSize;
  179. drawingAttributes.Height = PenSize;
  180. drawingAttributes.Color = Color;
  181. blackboard_canvas.Cursor = System.Windows.Input.Cursors.Pen;
  182. //wfhCamera.Visibility = Visibility.Hidden;
  183. ImgPDFPath = null;
  184. ImgPDFPath = new string[300];
  185. }
  186. /// <summary>
  187. /// 开始
  188. /// </summary>
  189. /// <param name="sender"></param>
  190. /// <param name="e"></param>
  191. private void Stack()
  192. {
  193. _state = State.Start;
  194. }
  195. /// <summary>
  196. /// 暂停
  197. /// </summary>
  198. private void TimeOut()
  199. {
  200. _state = State.Pause;
  201. }
  202. /// <summary>
  203. /// 结束
  204. /// </summary>
  205. /// <param name="sender"></param>
  206. /// <param name="e"></param>
  207. private void End()
  208. {
  209. _state = State.End;
  210. }
  211. /// <summary>
  212. /// 时钟回调
  213. /// </summary>
  214. /// <param name="sender"></param>
  215. /// <param name="e"></param>
  216. private void OnTimer(object sender, EventArgs e)
  217. {
  218. switch (_state)
  219. {
  220. case State.Start:
  221. {
  222. _timeSpan += new TimeSpan(0, 0, 0, 1);
  223. }
  224. break;
  225. case State.Pause:
  226. {
  227. }
  228. break;
  229. case State.End:
  230. {
  231. _timeSpan = new TimeSpan();
  232. //_timeSpan = new TimeSpan(0, 23, 12, 45, 54);
  233. }
  234. break;
  235. }
  236. string time = string.Format("{0:D2}:{1:D2}",/* _timeSpan.Hours,*/ _timeSpan.Minutes, _timeSpan.Seconds);
  237. txbTime.Text = time;
  238. //txbTime.Text = time;
  239. }
  240. /// <summary>
  241. /// 修改布局
  242. /// </summary>
  243. public void SetUpLayout()
  244. {
  245. //宽高比1276,1040
  246. //double AspectRatio = 1276.0 / 1040.0;
  247. ////System.Drawing.Size des = PrimaryScreen.DESKTOP;
  248. //System.Drawing.Size workingArea = PrimaryScreen.WorkingArea;
  249. //this.Height = workingArea.Height;
  250. }
  251. #endregion
  252. #region 事件
  253. /// <summary>
  254. /// 窗体移动
  255. /// </summary>
  256. /// <param name="sender"></param>
  257. /// <param name="e"></param>
  258. private void Window_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
  259. {
  260. DragMove();
  261. }
  262. #region 摄像头
  263. private System.Timers.Timer times;
  264. private List<string> RbnOpen;
  265. private bool IsRbnOpen = false;
  266. /// <summary>
  267. /// 摄像头打开事件
  268. /// </summary>
  269. /// <param name="sender"></param>
  270. /// <param name="e"></param>
  271. private void RbnOpen_Click(object sender, RoutedEventArgs e)
  272. {
  273. //UCCamera win = new UCCamera();
  274. ////win.Topmost = true;
  275. //win.ShowDialog();
  276. //wfhCamera.Visibility = Visibility.Visible;
  277. //CameraHelper.IsDisplay = true;
  278. //CameraHelper.SourcePlayer = player;
  279. CameraHelper.UpdateCameraDevices();
  280. if (CameraHelper.CameraDevices.Count > 0)
  281. {
  282. CameraHelper.SetCameraDevice(0);
  283. RbnOpen = new List<string>();
  284. times = new System.Timers.Timer(100)//初始值为300
  285. {
  286. AutoReset = true//设置是否执行System.Timers.Timer.Elapsed事件
  287. };//设置执行一次(false)还是一直执行(true)
  288. times.Elapsed += new System.Timers.ElapsedEventHandler(Times_Elapsed);
  289. times.Enabled = true; //启动计时器
  290. IsRbnOpen = true;
  291. string imgPath = FileToolsCommon.GetFileAbsolutePath("Temp/imgplayer");
  292. FileToolsCommon.CreateDirectory(imgPath);
  293. }
  294. }
  295. private int I = 9999;
  296. private void Times_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
  297. {
  298. if (IsRbnOpen)
  299. {
  300. try
  301. {
  302. Dispatcher.Invoke(() =>
  303. {
  304. if (I > 10010)
  305. {
  306. long time = Timestamp();
  307. string imgPath = FileToolsCommon.GetFileAbsolutePath("Temp/imgplayer");
  308. //string FilePathName = ImgPath + RsImgName.Count + ".png";
  309. string path = CameraHelper.CaptureImage(imgPath, time.ToString());
  310. if (!string.IsNullOrWhiteSpace(path))
  311. {
  312. RbnOpen.Add(path);
  313. imgPlayerRight.Visibility = Visibility.Visible;
  314. /// < !--摄像头位置 1.右上 2.左上 3.右下 4.左下-- >
  315. if ("1".Equals(APP.CameraPosition))
  316. {
  317. imgPlayerRight.Visibility = Visibility.Visible;
  318. imgPlayerLeft.Visibility = Visibility.Collapsed;
  319. imgPlayerRightUnder.Visibility = Visibility.Collapsed;
  320. imgPlayerLeftUnder.Visibility = Visibility.Collapsed;
  321. imgPlayerRight.Source = new BitmapImage(new Uri(path));
  322. }
  323. else if ("2".Equals(APP.CameraPosition))
  324. {
  325. imgPlayerRight.Visibility = Visibility.Collapsed;
  326. imgPlayerLeft.Visibility = Visibility.Visible;
  327. imgPlayerRightUnder.Visibility = Visibility.Collapsed;
  328. imgPlayerLeftUnder.Visibility = Visibility.Collapsed;
  329. imgPlayerLeft.Source = new BitmapImage(new Uri(path));
  330. }
  331. else if ("3".Equals(APP.CameraPosition))
  332. {
  333. imgPlayerRight.Visibility = Visibility.Collapsed;
  334. imgPlayerLeft.Visibility = Visibility.Collapsed;
  335. imgPlayerRightUnder.Visibility = Visibility.Visible;
  336. imgPlayerLeftUnder.Visibility = Visibility.Collapsed;
  337. imgPlayerRightUnder.Source = new BitmapImage(new Uri(path));
  338. }
  339. else if ("4".Equals(APP.CameraPosition))
  340. {
  341. imgPlayerRight.Visibility = Visibility.Collapsed;
  342. imgPlayerLeft.Visibility = Visibility.Collapsed;
  343. imgPlayerRightUnder.Visibility = Visibility.Collapsed;
  344. imgPlayerLeftUnder.Visibility = Visibility.Visible;
  345. imgPlayerLeftUnder.Source = new BitmapImage(new Uri(path));
  346. }
  347. else
  348. {
  349. imgPlayerLeft.Visibility = Visibility.Collapsed;
  350. imgPlayerRightUnder.Visibility = Visibility.Collapsed;
  351. imgPlayerLeftUnder.Visibility = Visibility.Collapsed;
  352. imgPlayerRight.Source = new BitmapImage(new Uri(path));
  353. }
  354. }
  355. }
  356. I++;
  357. });
  358. }
  359. catch (Exception ex)
  360. {
  361. LogHelper.WriteErrLog("【摄像】(Times_Elapsed)生成图片错误:" + ex.Message, ex);
  362. }
  363. }
  364. }
  365. /// <summary>
  366. /// 摄像头关闭事件
  367. /// </summary>
  368. /// <param name="sender"></param>
  369. /// <param name="e"></param>
  370. private void RbnTurnOff_Click(object sender, RoutedEventArgs e)
  371. {
  372. IsRbnOpen = false;
  373. imgPlayerRight.Visibility = Visibility.Collapsed;
  374. imgPlayerLeft.Visibility = Visibility.Collapsed;
  375. imgPlayerRightUnder.Visibility = Visibility.Collapsed;
  376. imgPlayerLeftUnder.Visibility = Visibility.Collapsed;
  377. CameraHelper.CloseDevice();
  378. I = 9999;
  379. }
  380. #endregion
  381. #endregion
  382. /// <summary>
  383. /// 关闭事件
  384. /// </summary>
  385. /// <param name="sender"></param>
  386. /// <param name="e"></param>
  387. private void BtnDown_Click(object sender, RoutedEventArgs e)
  388. {
  389. if (IsFirstR)
  390. {
  391. MessageBoxResult br= MessageWindow.Show("确定退出系统?","退出",MessageBoxButton.OKCancel);
  392. if (br == MessageBoxResult.OK)
  393. {
  394. APP.Killffmpeg();
  395. APP.SaveWkData();
  396. APP.SaveDraw();
  397. Thread.Sleep(100);
  398. System.Environment.Exit(0);
  399. }
  400. }
  401. else
  402. {
  403. MessageWindow.Show("当前正在录制,请先停止录制。");
  404. return;
  405. //MessageBoxResult dr = MessageWindow.Show("当前正在录制,是否停止录制?", "提示", MessageBoxButton.OKCancel);
  406. //if (dr == MessageBoxResult.OK)
  407. //{
  408. // APP.SaveWkData();
  409. // APP.SaveDraw();
  410. // BtnStop_Click(null, null);
  411. // while (!IsFirstR)
  412. // {
  413. // Thread.Sleep(100);
  414. // }
  415. // System.Environment.Exit(0);
  416. //}
  417. //else
  418. //{
  419. // return;
  420. //}
  421. }
  422. }
  423. #region 设置
  424. /// <summary>
  425. /// 设置事件
  426. /// </summary>
  427. /// <param name="sender"></param>
  428. /// <param name="e"></param>
  429. private void BtnSetUp_Click(object sender, RoutedEventArgs e)
  430. {
  431. if (!TxbRecordingWord.Text.Equals("暂停"))
  432. {
  433. if(gridSetUp.Visibility==Visibility.Collapsed)
  434. {
  435. GridMain.Visibility = Visibility.Collapsed;
  436. gridSetUp.Visibility = Visibility.Visible;
  437. //gridUpload.Visibility = Visibility.Collapsed;
  438. GridMyVideo.Visibility = Visibility.Collapsed;
  439. txbStoragePath.Content = APP.WKData.WkPath;
  440. GridMyVideo.Visibility = Visibility.Collapsed;
  441. #region 读取用户配置
  442. //接口地址
  443. if (!File.Exists(APP.dataPath + "interfaceAddress.txt")) //若为空
  444. {
  445. txbInterfaceAddress.Text = APP.apiUrl.Replace("http://", "").Trim();
  446. }
  447. else
  448. {
  449. txbInterfaceAddress.Text = System.IO.File.ReadAllText(APP.dataPath + "interfaceAddress.txt", Encoding.Default).Replace("http://", "").Trim();
  450. }
  451. //上传地址
  452. if (!File.Exists(APP.dataPath + "imageUploadAddress.txt")) //若为空
  453. {
  454. txbImageUploadAddress.Text = APP.uploadUrl.Replace("http://", "").Replace("/", "").Trim();
  455. }
  456. else
  457. {
  458. txbImageUploadAddress.Text = System.IO.File.ReadAllText(APP.dataPath + "imageUploadAddress.txt", Encoding.Default).Replace("http://", "").Replace("/", "").Trim();
  459. }
  460. //下载地址
  461. if (!File.Exists(APP.dataPath + "pictureShowsAddress.txt")) //若为空
  462. {
  463. txbPictureShowsAddress.Text = APP.showImageUrl.Replace("http://", "").Replace("/", "").Replace("static", "").Trim();
  464. }
  465. else
  466. {
  467. txbPictureShowsAddress.Text = System.IO.File.ReadAllText(APP.dataPath + "pictureShowsAddress.txt", Encoding.Default).Replace("http://", "").Replace("/", "").Replace("static", "").Trim();
  468. }
  469. /// < !--摄像头位置 1.右上 2.左上 3.右下 4.左下-- >
  470. if ("1".Equals(APP.CameraPosition))
  471. {
  472. rbnRight.IsChecked = true;
  473. }
  474. else if ("2".Equals(APP.CameraPosition))
  475. {
  476. rbnLeft.IsChecked = true;
  477. }
  478. else if ("3".Equals(APP.CameraPosition))
  479. {
  480. rbnRightUnder.IsChecked = true;
  481. }
  482. else if ("4".Equals(APP.CameraPosition))
  483. {
  484. rbnLeftUnder.IsChecked = true;
  485. }
  486. string type = FileToolsCommon.GetConfigValue("VideoType");//<!--视频格式 1、MP4 2、FlV 3、AVI-->
  487. if ("1".Equals(type))
  488. {
  489. rbnMP4.IsChecked = true;
  490. }
  491. else if ("2".Equals(type))
  492. {
  493. rbnFLV.IsChecked = true;
  494. }
  495. else if ("3".Equals(type))
  496. {
  497. rbnAVI.IsChecked = true;
  498. }
  499. string isSound = FileToolsCommon.GetConfigValue("IsSound");//<!--声音 true 有 false 无-->
  500. if (isSound == "true")
  501. {
  502. rbnY.IsChecked = true;
  503. }
  504. else
  505. {
  506. rbnN.IsChecked = true;
  507. }
  508. #endregion
  509. }
  510. else
  511. {
  512. GridMain.Visibility = Visibility.Visible;
  513. gridSetUp.Visibility = Visibility.Collapsed;
  514. //gridUpload.Visibility = Visibility.Collapsed;
  515. GridMyVideo.Visibility = Visibility.Collapsed;
  516. if (APP.pageData.pagenum > 0)
  517. {
  518. gridPage.Visibility = Visibility.Visible;
  519. }
  520. DataContext = APP.pageData;
  521. }
  522. }
  523. }
  524. /// <summary>
  525. /// 设置 保存事件
  526. /// </summary>
  527. /// <param name="sender"></param>
  528. /// <param name="e"></param>
  529. private void BtnSave_Click(object sender, RoutedEventArgs e)
  530. {
  531. try
  532. {
  533. ImgRecord.Visibility = Visibility.Visible;//设置结束时可录制
  534. ImgRecordTwo.Visibility = Visibility.Collapsed;//设置结束时可录制
  535. BtnRecord.IsEnabled = true;//设置结束时可录制
  536. if (!string.IsNullOrWhiteSpace(txbInterfaceAddress.Text))
  537. {
  538. string ApplicationData = APP.dataPath + "interfaceAddress.txt";
  539. string temp = "http://" + txbInterfaceAddress.Text;
  540. System.IO.File.WriteAllText(ApplicationData, temp, Encoding.Default);
  541. }
  542. else
  543. {
  544. MessageWindow.Show("接口地址未输入");
  545. return;
  546. }
  547. if (!string.IsNullOrWhiteSpace(txbImageUploadAddress.Text))//图片上传地址
  548. {
  549. string ApplicationData = APP.dataPath + "imageUploadAddress.txt";
  550. string temp = "http://" + txbImageUploadAddress.Text + "/";
  551. System.IO.File.WriteAllText(ApplicationData, temp, Encoding.Default);
  552. }
  553. else
  554. {
  555. MessageWindow.Show("上传地址未输入");
  556. return;
  557. }
  558. if (!string.IsNullOrWhiteSpace(txbPictureShowsAddress.Text))
  559. {
  560. string ApplicationData = APP.dataPath + "pictureShowsAddress.txt";
  561. string temp = "http://" + txbPictureShowsAddress.Text + "/static/";
  562. System.IO.File.WriteAllText(ApplicationData, temp, Encoding.Default);
  563. }
  564. else
  565. {
  566. MessageWindow.Show("下载地址未输入");
  567. return;
  568. }
  569. if (!APP.apiUrl.Equals("http://" + txbInterfaceAddress.Text))
  570. {
  571. APP.apiUrl = "http://" + txbInterfaceAddress.Text;
  572. if (!txbLoginType.Text.Equals("未登录"))
  573. {
  574. LoginType();
  575. MessageWindow.Show("接口地址已修改,请重新登陆!");
  576. }
  577. }
  578. if (!APP.uploadUrl.Equals(txbImageUploadAddress.Text))
  579. {
  580. APP.uploadUrl = "http://" + txbImageUploadAddress.Text + "/";
  581. }
  582. if (!APP.showImageUrl.Equals(txbPictureShowsAddress.Text))
  583. {
  584. APP.showImageUrl = "http://" + txbPictureShowsAddress.Text + "/static/";
  585. }
  586. if (rbnMP4.IsChecked == true)
  587. {
  588. //存储文件
  589. FileToolsCommon.SetConfigValue("VideoType", "1");
  590. }
  591. else if (rbnFLV.IsChecked == true)
  592. {
  593. FileToolsCommon.SetConfigValue("VideoType", "2");
  594. }
  595. else
  596. {
  597. FileToolsCommon.SetConfigValue("VideoType", "3");
  598. }
  599. if (rbnY.IsChecked == true)
  600. {
  601. FileToolsCommon.SetConfigValue("IsSound", "true");
  602. }
  603. else
  604. {
  605. FileToolsCommon.SetConfigValue("IsSound", "false");
  606. }
  607. /// < !--摄像头位置 1.右上 2.左上 3.右下 4.左下-- >
  608. if (rbnRight.IsChecked == true)
  609. {
  610. FileToolsCommon.SetConfigValue("CameraPosition", "1");
  611. }
  612. else if (rbnLeft.IsChecked == true)
  613. {
  614. FileToolsCommon.SetConfigValue("CameraPosition", "2");
  615. }
  616. else if (rbnRightUnder.IsChecked == true)
  617. {
  618. FileToolsCommon.SetConfigValue("CameraPosition", "3");
  619. }
  620. else if (rbnLeftUnder.IsChecked == true)
  621. {
  622. FileToolsCommon.SetConfigValue("CameraPosition", "4");
  623. }
  624. if (rbnMP4.IsChecked == true)
  625. {
  626. FileToolsCommon.SetConfigValue("VideoType", "1");
  627. }
  628. else if (rbnFLV.IsChecked == true)
  629. {
  630. FileToolsCommon.SetConfigValue("VideoType", "2");
  631. }
  632. else if (rbnAVI.IsChecked == true)
  633. {
  634. FileToolsCommon.SetConfigValue("VideoType", "3");
  635. }
  636. APP.CameraPosition = FileToolsCommon.GetConfigValue("CameraPosition");
  637. GridMain.Visibility = Visibility.Visible;
  638. gridSetUp.Visibility = Visibility.Collapsed;
  639. imgPlayerRight.Visibility = Visibility.Collapsed;
  640. imgPlayerLeft.Visibility = Visibility.Collapsed;
  641. imgPlayerRightUnder.Visibility = Visibility.Collapsed;
  642. imgPlayerLeftUnder.Visibility = Visibility.Collapsed;
  643. if (!txbStoragePath.Content.ToString().Equals(APP.WKData.WkPath))
  644. {
  645. //存储文件
  646. FileToolsCommon.SetConfigValue("VideoSavePath", txbStoragePath.Content.ToString());
  647. MessageWindow.Show("路径已变更,下次创建微课时自动生效!!!");
  648. }
  649. }
  650. catch (Exception ex)
  651. {
  652. LogHelper.WriteErrLog("XHMicroLessonSystemWindow(设置保存事件报错:)" + ex.Message,ex);
  653. }
  654. }
  655. /// <summary>
  656. /// 设置 浏览事件
  657. /// </summary>
  658. /// <param name="sender"></param>
  659. /// <param name="e"></param>
  660. private void BtnBrowse_Click(object sender, RoutedEventArgs e)
  661. {
  662. //System.Diagnostics.Process.Start(APP.WKData.WkPath);
  663. string desktopPath = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
  664. Ofd = new System.Windows.Forms.FolderBrowserDialog();
  665. Result = Ofd.ShowDialog();
  666. if (Result == System.Windows.Forms.DialogResult.OK)
  667. {
  668. if (Ofd.SelectedPath != "")
  669. {
  670. txbStoragePath.Content = Ofd.SelectedPath;
  671. //string ApplicationData = ZConfig.dataPath + "fileStorageAddress.txt";
  672. //string temp = ofd.SelectedPath;
  673. //System.IO.File.WriteAllText(ApplicationData, temp, Encoding.Default);
  674. }
  675. }
  676. }
  677. #endregion
  678. #region 画笔
  679. /// <summary>
  680. /// 画笔颜色事件 白色
  681. /// </summary>
  682. /// <param name="sender"></param>
  683. /// <param name="e"></param>
  684. private void BtnWhite_Click(object sender, RoutedEventArgs e)
  685. {
  686. ////创建 DrawingAttributes 类的一个实例
  687. //drawingAttributes = new DrawingAttributes();
  688. ////将 InkCanvas 的 DefaultDrawingAttributes 属性的值赋成创建的 DrawingAttributes 类的对象的引用
  689. ////InkCanvas 通过 DefaultDrawingAttributes 属性来获取墨迹的各种设置,该属性的类型为 DrawingAttributes 型
  690. //blackboard_canvas.DefaultDrawingAttributes = drawingAttributes;
  691. ////设置 DrawingAttributes 的 Color 属性设置颜色
  692. drawingAttributes.Color = Colors.White;
  693. Color = Colors.White;
  694. }
  695. /// <summary>
  696. /// 画笔颜色事件 红色
  697. /// </summary>
  698. /// <param name="sender"></param>
  699. /// <param name="e"></param>
  700. private void BtnRed_Click(object sender, RoutedEventArgs e)
  701. {
  702. //设置 DrawingAttributes 的 Color 属性设置颜色
  703. drawingAttributes.Color = Colors.Red;
  704. Color = Colors.Red;
  705. imgRed.Visibility = Visibility.Visible;
  706. imgGray.Visibility = Visibility.Collapsed;
  707. imgCyanBlue.Visibility = Visibility.Collapsed;
  708. imgYellow.Visibility = Visibility.Collapsed;
  709. imgBlue.Visibility = Visibility.Collapsed;
  710. }
  711. /// <summary>
  712. /// 画笔颜色事件 黑色
  713. /// </summary>
  714. /// <param name="sender"></param>
  715. /// <param name="e"></param>
  716. private void BtnGray_Click(object sender, RoutedEventArgs e)
  717. {
  718. drawingAttributes.Color = Colors.Black;
  719. Color = Colors.Black;
  720. imgRed.Visibility = Visibility.Collapsed;
  721. imgGray.Visibility = Visibility.Visible;
  722. imgCyanBlue.Visibility = Visibility.Collapsed;
  723. imgYellow.Visibility = Visibility.Collapsed;
  724. imgBlue.Visibility = Visibility.Collapsed;
  725. }
  726. /// <summary>
  727. /// 画笔颜色事件 青色
  728. /// </summary>
  729. /// <param name="sender"></param>
  730. /// <param name="e"></param>
  731. private void BtnCyanBlue_Click(object sender, RoutedEventArgs e)
  732. {
  733. drawingAttributes.Color = Colors.LimeGreen;
  734. Color = Colors.LimeGreen;
  735. imgRed.Visibility = Visibility.Collapsed;
  736. imgGray.Visibility = Visibility.Collapsed;
  737. imgCyanBlue.Visibility = Visibility.Visible;
  738. imgYellow.Visibility = Visibility.Collapsed;
  739. imgBlue.Visibility = Visibility.Collapsed;
  740. }
  741. /// <summary>
  742. /// 画笔颜色事件 黄色
  743. /// </summary>
  744. /// <param name="sender"></param>
  745. /// <param name="e"></param>
  746. private void BtnYellow_Click(object sender, RoutedEventArgs e)
  747. {
  748. drawingAttributes.Color = Colors.Gold;
  749. Color = Colors.Gold;
  750. imgRed.Visibility = Visibility.Collapsed;
  751. imgGray.Visibility = Visibility.Collapsed;
  752. imgCyanBlue.Visibility = Visibility.Collapsed;
  753. imgYellow.Visibility = Visibility.Visible;
  754. imgBlue.Visibility = Visibility.Collapsed;
  755. }
  756. /// <summary>
  757. /// 画笔颜色事件 蓝色
  758. /// </summary>
  759. /// <param name="sender"></param>
  760. /// <param name="e"></param>
  761. private void BtnBlue_Click(object sender, RoutedEventArgs e)
  762. {
  763. drawingAttributes.Color = Colors.DeepSkyBlue;
  764. Color = Colors.DeepSkyBlue;
  765. imgRed.Visibility = Visibility.Collapsed;
  766. imgGray.Visibility = Visibility.Collapsed;
  767. imgCyanBlue.Visibility = Visibility.Collapsed;
  768. imgYellow.Visibility = Visibility.Collapsed;
  769. imgBlue.Visibility = Visibility.Visible;
  770. }
  771. /// <summary>
  772. /// 画笔粗细事件 细
  773. /// </summary>
  774. /// <param name="sender"></param>
  775. /// <param name="e"></param>
  776. private void RbnFine_Click(object sender, RoutedEventArgs e)
  777. {
  778. drawingAttributes.Width = 1;
  779. drawingAttributes.Height = 1;
  780. PenSize = 1;
  781. }
  782. /// <summary>
  783. /// 画笔粗细事件 中
  784. /// </summary>
  785. /// <param name="sender"></param>
  786. /// <param name="e"></param>
  787. private void RbnIn_Click(object sender, RoutedEventArgs e)
  788. {
  789. drawingAttributes.Width = 3;
  790. drawingAttributes.Height = 3;
  791. PenSize = 3;
  792. }
  793. /// <summary>
  794. /// 画笔粗细事件 粗
  795. /// </summary>
  796. /// <param name="sender"></param>
  797. /// <param name="e"></param>
  798. private void RbnCrude_Click(object sender, RoutedEventArgs e)
  799. {
  800. drawingAttributes.Width = 5;
  801. drawingAttributes.Height = 5;
  802. PenSize = 5;
  803. }
  804. #endregion
  805. #region 导入截图
  806. /// <summary>
  807. /// 截图事件
  808. /// </summary>
  809. /// <param name="sender"></param>
  810. /// <param name="e"></param>
  811. private void BtnScreenshot_Click(object sender, RoutedEventArgs e)
  812. {
  813. Record();
  814. HideAngleBorder();
  815. imgCanvas.Margin = new Thickness(0, 0, 0, 0);
  816. APP.ImgPath = string.Empty;
  817. string time = GetTimeStamp();
  818. string desktopPath = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory) + time + ".jpg";
  819. APP.ImgPath = desktopPath;
  820. ImageHelper.GetScreenshot(new System.Drawing.Rectangle(0, 0, 0, 0), desktopPath, false, out BitmapImage bitmap);
  821. if (WindowState == WindowState.Normal)//截图隐藏窗口
  822. {
  823. WindowState = WindowState.Minimized;
  824. }
  825. if (APP.W_JieTuWindow != null)
  826. {
  827. APP.W_JieTuWindow.initialization();
  828. APP.W_JieTuWindow.Screenshot();
  829. APP.W_JieTuWindow.WindowState = WindowState.Maximized;
  830. APP.W_JieTuWindow.Visibility = Visibility.Visible;
  831. }
  832. else
  833. {
  834. APP.W_JieTuWindow = new JieTuWindow();
  835. // 订阅事件
  836. APP.W_JieTuWindow.ChangeTextEvent += new ChangeTextHandler(frm_ChangeTextEvent);
  837. APP.W_JieTuWindow.click_closeJietuWindowClick += JietuWindow_click_closeJietuWindowClick;
  838. APP.W_JieTuWindow.Show();
  839. }
  840. //imgCanvas.Source = new BitmapImage(new Uri(desktopPath));
  841. }
  842. /// <summary>
  843. /// 截图关闭窗口
  844. /// </summary>
  845. /// <param name="text"></param>
  846. private void frm_ChangeTextEvent(string text)
  847. {
  848. if ("关闭窗口".Equals(text))
  849. {
  850. if (WindowState == WindowState.Minimized)//截图完恢复窗口
  851. {
  852. Topmost = true;
  853. WindowState = WindowState.Normal;
  854. }
  855. if (!string.IsNullOrWhiteSpace(APP.ImgPath) && File.Exists(APP.ImgPath))
  856. {
  857. if (APP.pageData.currpage == 0)
  858. {
  859. APP.pageData.pagenum += 1;
  860. APP.pageData.currpage = APP.pageData.pagenum;
  861. myblackboard.changepage(APP.pageData.currpage - 1);
  862. gridPage.Visibility = Visibility.Visible;//页码大于0 显示
  863. }
  864. if (APP.PageDrawList.Count >= APP.pageData.currpage)
  865. {
  866. APP.PageDrawList[APP.pageData.currpage - 1].PageImagePath = APP.ImgPath;//zxycs
  867. APP.PageDrawList[APP.pageData.currpage - 1].PdfImagePath = APP.ImgPath;
  868. }
  869. else
  870. {
  871. Model_DrawData model_DrawData = new Model_DrawData
  872. {
  873. PageImagePath = APP.ImgPath,
  874. PdfImagePath = APP.ImgPath
  875. };
  876. APP.PageDrawList.Add(model_DrawData);
  877. }
  878. if (APP.PageDrawList.Count >= APP.pageData.currpage && !string.IsNullOrWhiteSpace(APP.PageDrawList[APP.pageData.currpage - 1].PageImagePath))
  879. {
  880. imgDocumentation.Source = null;
  881. BitmapImage bitImg = new BitmapImage(new Uri(APP.PageDrawList[APP.pageData.currpage - 1].PageImagePath));
  882. mouseDown = false;
  883. APP.PageDrawList[APP.pageData.currpage - 1].ImageLocation = new TranslateTransform
  884. {
  885. X = 0.1,
  886. Y = 0.1
  887. };
  888. APP.PageDrawList[APP.pageData.currpage - 1].ImageSizes = new ScaleTransform
  889. {
  890. CenterX = 475,
  891. CenterY = 538
  892. };
  893. APP.PageDrawList[APP.pageData.currpage - 1].IsImageLocation = false;
  894. imgCanvas.Source = bitImg;
  895. imgCanvas.Width = bitImg.Width;
  896. imgCanvas.Height = bitImg.Height;
  897. ImgPrint.Visibility = Visibility.Visible;//截图成功可打印
  898. ImgPrintTwo.Visibility = Visibility.Collapsed;
  899. btnPrint.IsEnabled = true;
  900. }
  901. }
  902. Topmost = false;
  903. }
  904. }
  905. /// <summary>
  906. /// 截图关闭 非正常关闭截图时,截图清空
  907. /// </summary>
  908. private void JietuWindow_click_closeJietuWindowClick()
  909. {
  910. if (WindowState == WindowState.Minimized)//截图完恢复窗口
  911. {
  912. WindowState = WindowState.Normal;
  913. }
  914. APP.W_JieTuWindow = null;
  915. }
  916. /// 截图的图片鼠标右键事件
  917. /// </summary>
  918. /// <param name="sender"></param>
  919. /// <param name="e"></param>
  920. private void imgCanvas_MouseRightButtonDown(object sender, MouseButtonEventArgs e)
  921. {
  922. imgCanvas.Source = null;
  923. }
  924. /// <summary>
  925. /// 导入事件
  926. /// </summary>
  927. /// <param name="sender"></param>
  928. /// <param name="e"></param>
  929. private void BtnImport_Click(object sender, RoutedEventArgs e)
  930. {
  931. try
  932. {
  933. Record();
  934. HideAngleBorder();
  935. string desktopPath = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
  936. ofd = new System.Windows.Forms.OpenFileDialog
  937. {
  938. //Filter = "文档|*.docx;*.doc;*.ppt;*.pptx",
  939. Filter = "文档|*.docx;*.doc;*.ppt;*.pptx",
  940. InitialDirectory = desktopPath,
  941. Multiselect = false,
  942. AddExtension = true,
  943. DereferenceLinks = true
  944. };
  945. //APP.myloading.Show();
  946. APP.BackgroundWorkerHelper.RunWorkerAsync(InvokeServering, InvokeServerCompate);
  947. //new Thread(
  948. // o =>
  949. // {
  950. // Thread.Sleep(400);
  951. // Dispatcher.Invoke(new Action(() =>
  952. // {
  953. // OpenDialog();
  954. // }
  955. // ));
  956. // })
  957. //{
  958. // IsBackground = true
  959. //}.Start();
  960. }
  961. catch (Exception ex)
  962. {
  963. LogHelper.WriteErrLog("【导入(BtnImport_Click)" + ex.Message, ex);
  964. }
  965. }
  966. /// <summary>
  967. /// 导入-开始
  968. /// </summary>
  969. /// <returns></returns>
  970. private object InvokeServering()
  971. {
  972. Dispatcher.Invoke(new Action(() =>
  973. {
  974. result = ofd.ShowDialog();
  975. }));
  976. if (result == System.Windows.Forms.DialogResult.OK)
  977. {
  978. if (ofd.FileName != "")
  979. {
  980. Dispatcher.Invoke(new Action(() =>
  981. {
  982. APP.myloading.Show();
  983. myblackboard.changepage(APP.pageData.pagenum);
  984. }));
  985. #region PPT转PDF
  986. string filepath = ofd.FileName;
  987. string path = ofd.SafeFileName.Replace(".ppt", "").Replace(".pptx", "").Trim();
  988. string type = ofd.SafeFileName.Replace(".ppt", "typezsygppt").Replace(".pptx", "typezsygppt").Replace(".pdf", "typepdf").Trim();
  989. if (type.Contains("typezsygppt"))//ppt
  990. {
  991. try
  992. {
  993. string pathTemp = AppDomain.CurrentDomain.BaseDirectory + "Temp\\";
  994. path = pathTemp + path + ".pdf";
  995. FileToolsCommon.CreateDirectory(pathTemp);
  996. //PPT转PDF
  997. Presentation ppt = new Presentation(filepath);
  998. ppt.Save(path, Aspose.Slides.Export.SaveFormat.Pdf);
  999. #endregion
  1000. #region PDF转图片
  1001. // 图片绝对路径集合
  1002. List<string> images = new List<string>();
  1003. string directoryPath = pathTemp;
  1004. //aspose许可证
  1005. //Aspose.Pdf.License l = new Aspose.Pdf.License();
  1006. //string licenseName = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Aspose.Total.Product.Family.lic");
  1007. //l.SetLicense(licenseName);
  1008. //定义Jpeg转换设备
  1009. Aspose.Pdf.Document document = new Aspose.Pdf.Document(path);
  1010. Aspose.Pdf.Devices.JpegDevice device = new Aspose.Pdf.Devices.JpegDevice();
  1011. //int quality = int.Parse(this.comboBox1.SelectedItem.ToString());
  1012. //directoryPath += quality;
  1013. Directory.CreateDirectory(directoryPath);
  1014. //默认质量为100,设置质量的好坏与处理速度不成正比,甚至是设置的质量越低反而花的时间越长,怀疑处理过程是先生成高质量的再压缩
  1015. device = new Aspose.Pdf.Devices.JpegDevice(100);
  1016. //遍历每一页转为jpg
  1017. for (int i = 1; i <= document.Pages.Count; i++)
  1018. {
  1019. long ii = Timestamp();
  1020. string filePathOutPut = Path.Combine(directoryPath, string.Format("{0}{1}.jpg", ii, i));
  1021. images.Add(filePathOutPut);
  1022. FileStream fs = new FileStream(filePathOutPut, FileMode.OpenOrCreate);
  1023. try
  1024. {
  1025. device.Process(document.Pages[i], fs);
  1026. fs.Close();
  1027. }
  1028. catch (Exception)
  1029. {
  1030. fs.Close();
  1031. File.Delete(filePathOutPut);
  1032. }
  1033. }
  1034. #endregion
  1035. Dispatcher.Invoke(new Action(() =>
  1036. {
  1037. string[] page = images.ToArray();
  1038. int num = 0;
  1039. for (int i = 0 + APP.pageData.pagenum; i < page.Length + APP.pageData.pagenum; i++)//给画板模型加图片路径
  1040. {
  1041. if (APP.PageDrawList != null && APP.PageDrawList.Count > i)
  1042. {
  1043. APP.PageDrawList[i].PageImagePath = page[i - APP.pageData.pagenum]; //zxycs
  1044. APP.PageDrawList[i].PdfImagePath = page[i - APP.pageData.pagenum];
  1045. APP.PageDrawList[i].PageNum = i + 1;
  1046. APP.PageDrawList[i].ImgDocumentation = true;
  1047. }
  1048. else
  1049. {
  1050. Model_DrawData model_DrawData = new Model_DrawData
  1051. {
  1052. PageImagePath = page[i - APP.pageData.pagenum],
  1053. PdfImagePath = page[i - APP.pageData.pagenum],
  1054. PageNum = i + 1,
  1055. ImgDocumentation = true
  1056. };
  1057. APP.PageDrawList.Add(model_DrawData);
  1058. }
  1059. ImgPrint.Visibility = Visibility.Visible;//导入成功可打印
  1060. ImgPrintTwo.Visibility = Visibility.Collapsed;
  1061. btnPrint.IsEnabled = true;
  1062. APP.SaveDraw();
  1063. num++;
  1064. }
  1065. if (num > 0)
  1066. {
  1067. APP.pageData.currpage = APP.pageData.pagenum + 1;
  1068. APP.pageData.pagenum += num;
  1069. gridPage.Visibility = Visibility.Visible;//页码大于0 显示
  1070. }
  1071. if (APP.pageData.currpage > 0 && APP.pageData.currpage < APP.PageDrawList.Count)
  1072. {
  1073. imgCanvas.Source = null;
  1074. ImgScreenshot.Visibility = Visibility.Collapsed;//当前页为导入时不可截图
  1075. ImgScreenshotTwo.Visibility = Visibility.Visible;
  1076. btnScreenshot.IsEnabled = false;
  1077. imgDocumentation.Source = new BitmapImage(new Uri(APP.PageDrawList[APP.pageData.currpage - 1].PageImagePath));//给当前页面展示图片
  1078. }
  1079. else
  1080. {
  1081. imgDocumentation.Source = null;
  1082. imgCanvas.Source = null;
  1083. ///截图可用
  1084. ImgScreenshot.Visibility = Visibility.Visible;
  1085. ImgScreenshotTwo.Visibility = Visibility.Collapsed;
  1086. btnScreenshot.IsEnabled = true;
  1087. }
  1088. }));
  1089. }
  1090. catch (Exception ex)
  1091. {
  1092. MessageWindow.Show("文件无效或者文件被加密!");
  1093. LogHelper.WriteErrLog("【打开ppt】(OpenDialog PPT)" + ex.Message, ex);
  1094. }
  1095. }
  1096. else if (type.Contains("typepdf"))
  1097. {
  1098. string pathTemp = AppDomain.CurrentDomain.BaseDirectory + "Temp\\";
  1099. #region PDF转图片
  1100. // 图片绝对路径集合
  1101. List<string> images = new List<string>();
  1102. string directoryPath = pathTemp;
  1103. //aspose许可证
  1104. //Aspose.Pdf.License l = new Aspose.Pdf.License();
  1105. //string licenseName = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Aspose.Total.Product.Family.lic");
  1106. //l.SetLicense(licenseName);
  1107. //定义Jpeg转换设备
  1108. Aspose.Pdf.Document document = new Aspose.Pdf.Document(filepath);
  1109. Aspose.Pdf.Devices.JpegDevice device = new Aspose.Pdf.Devices.JpegDevice();
  1110. //int quality = int.Parse(this.comboBox1.SelectedItem.ToString());
  1111. //directoryPath += quality;
  1112. Directory.CreateDirectory(directoryPath);
  1113. //默认质量为100,设置质量的好坏与处理速度不成正比,甚至是设置的质量越低反而花的时间越长,怀疑处理过程是先生成高质量的再压缩
  1114. device = new Aspose.Pdf.Devices.JpegDevice(100);
  1115. //遍历每一页转为jpg
  1116. for (int i = 1; i <= document.Pages.Count; i++)
  1117. {
  1118. long ii = Timestamp();
  1119. string filePathOutPut = Path.Combine(directoryPath, string.Format("{0}{1}.jpg", ii, i));
  1120. images.Add(filePathOutPut);
  1121. FileStream fs = new FileStream(filePathOutPut, FileMode.OpenOrCreate);
  1122. try
  1123. {
  1124. device.Process(document.Pages[i], fs);
  1125. fs.Close();
  1126. }
  1127. catch (Exception)
  1128. {
  1129. fs.Close();
  1130. File.Delete(filePathOutPut);
  1131. }
  1132. }
  1133. #endregion
  1134. string[] page = images.ToArray();
  1135. int num = 0;
  1136. for (int i = 0 + APP.pageData.pagenum; i < page.Length + APP.pageData.pagenum; i++)//给画板模型加图片路径
  1137. {
  1138. if (APP.PageDrawList != null && APP.PageDrawList.Count > i)
  1139. {
  1140. APP.PageDrawList[i].PageImagePath = page[i - APP.pageData.pagenum]; //zxycs
  1141. APP.PageDrawList[i].PdfImagePath = page[i - APP.pageData.pagenum];
  1142. APP.PageDrawList[i].PageNum = i + 1;
  1143. APP.PageDrawList[i].ImgDocumentation = true;
  1144. }
  1145. else
  1146. {
  1147. Model_DrawData model_DrawData = new Model_DrawData
  1148. {
  1149. PageImagePath = page[i - APP.pageData.pagenum],
  1150. PdfImagePath = page[i - APP.pageData.pagenum],
  1151. PageNum = i + 1,
  1152. ImgDocumentation = true
  1153. };
  1154. APP.PageDrawList.Add(model_DrawData);
  1155. }
  1156. ImgPrint.Visibility = Visibility.Visible;//导入成功可打印
  1157. ImgPrintTwo.Visibility = Visibility.Collapsed;
  1158. btnPrint.IsEnabled = true;
  1159. APP.SaveDraw();
  1160. num++;
  1161. }
  1162. if (num > 0)
  1163. {
  1164. APP.pageData.currpage = APP.pageData.pagenum + 1;
  1165. APP.pageData.pagenum += num;
  1166. gridPage.Visibility = Visibility.Visible;//页码大于0 显示
  1167. }
  1168. if (APP.pageData.currpage > 0 && APP.pageData.currpage < APP.PageDrawList.Count)
  1169. {
  1170. imgCanvas.Source = null;
  1171. ImgScreenshot.Visibility = Visibility.Collapsed;//当前页为导入时不可截图
  1172. ImgScreenshotTwo.Visibility = Visibility.Visible;
  1173. btnScreenshot.IsEnabled = false;
  1174. imgDocumentation.Source = new BitmapImage(new Uri(APP.PageDrawList[APP.pageData.currpage - 1].PageImagePath));//给当前页面展示图片
  1175. }
  1176. else
  1177. {
  1178. imgDocumentation.Source = null;
  1179. imgCanvas.Source = null;
  1180. ///截图可用
  1181. ImgScreenshot.Visibility = Visibility.Visible;
  1182. ImgScreenshotTwo.Visibility = Visibility.Collapsed;
  1183. btnScreenshot.IsEnabled = true;
  1184. }
  1185. APP.myloading.Hide();
  1186. }
  1187. else//word
  1188. {
  1189. try
  1190. {
  1191. string paths = AppDomain.CurrentDomain.BaseDirectory + "Temp\\";
  1192. string[] page = ConvertWordToImage(filepath, paths, "", 0, 0, null, 0).ToArray();
  1193. int num = 0;
  1194. Dispatcher.Invoke(new Action(() =>
  1195. {
  1196. for (int i = 0 + APP.pageData.pagenum; i < page.Length + APP.pageData.pagenum; i++)//给画板模型加图片路径
  1197. {
  1198. if (APP.PageDrawList != null && APP.PageDrawList.Count > i)
  1199. {
  1200. APP.PageDrawList[i].PageImagePath = page[i - APP.pageData.pagenum]; //zxycs
  1201. APP.PageDrawList[i].PdfImagePath = page[i - APP.pageData.pagenum];
  1202. APP.PageDrawList[i].PageNum = i + 1;
  1203. APP.PageDrawList[i].ImgDocumentation = true;
  1204. }
  1205. else
  1206. {
  1207. Model_DrawData model_DrawData = new Model_DrawData
  1208. {
  1209. PageImagePath = page[i - APP.pageData.pagenum],
  1210. PdfImagePath = page[i - APP.pageData.pagenum],
  1211. PageNum = i + 1,
  1212. ImgDocumentation = true
  1213. };
  1214. APP.PageDrawList.Add(model_DrawData);
  1215. }
  1216. ImgPrint.Visibility = Visibility.Visible;//导入成功可打印
  1217. ImgPrintTwo.Visibility = Visibility.Collapsed;
  1218. btnPrint.IsEnabled = true;
  1219. APP.SaveDraw();
  1220. num++;
  1221. }
  1222. if (num > 0)
  1223. {
  1224. APP.pageData.currpage = APP.pageData.pagenum + 1;
  1225. APP.pageData.pagenum += num;
  1226. gridPage.Visibility = Visibility.Visible;//页码大于0 显示
  1227. }
  1228. if (APP.pageData.currpage > 0 && APP.pageData.currpage < APP.PageDrawList.Count)
  1229. {
  1230. imgCanvas.Source = null;
  1231. ImgScreenshot.Visibility = Visibility.Collapsed;//当前页为导入时不可截图
  1232. ImgScreenshotTwo.Visibility = Visibility.Visible;
  1233. btnScreenshot.IsEnabled = false;
  1234. imgDocumentation.Visibility = Visibility.Visible;
  1235. imgDocumentation.Source = new BitmapImage(new Uri(APP.PageDrawList[APP.pageData.currpage - 1].PageImagePath));//给当前页面展示图片
  1236. }
  1237. else
  1238. {
  1239. imgDocumentation.Source = null;
  1240. imgCanvas.Source = null;
  1241. ///截图可用
  1242. ImgScreenshot.Visibility = Visibility.Visible;
  1243. ImgScreenshotTwo.Visibility = Visibility.Collapsed;
  1244. btnScreenshot.IsEnabled = true;
  1245. }
  1246. }));
  1247. }
  1248. catch (Exception ex)
  1249. {
  1250. APP.myloading.Hide();
  1251. LogHelper.WriteErrLog("【XHMicroLessonSystemWindow】(OpenDialog 导入文档)" + ex.Message, ex);
  1252. }
  1253. }
  1254. }
  1255. }
  1256. //OpenDialog();
  1257. return "";
  1258. }
  1259. /// <summary>
  1260. /// 导入-结束
  1261. /// </summary>
  1262. /// <returns></returns>
  1263. public void InvokeServerCompate(object obj)
  1264. {
  1265. //APP.myloading.Hide();
  1266. APP.myloading.Hide();
  1267. }
  1268. /// <summary>
  1269. /// 导入文档
  1270. /// </summary>
  1271. private void OpenDialog()
  1272. {
  1273. Dispatcher.Invoke(new Action(() =>
  1274. {
  1275. result = ofd.ShowDialog();
  1276. if (result == System.Windows.Forms.DialogResult.OK)
  1277. {
  1278. if (ofd.FileName != "")
  1279. {
  1280. APP.myloading.Show();
  1281. myblackboard.changepage(APP.pageData.pagenum);
  1282. #region PPT转PDF
  1283. string filepath = ofd.FileName;
  1284. string path = ofd.SafeFileName.Replace(".ppt", "").Replace(".pptx", "").Trim();
  1285. string type = ofd.SafeFileName.Replace(".ppt", "typezsygppt").Replace(".pptx", "typezsygppt").Replace(".pdf", "typepdf").Trim();
  1286. if (type.Contains("typezsygppt"))//ppt
  1287. {
  1288. try
  1289. {
  1290. string pathTemp = AppDomain.CurrentDomain.BaseDirectory + "Temp\\";
  1291. path = pathTemp + path + ".pdf";
  1292. FileToolsCommon.CreateDirectory(pathTemp);
  1293. //PPT转PDF
  1294. Presentation ppt = new Presentation(filepath);
  1295. ppt.Save(path, Aspose.Slides.Export.SaveFormat.Pdf);
  1296. #endregion
  1297. #region PDF转图片
  1298. // 图片绝对路径集合
  1299. List<string> images = new List<string>();
  1300. string directoryPath = pathTemp;
  1301. //aspose许可证
  1302. //Aspose.Pdf.License l = new Aspose.Pdf.License();
  1303. //string licenseName = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Aspose.Total.Product.Family.lic");
  1304. //l.SetLicense(licenseName);
  1305. //定义Jpeg转换设备
  1306. Aspose.Pdf.Document document = new Aspose.Pdf.Document(path);
  1307. Aspose.Pdf.Devices.JpegDevice device = new Aspose.Pdf.Devices.JpegDevice();
  1308. //int quality = int.Parse(this.comboBox1.SelectedItem.ToString());
  1309. //directoryPath += quality;
  1310. Directory.CreateDirectory(directoryPath);
  1311. //默认质量为100,设置质量的好坏与处理速度不成正比,甚至是设置的质量越低反而花的时间越长,怀疑处理过程是先生成高质量的再压缩
  1312. device = new Aspose.Pdf.Devices.JpegDevice(100);
  1313. //遍历每一页转为jpg
  1314. for (int i = 1; i <= document.Pages.Count; i++)
  1315. {
  1316. long ii = Timestamp();
  1317. string filePathOutPut = Path.Combine(directoryPath, string.Format("{0}{1}.jpg", ii, i));
  1318. images.Add(filePathOutPut);
  1319. FileStream fs = new FileStream(filePathOutPut, FileMode.OpenOrCreate);
  1320. try
  1321. {
  1322. device.Process(document.Pages[i], fs);
  1323. fs.Close();
  1324. }
  1325. catch (Exception)
  1326. {
  1327. fs.Close();
  1328. File.Delete(filePathOutPut);
  1329. }
  1330. }
  1331. #endregion
  1332. string[] page = images.ToArray();
  1333. int num = 0;
  1334. for (int i = 0 + APP.pageData.pagenum; i < page.Length + APP.pageData.pagenum; i++)//给画板模型加图片路径
  1335. {
  1336. if (APP.PageDrawList != null && APP.PageDrawList.Count > i)
  1337. {
  1338. APP.PageDrawList[i].PageImagePath = page[i - APP.pageData.pagenum]; //zxycs
  1339. APP.PageDrawList[i].PdfImagePath = page[i - APP.pageData.pagenum];
  1340. APP.PageDrawList[i].PageNum = i + 1;
  1341. APP.PageDrawList[i].ImgDocumentation = true;
  1342. }
  1343. else
  1344. {
  1345. Model_DrawData model_DrawData = new Model_DrawData
  1346. {
  1347. PageImagePath = page[i - APP.pageData.pagenum],
  1348. PdfImagePath = page[i - APP.pageData.pagenum],
  1349. PageNum = i + 1,
  1350. ImgDocumentation = true
  1351. };
  1352. APP.PageDrawList.Add(model_DrawData);
  1353. }
  1354. ImgPrint.Visibility = Visibility.Visible;//导入成功可打印
  1355. ImgPrintTwo.Visibility = Visibility.Collapsed;
  1356. btnPrint.IsEnabled = true;
  1357. APP.SaveDraw();
  1358. num++;
  1359. }
  1360. if (num > 0)
  1361. {
  1362. APP.pageData.currpage = APP.pageData.pagenum + 1;
  1363. APP.pageData.pagenum += num;
  1364. gridPage.Visibility = Visibility.Visible;//页码大于0 显示
  1365. }
  1366. if (APP.pageData.currpage > 0 && APP.pageData.currpage < APP.PageDrawList.Count)
  1367. {
  1368. imgCanvas.Source = null;
  1369. ImgScreenshot.Visibility = Visibility.Collapsed;//当前页为导入时不可截图
  1370. ImgScreenshotTwo.Visibility = Visibility.Visible;
  1371. btnScreenshot.IsEnabled = false;
  1372. imgDocumentation.Source = new BitmapImage(new Uri(APP.PageDrawList[APP.pageData.currpage - 1].PageImagePath));//给当前页面展示图片
  1373. }
  1374. else
  1375. {
  1376. imgDocumentation.Source = null;
  1377. imgCanvas.Source = null;
  1378. ///截图可用
  1379. ImgScreenshot.Visibility = Visibility.Visible;
  1380. ImgScreenshotTwo.Visibility = Visibility.Collapsed;
  1381. btnScreenshot.IsEnabled = true;
  1382. }
  1383. APP.myloading.Hide();
  1384. }
  1385. catch (Exception ex)
  1386. {
  1387. APP.myloading.Hide();
  1388. MessageWindow.Show("文件无效或者文件被加密!");
  1389. LogHelper.WriteErrLog("【打开ppt】(OpenDialog PPT)" + ex.Message, ex);
  1390. }
  1391. }
  1392. else if (type.Contains("typepdf"))
  1393. {
  1394. string pathTemp = AppDomain.CurrentDomain.BaseDirectory + "Temp\\";
  1395. #region PDF转图片
  1396. // 图片绝对路径集合
  1397. List<string> images = new List<string>();
  1398. string directoryPath = pathTemp;
  1399. //aspose许可证
  1400. //Aspose.Pdf.License l = new Aspose.Pdf.License();
  1401. //string licenseName = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Aspose.Total.Product.Family.lic");
  1402. //l.SetLicense(licenseName);
  1403. //定义Jpeg转换设备
  1404. Aspose.Pdf.Document document = new Aspose.Pdf.Document(filepath);
  1405. Aspose.Pdf.Devices.JpegDevice device = new Aspose.Pdf.Devices.JpegDevice();
  1406. //int quality = int.Parse(this.comboBox1.SelectedItem.ToString());
  1407. //directoryPath += quality;
  1408. Directory.CreateDirectory(directoryPath);
  1409. //默认质量为100,设置质量的好坏与处理速度不成正比,甚至是设置的质量越低反而花的时间越长,怀疑处理过程是先生成高质量的再压缩
  1410. device = new Aspose.Pdf.Devices.JpegDevice(100);
  1411. //遍历每一页转为jpg
  1412. for (int i = 1; i <= document.Pages.Count; i++)
  1413. {
  1414. long ii = Timestamp();
  1415. string filePathOutPut = Path.Combine(directoryPath, string.Format("{0}{1}.jpg", ii, i));
  1416. images.Add(filePathOutPut);
  1417. FileStream fs = new FileStream(filePathOutPut, FileMode.OpenOrCreate);
  1418. try
  1419. {
  1420. device.Process(document.Pages[i], fs);
  1421. fs.Close();
  1422. }
  1423. catch (Exception)
  1424. {
  1425. fs.Close();
  1426. File.Delete(filePathOutPut);
  1427. }
  1428. }
  1429. #endregion
  1430. string[] page = images.ToArray();
  1431. int num = 0;
  1432. for (int i = 0 + APP.pageData.pagenum; i < page.Length + APP.pageData.pagenum; i++)//给画板模型加图片路径
  1433. {
  1434. if (APP.PageDrawList != null && APP.PageDrawList.Count > i)
  1435. {
  1436. APP.PageDrawList[i].PageImagePath = page[i - APP.pageData.pagenum]; //zxycs
  1437. APP.PageDrawList[i].PdfImagePath = page[i - APP.pageData.pagenum];
  1438. APP.PageDrawList[i].PageNum = i + 1;
  1439. APP.PageDrawList[i].ImgDocumentation = true;
  1440. }
  1441. else
  1442. {
  1443. Model_DrawData model_DrawData = new Model_DrawData
  1444. {
  1445. PageImagePath = page[i - APP.pageData.pagenum],
  1446. PdfImagePath = page[i - APP.pageData.pagenum],
  1447. PageNum = i + 1,
  1448. ImgDocumentation = true
  1449. };
  1450. APP.PageDrawList.Add(model_DrawData);
  1451. }
  1452. ImgPrint.Visibility = Visibility.Visible;//导入成功可打印
  1453. ImgPrintTwo.Visibility = Visibility.Collapsed;
  1454. btnPrint.IsEnabled = true;
  1455. APP.SaveDraw();
  1456. num++;
  1457. }
  1458. if (num > 0)
  1459. {
  1460. APP.pageData.currpage = APP.pageData.pagenum + 1;
  1461. APP.pageData.pagenum += num;
  1462. gridPage.Visibility = Visibility.Visible;//页码大于0 显示
  1463. }
  1464. if (APP.pageData.currpage > 0 && APP.pageData.currpage < APP.PageDrawList.Count)
  1465. {
  1466. imgCanvas.Source = null;
  1467. ImgScreenshot.Visibility = Visibility.Collapsed;//当前页为导入时不可截图
  1468. ImgScreenshotTwo.Visibility = Visibility.Visible;
  1469. btnScreenshot.IsEnabled = false;
  1470. imgDocumentation.Source = new BitmapImage(new Uri(APP.PageDrawList[APP.pageData.currpage - 1].PageImagePath));//给当前页面展示图片
  1471. }
  1472. else
  1473. {
  1474. imgDocumentation.Source = null;
  1475. imgCanvas.Source = null;
  1476. ///截图可用
  1477. ImgScreenshot.Visibility = Visibility.Visible;
  1478. ImgScreenshotTwo.Visibility = Visibility.Collapsed;
  1479. btnScreenshot.IsEnabled = true;
  1480. }
  1481. APP.myloading.Hide();
  1482. }
  1483. else//word
  1484. {
  1485. try
  1486. {
  1487. string paths = AppDomain.CurrentDomain.BaseDirectory + "Temp\\";
  1488. string[] page = ConvertWordToImage(filepath, paths, "", 0, 0, null, 0).ToArray();
  1489. int num = 0;
  1490. for (int i = 0 + APP.pageData.pagenum; i < page.Length + APP.pageData.pagenum; i++)//给画板模型加图片路径
  1491. {
  1492. if (APP.PageDrawList != null && APP.PageDrawList.Count > i)
  1493. {
  1494. APP.PageDrawList[i].PageImagePath = page[i - APP.pageData.pagenum]; //zxycs
  1495. APP.PageDrawList[i].PdfImagePath = page[i - APP.pageData.pagenum];
  1496. APP.PageDrawList[i].PageNum = i + 1;
  1497. APP.PageDrawList[i].ImgDocumentation = true;
  1498. }
  1499. else
  1500. {
  1501. Model_DrawData model_DrawData = new Model_DrawData
  1502. {
  1503. PageImagePath = page[i - APP.pageData.pagenum],
  1504. PdfImagePath = page[i - APP.pageData.pagenum],
  1505. PageNum = i + 1,
  1506. ImgDocumentation = true
  1507. };
  1508. APP.PageDrawList.Add(model_DrawData);
  1509. }
  1510. ImgPrint.Visibility = Visibility.Visible;//导入成功可打印
  1511. ImgPrintTwo.Visibility = Visibility.Collapsed;
  1512. btnPrint.IsEnabled = true;
  1513. APP.SaveDraw();
  1514. num++;
  1515. }
  1516. if (num > 0)
  1517. {
  1518. APP.pageData.currpage = APP.pageData.pagenum + 1;
  1519. APP.pageData.pagenum += num;
  1520. gridPage.Visibility = Visibility.Visible;//页码大于0 显示
  1521. }
  1522. if (APP.pageData.currpage > 0 && APP.pageData.currpage < APP.PageDrawList.Count)
  1523. {
  1524. imgCanvas.Source = null;
  1525. ImgScreenshot.Visibility = Visibility.Collapsed;//当前页为导入时不可截图
  1526. ImgScreenshotTwo.Visibility = Visibility.Visible;
  1527. btnScreenshot.IsEnabled = false;
  1528. imgDocumentation.Visibility = Visibility.Visible;
  1529. imgDocumentation.Source = new BitmapImage(new Uri(APP.PageDrawList[APP.pageData.currpage - 1].PageImagePath));//给当前页面展示图片
  1530. }
  1531. else
  1532. {
  1533. imgDocumentation.Source = null;
  1534. imgCanvas.Source = null;
  1535. ///截图可用
  1536. ImgScreenshot.Visibility = Visibility.Visible;
  1537. ImgScreenshotTwo.Visibility = Visibility.Collapsed;
  1538. btnScreenshot.IsEnabled = true;
  1539. }
  1540. APP.myloading.Hide();
  1541. }
  1542. catch (Exception ex)
  1543. {
  1544. APP.myloading.Hide();
  1545. LogHelper.WriteErrLog("【XHMicroLessonSystemWindow】(OpenDialog 导入文档)" + ex.Message, ex);
  1546. }
  1547. }
  1548. }
  1549. }
  1550. }
  1551. ));
  1552. }
  1553. #endregion
  1554. #region 上传 列表
  1555. /// <summary>
  1556. /// 上传事件
  1557. /// </summary>
  1558. /// <param name="sender"></param>
  1559. /// <param name="e"></param>
  1560. private void BtnUpload_Click(object sender, RoutedEventArgs e)
  1561. {
  1562. //if (gridUpload.Visibility == Visibility.Visible)
  1563. //{
  1564. // gridUpload.Visibility = Visibility.Collapsed;
  1565. // GridMain.Visibility = Visibility.Visible;
  1566. // //ImgRecord.Visibility = Visibility.Visible;//上传结束时可录制
  1567. // //ImgRecordTwo.Visibility = Visibility.Collapsed;//上传结束时可录制
  1568. // //BtnRecord.IsEnabled = true;//设置结束时可录制
  1569. // if (APP.pageData.pagenum > 0)
  1570. // {
  1571. // gridPage.Visibility = Visibility.Visible;
  1572. // }
  1573. // DataContext = APP.pageData;
  1574. //}
  1575. //else
  1576. //{
  1577. // gridPage.Visibility = Visibility.Collapsed;
  1578. // gridUpload.Visibility = Visibility.Visible;
  1579. // GridMain.Visibility = Visibility.Collapsed;
  1580. // //ImgRecord.Visibility = Visibility.Collapsed;//上传时不可录制
  1581. // //ImgRecordTwo.Visibility = Visibility.Visible;//上传时不可录制
  1582. // //BtnRecord.IsEnabled = false;//上传时不可录制
  1583. // InitializeUpload();
  1584. //}
  1585. if (GridMyVideo.Visibility == Visibility.Visible)
  1586. {
  1587. GridMyVideo.Visibility = Visibility.Collapsed;
  1588. GridMain.Visibility = Visibility.Visible;
  1589. if (APP.pageData.pagenum > 0)
  1590. {
  1591. gridPage.Visibility = Visibility.Visible;
  1592. }
  1593. DataContext = APP.pageData;
  1594. }
  1595. else
  1596. {
  1597. gridSetUp.Visibility = Visibility.Collapsed;
  1598. gridPage.Visibility = Visibility.Collapsed;
  1599. GridMyVideo.Visibility = Visibility.Visible;
  1600. GridMain.Visibility = Visibility.Collapsed;
  1601. LoadUploadInitData();
  1602. }
  1603. //btnStop.IsEnabled = true;//停止录制按钮可点击
  1604. }
  1605. /// <summary>
  1606. /// 初始化上传
  1607. /// </summary>
  1608. public void InitializeUpload()
  1609. {
  1610. APP.myloading.Show();
  1611. MouseNumber = 0;
  1612. IsModify = false;
  1613. //加载视频列表
  1614. LoadingVideoList();
  1615. int i = 1;
  1616. bool isColour = true;
  1617. pageData.menuList.Clear();
  1618. //显示视频
  1619. foreach (Model_Video videoinfo in model_VideoList)
  1620. {
  1621. //是否已上传
  1622. //videoinfo.IsUpload;
  1623. //录制时间
  1624. //videoinfo.RSTime;
  1625. //文件大小
  1626. //videoinfo.VideoSize;
  1627. //文件缩略图路径
  1628. //videoinfo.ThumbnailPath;
  1629. //文件唯一标示 上传事件筛选需要上传的视频
  1630. //videoinfo.FileGuid;
  1631. //文件存储路径
  1632. //videoinfo.VidePath;
  1633. string colour = "#FFFFFF";
  1634. if (isColour == true)
  1635. {
  1636. colour = "#FFFFFF";
  1637. isColour = false;
  1638. }
  1639. else
  1640. {
  1641. colour = "#E6F1FF";
  1642. isColour = true;
  1643. }
  1644. string vis = "Visible";
  1645. string cos = "Collapsed";
  1646. if (!videoinfo.IsUpload)
  1647. {
  1648. vis = "Collapsed";
  1649. cos = "Visible";
  1650. }
  1651. //if(i==1)//ceshi
  1652. //{
  1653. // vis = "Visible";
  1654. // cos = "Collapsed";
  1655. //}
  1656. if (i <= 16)
  1657. {
  1658. pageData.menuList.Add(new FileDirectoryModel()
  1659. {
  1660. SerialNumber = i,
  1661. VideoName = Common.system.FileToolsCommon.GetIOFileName(videoinfo.VideoPath).Replace(".MP4", "").Replace(".FLV", "").Replace(".AVI", "").Trim(),
  1662. Name = Common.system.FileToolsCommon.GetIOFileName(videoinfo.VideoPath).Replace(".MP4", "").Replace(".FLV", "").Replace(".AVI", "").Trim(),
  1663. FilePath = videoinfo.VideoPath.Replace(FileToolsCommon.GetIOFileName(videoinfo.VideoPath), "").Trim(),
  1664. VideoDuration = 0,
  1665. VideoSize = videoinfo.VideoSize,
  1666. VideoTime = videoinfo.RSTime,
  1667. IsEnabled = false,
  1668. Path = videoinfo.VideoPath,
  1669. Colour = colour,
  1670. Visi = vis,
  1671. Coll = cos,
  1672. FileGuid = videoinfo.FileGuid,
  1673. VideoType = videoinfo.VideoType.ToString(),
  1674. VideoSizes= videoinfo.VideoSizebyte
  1675. }); ;
  1676. }
  1677. i++;
  1678. }
  1679. Currpage = 0;
  1680. PageNum = 0;
  1681. if (pageData.menuList.Count > 0)
  1682. {
  1683. Currpage = 1;
  1684. txbCurrpageTwo.Text = Currpage.ToString();
  1685. stpUp.Visibility = Visibility.Visible;
  1686. }
  1687. else
  1688. {
  1689. stpUp.Visibility = Visibility.Hidden;
  1690. }
  1691. PageNum = model_VideoList.Count;
  1692. if (PageNum > 0)
  1693. {
  1694. int t = 1;
  1695. while (PageNum > 16 * t)
  1696. {
  1697. t++;
  1698. }
  1699. PageNum = t;
  1700. }
  1701. else
  1702. {
  1703. PageNum = 0;
  1704. }
  1705. txbPageNumTwo.Text = PageNum.ToString();
  1706. APP.myloading.Hide();
  1707. DataContext = pageData;
  1708. }
  1709. /// <summary>
  1710. /// 当前页
  1711. /// </summary>
  1712. private int Currpage = 0;
  1713. /// <summary>
  1714. /// 总页码
  1715. /// </summary>
  1716. private int PageNum = 0;
  1717. /// <summary>
  1718. /// 加载视频列表
  1719. /// </summary>
  1720. public void LoadingVideoList()
  1721. {
  1722. try
  1723. {
  1724. model_VideoList = new List<Model_Video>();
  1725. foreach (Model_WKData Vdata in APP.WKDataList)
  1726. {
  1727. #region 计时器初始化
  1728. if (Vdata.VideoList == null)
  1729. {
  1730. continue;
  1731. }
  1732. foreach (Model_Video videoinfo in Vdata.VideoList)
  1733. {
  1734. try
  1735. {
  1736. if (string.IsNullOrWhiteSpace(videoinfo.VideoPath))
  1737. {
  1738. continue;
  1739. }
  1740. if (string.IsNullOrWhiteSpace(videoinfo.VideoSize) || videoinfo.VideoSize == "0 MB")
  1741. {
  1742. videoinfo.VideoSize = FileToolsCommon.GetFileSizeByMB(videoinfo.VideoPath).ToString() + " MB";
  1743. videoinfo.VideoSizebyte = FileToolsCommon.GetFileSize(videoinfo.VideoPath);
  1744. }
  1745. model_VideoList.Add(videoinfo);
  1746. }
  1747. catch (Exception ex)
  1748. {
  1749. LogHelper.WriteErrLog("【加载视频列表】(LoadingVideoList)" + ex.Message, ex);
  1750. }
  1751. }
  1752. #endregion
  1753. }
  1754. //翻转
  1755. if(model_VideoList.Count>1)
  1756. {
  1757. model_VideoList.Reverse();
  1758. }
  1759. }
  1760. catch (Exception ex)
  1761. {
  1762. LogHelper.WriteErrLog("【加载视频列表】(LoadingVideoList)" + ex.Message, ex);
  1763. }
  1764. }
  1765. ////定义事件
  1766. //public event ChangeTextHandler ChangeTextEvents;
  1767. /// <summary>
  1768. /// 上传
  1769. /// </summary>
  1770. /// <param name="sender"></param>
  1771. /// <param name="e"></param>
  1772. private void BtnUploads_Click(object sender, RoutedEventArgs e)
  1773. {
  1774. if (APP.IsLoginType == false)
  1775. {
  1776. Login();
  1777. return;
  1778. }
  1779. pageData.menuList[Subscript].IsEnabled = false;
  1780. List<System.Windows.Controls.Button> buttons = FindChilds<System.Windows.Controls.Button>(listView1, "btnUpload");
  1781. for (int i = 0; i < buttons.Count; i++)
  1782. {
  1783. if (buttons[i] == sender)
  1784. {
  1785. DAL_Upload dAL_Upload = new DAL_Upload();
  1786. if (dAL_Upload.UploadVideo(pageData.menuList[i].FileGuid, out string ErrMessage))
  1787. {
  1788. //MessageWindow.Show("视频上传服务器成功!");
  1789. if (APP.W_UploadWindow == null)
  1790. {
  1791. APP.W_UploadWindow = new UploadWindow
  1792. {
  1793. Owner = this
  1794. };
  1795. APP.W_UploadWindow.ChangeTextEvents += new ChangeTextHandlers(frm_ChangeTextEvents);
  1796. }
  1797. //long size = Convert.ToInt64(FileToolsCommon.GetFileSizeByMB(pageData.menuList[i].FilePath));
  1798. APP.W_UploadWindow.Initialize(pageData.menuList[i].VideoName, pageData.menuList[i].VideoSizes, pageData.menuList[i].VideoType, pageData.menuList[i].FileGuid,i);
  1799. APP.W_UploadWindow.ShowDialog();
  1800. }
  1801. else
  1802. {
  1803. MessageWindow.Show(ErrMessage);
  1804. }
  1805. }
  1806. }
  1807. }
  1808. /// <summary>
  1809. /// 上传返回事件
  1810. /// </summary>
  1811. /// <param name="text"></param>
  1812. private void frm_ChangeTextEvents(string text,int i)
  1813. {
  1814. if ("上传成功".Equals(text))
  1815. {
  1816. pageData.menuList[i].Visi = "Visible";
  1817. pageData.menuList[i].Coll = "Collapsed";
  1818. DataContext = pageData;
  1819. }
  1820. }
  1821. /// <summary>
  1822. /// 删除
  1823. /// </summary>
  1824. /// <param name="sender"></param>
  1825. /// <param name="e"></param>
  1826. private void BtnDelete_Click(object sender, RoutedEventArgs e)
  1827. {
  1828. MessageBoxResult dr = MessageWindow.Show("确定删除该视频?", "提示", MessageBoxButton.OKCancel);
  1829. if (dr == MessageBoxResult.OK)
  1830. {
  1831. pageData.menuList[Subscript].IsEnabled = false;
  1832. List<System.Windows.Controls.Button> buttons = FindChilds<System.Windows.Controls.Button>(listView1, "btnDelete");
  1833. for (int i = 0; i < buttons.Count; i++)
  1834. {
  1835. if (buttons[i] == sender)
  1836. {
  1837. //if (APP.W_PromptWindow == null)
  1838. //{
  1839. // APP.W_PromptWindow = new PromptWindow();
  1840. // APP.W_PromptWindow.Owner = this;
  1841. //}
  1842. //APP.W_PromptWindow.Initialize(pageData.menuList[i].VideoName);
  1843. //APP.W_PromptWindow.ShowDialog();
  1844. foreach (Model_WKData wKData in APP.WKDataList)
  1845. {
  1846. if (wKData.VideoList == null)
  1847. {
  1848. continue;
  1849. }
  1850. if (wKData.VideoList.Exists(x => x.FileGuid == pageData.menuList[i].FileGuid))
  1851. {
  1852. try
  1853. {
  1854. FileToolsCommon.DeleteFile(wKData.VideoList.Find(x => x.FileGuid == pageData.menuList[i].FileGuid).VideoPath);
  1855. FileToolsCommon.DeleteFile(wKData.VideoList.Find(x => x.FileGuid == pageData.menuList[i].FileGuid).ThumbnailPath);
  1856. wKData.VideoList.Remove(wKData.VideoList.Find(x => x.FileGuid == pageData.menuList[i].FileGuid));
  1857. InitializeUpload();
  1858. return;
  1859. }
  1860. catch (Exception ex)
  1861. {
  1862. MessageWindow.Show("无法删除视频!" + ex.Message);
  1863. return;
  1864. }
  1865. }
  1866. }
  1867. }
  1868. }
  1869. }
  1870. }
  1871. /// <summary>
  1872. /// 播放
  1873. /// </summary>
  1874. /// <param name="sender"></param>
  1875. /// <param name="e"></param>
  1876. private void BtnPlay_Click(object sender, RoutedEventArgs e)
  1877. {
  1878. pageData.menuList[Subscript].IsEnabled = false;
  1879. List<System.Windows.Controls.Button> buttons = FindChilds<System.Windows.Controls.Button>(listView1, "btnPlay");
  1880. for (int i = 0; i < buttons.Count; i++)
  1881. {
  1882. if (buttons[i] == sender)
  1883. {
  1884. try
  1885. {
  1886. ProcessStartInfo psi = new ProcessStartInfo(pageData.menuList[i].Path);
  1887. Process pro = new Process
  1888. {
  1889. StartInfo = psi
  1890. };
  1891. pro.Start();
  1892. }
  1893. catch (Exception ex)
  1894. {
  1895. LogHelper.WriteErrLog("FileDirectoryWindow【BtnPlay_Click】" + ex.Message, ex);
  1896. System.Windows.MessageBox.Show(ex.Message);
  1897. return;
  1898. }
  1899. }
  1900. }
  1901. }
  1902. /// <summary>
  1903. /// 搜索集合匹配的索引
  1904. /// </summary>
  1905. /// <typeparam name="T"></typeparam>
  1906. /// <param name="parent"></param>
  1907. /// <param name="childName"></param>
  1908. /// <returns></returns>
  1909. public static List<T> FindChilds<T>(DependencyObject parent, string childName)
  1910. where T : DependencyObject
  1911. {
  1912. List<T> list = new List<T>();
  1913. if (parent == null)
  1914. {
  1915. return list;
  1916. }
  1917. int childrenCount = VisualTreeHelper.GetChildrenCount(parent);
  1918. for (int i = 0; i < childrenCount; i++)
  1919. {
  1920. DependencyObject child = VisualTreeHelper.GetChild(parent, i);
  1921. // 如果子控件不是需查找的控件类型
  1922. T childType = child as T;
  1923. if (childType == null)
  1924. {
  1925. // 在下一级控件中递归查找
  1926. List<T> findChildList = FindChilds<T>(child, childName);
  1927. for (int j = 0; j < findChildList.Count; j++)
  1928. {
  1929. }
  1930. list.AddRange(FindChilds<T>(child, childName));
  1931. }
  1932. else if (!string.IsNullOrEmpty(childName))
  1933. {
  1934. FrameworkElement frameworkElement = child as FrameworkElement;
  1935. // 如果控件名称符合参数条件
  1936. if (frameworkElement != null && frameworkElement.Name == childName)
  1937. {
  1938. list.Add((T)child);
  1939. }
  1940. }
  1941. else
  1942. {
  1943. // 查找到了控件
  1944. list.Add((T)child);
  1945. }
  1946. }
  1947. return list;
  1948. }
  1949. /// <summary>
  1950. /// 修改
  1951. /// </summary>
  1952. /// <param name="sender"></param>
  1953. /// <param name="e"></param>
  1954. private void BtnModify_Click(object sender, RoutedEventArgs e)
  1955. {
  1956. if (IsModify)
  1957. {
  1958. try
  1959. {
  1960. string newName = pageData.menuList[Subscript].VideoName +"."+ pageData.menuList[Subscript].VideoType;
  1961. bool isName = ModifyPathName(pageData.menuList[Subscript].FileGuid, newName, out string Errmessage);
  1962. if (!isName)
  1963. {
  1964. MessageWindow.Show(Errmessage);
  1965. }
  1966. }
  1967. catch (Exception ex)
  1968. {
  1969. LogHelper.WriteErrLog("XHMicroLessonSystemWindow(BtnModify_Click)" + ex.Message, ex);
  1970. }
  1971. IsModify = false;
  1972. pageData.menuList[Subscript].IsEnabled = false;
  1973. listView1.DataContext = pageData;
  1974. }
  1975. else
  1976. {
  1977. List<System.Windows.Controls.Button> buttons = FindChilds<System.Windows.Controls.Button>(listView1, "btnModify");
  1978. for (int i = 0; i < buttons.Count; i++)
  1979. {
  1980. if (buttons[i] == sender)
  1981. {
  1982. pageData.menuList[i].IsEnabled = true;
  1983. Subscript = i;
  1984. IsModify = true;
  1985. }
  1986. }
  1987. }
  1988. }
  1989. private int MouseNumber = 0;
  1990. /// <summary>
  1991. /// 上传 上页
  1992. /// </summary>
  1993. /// <param name="sender"></param>
  1994. /// <param name="e"></param>
  1995. private void BtnLastPage_Click(object sender, RoutedEventArgs e)
  1996. {
  1997. if (Currpage > 1)
  1998. {
  1999. Currpage -= 1;
  2000. txbCurrpageTwo.Text = Currpage.ToString();
  2001. int i = 1;
  2002. bool isColour = true;
  2003. pageData.menuList.Clear();
  2004. //显示视频
  2005. foreach (Model_Video videoinfo in model_VideoList)
  2006. {
  2007. //是否已上传
  2008. //videoinfo.IsUpload;
  2009. //录制时间
  2010. //videoinfo.RSTime;
  2011. //文件大小
  2012. //videoinfo.VideoSize;
  2013. //文件缩略图路径
  2014. //videoinfo.ThumbnailPath;
  2015. //文件唯一标示 上传事件筛选需要上传的视频
  2016. //videoinfo.FileGuid;
  2017. //文件存储路径
  2018. //videoinfo.VidePath;
  2019. string colour = "#FFFFFF";
  2020. if (isColour == true)
  2021. {
  2022. colour = "#FFFFFF";
  2023. isColour = false;
  2024. }
  2025. else
  2026. {
  2027. colour = "#E6F1FF";
  2028. isColour = true;
  2029. }
  2030. string vis = "Visible";
  2031. string cos = "Collapsed";
  2032. if (!videoinfo.IsUpload)
  2033. {
  2034. vis = "Collapsed";
  2035. cos = "Visible";
  2036. }
  2037. if (i <= Currpage * 16 && i >= (Currpage - 1) * 16)
  2038. {
  2039. pageData.menuList.Add(new FileDirectoryModel()
  2040. {
  2041. SerialNumber = i,
  2042. VideoName = Common.system.FileToolsCommon.GetIOFileName(videoinfo.VideoPath).Replace(".MP4", "").Replace(".FLV", "").Replace(".AVI", "").Trim(),
  2043. Name = Common.system.FileToolsCommon.GetIOFileName(videoinfo.VideoPath).Replace(".MP4", "").Replace(".FLV", "").Replace(".AVI", "").Trim(),
  2044. FilePath = videoinfo.VideoPath.Replace(FileToolsCommon.GetIOFileName(videoinfo.VideoPath), "").Trim(),
  2045. VideoDuration = 0,
  2046. VideoSize = videoinfo.VideoSize,
  2047. VideoTime = videoinfo.RSTime,
  2048. IsEnabled = false,
  2049. Path = videoinfo.VideoPath,
  2050. Colour = colour,
  2051. Visi = vis,
  2052. Coll = cos,
  2053. FileGuid = videoinfo.FileGuid,
  2054. VideoType = videoinfo.VideoType.ToString()
  2055. }); ;
  2056. }
  2057. i++;
  2058. }
  2059. APP.myloading.Hide();
  2060. }
  2061. }
  2062. /// <summary>
  2063. /// 上传 下页
  2064. /// </summary>
  2065. /// <param name="sender"></param>
  2066. /// <param name="e"></param>
  2067. private void BtnNextPage_Click(object sender, RoutedEventArgs e)
  2068. {
  2069. if (Currpage < PageNum)
  2070. {
  2071. Currpage += 1;
  2072. txbCurrpageTwo.Text = Currpage.ToString();
  2073. int i = 1;
  2074. bool isColour = true;
  2075. pageData.menuList.Clear();
  2076. //显示视频
  2077. foreach (Model_Video videoinfo in model_VideoList)
  2078. {
  2079. //是否已上传
  2080. //videoinfo.IsUpload;
  2081. //录制时间
  2082. //videoinfo.RSTime;
  2083. //文件大小
  2084. //videoinfo.VideoSize;
  2085. //文件缩略图路径
  2086. //videoinfo.ThumbnailPath;
  2087. //文件唯一标示 上传事件筛选需要上传的视频
  2088. //videoinfo.FileGuid;
  2089. //文件存储路径
  2090. //videoinfo.VidePath;
  2091. string colour = "#FFFFFF";
  2092. if (isColour == true)
  2093. {
  2094. colour = "#FFFFFF";
  2095. isColour = false;
  2096. }
  2097. else
  2098. {
  2099. colour = "#E6F1FF";
  2100. isColour = true;
  2101. }
  2102. string vis = "Visible";
  2103. string cos = "Collapsed";
  2104. if (!videoinfo.IsUpload)
  2105. {
  2106. vis = "Collapsed";
  2107. cos = "Visible";
  2108. }
  2109. if (i <= Currpage * 16 && i > (Currpage - 1) * 16)
  2110. {
  2111. pageData.menuList.Add(new FileDirectoryModel()
  2112. {
  2113. SerialNumber = i,
  2114. VideoName = Common.system.FileToolsCommon.GetIOFileName(videoinfo.VideoPath).Replace(".MP4", "").Replace(".FLV", "").Replace(".AVI", "").Trim(),
  2115. Name = Common.system.FileToolsCommon.GetIOFileName(videoinfo.VideoPath).Replace(".MP4", "").Replace(".FLV", "").Replace(".AVI", "").Trim(),
  2116. FilePath = videoinfo.VideoPath.Replace(FileToolsCommon.GetIOFileName(videoinfo.VideoPath), "").Trim(),
  2117. VideoDuration = 0,
  2118. VideoSize = videoinfo.VideoSize,
  2119. VideoTime = videoinfo.RSTime,
  2120. IsEnabled = false,
  2121. Path = videoinfo.VideoPath,
  2122. Colour = colour,
  2123. Visi = vis,
  2124. Coll = cos,
  2125. FileGuid = videoinfo.FileGuid,
  2126. VideoType = videoinfo.VideoType.ToString()
  2127. }); ;
  2128. }
  2129. i++;
  2130. }
  2131. APP.myloading.Hide();
  2132. }
  2133. }
  2134. /// <summary>
  2135. /// 修改文件名
  2136. /// </summary>
  2137. /// <param name="Guid">唯一编号</param>
  2138. /// <param name="NewName">新文件名带后缀 不带路径</param>
  2139. /// <param name="Errmessage">错误信息</param>
  2140. /// <returns></returns>
  2141. private bool ModifyPathName(string FileGuid, string NewName, out string Errmessage)
  2142. {
  2143. Errmessage = "";
  2144. foreach(Model_WKData WKData in APP.WKDataList)
  2145. {
  2146. if (WKData.VideoList.Exists(x => x.FileGuid == FileGuid))
  2147. {
  2148. Model_Video model_Video = WKData.VideoList.Find(x => x.FileGuid == FileGuid);
  2149. string filePathName = model_Video.VideoPath;
  2150. string filePath = FileToolsCommon.GetDirectoryName(filePathName);
  2151. string newFilePathName = filePath + NewName;
  2152. //缩略图
  2153. string ThumbnailPath = filePath + "ThumbnailPath/";
  2154. FileToolsCommon.CreateDirectory(ThumbnailPath);
  2155. //缩略图存储位置
  2156. string ThumbnailPathName = ThumbnailPath + NewName.Replace(".", "") + ".JPG";
  2157. if (FileToolsCommon.IsExistFile(newFilePathName))
  2158. {
  2159. Errmessage = "文件已存在,请重新修改文件名!";
  2160. return false;
  2161. }
  2162. else
  2163. {
  2164. //修改文件名
  2165. FileToolsCommon.Copy(filePathName, newFilePathName);
  2166. model_Video.VideoPath = newFilePathName;
  2167. //修改缩略图名
  2168. FileToolsCommon.DeleteFile(ThumbnailPathName);
  2169. FileToolsCommon.Copy(model_Video.ThumbnailPath, ThumbnailPathName);
  2170. model_Video.ThumbnailPath = ThumbnailPathName;
  2171. APP.SaveWkData();
  2172. return true;
  2173. }
  2174. }
  2175. else
  2176. {
  2177. continue;
  2178. }
  2179. }
  2180. Errmessage = "视频文件有改动,当前文件不存在,请关闭后重新打开“我的”";
  2181. return false;
  2182. }
  2183. #endregion
  2184. #region 新上传 显示缩略图
  2185. #region 初始值
  2186. /// <summary>
  2187. /// 总页数
  2188. /// </summary>
  2189. int TotalPage=0;
  2190. /// <summary>
  2191. /// 当前页
  2192. /// </summary>
  2193. int CurrentPage = 1;
  2194. /// <summary>
  2195. /// 每页显示的视频数
  2196. /// </summary>
  2197. int PageShowNum = 0;
  2198. /// <summary>
  2199. /// 视频信息列表
  2200. /// </summary>
  2201. List<Uc_VideoItem> VideoControlList = new List<Uc_VideoItem>();
  2202. /// <summary>
  2203. /// 横向间隔
  2204. /// </summary>
  2205. double IntervalX = 0;
  2206. /// <summary>
  2207. /// 纵向间隔
  2208. /// </summary>
  2209. double IntervalY = 0;
  2210. #endregion
  2211. /// <summary>
  2212. /// 初始化加载上传页面数据
  2213. /// </summary>
  2214. void LoadUploadInitData()
  2215. {
  2216. APP.myloading.Show();
  2217. //加载视频列表
  2218. LoadingVideoList();
  2219. if (model_VideoList.Count > 0)
  2220. {
  2221. lblVideoMess.Visibility = Visibility.Hidden;
  2222. BtnVideoUpPage.Visibility = Visibility.Visible;
  2223. lblVideoPageNum.Visibility = Visibility.Visible;
  2224. BtnVideoDownPage.Visibility = Visibility.Visible;
  2225. //根据页面大小获取每页显示的数量 H300W250
  2226. int videoRow = (int)((GridMyVideo.ActualHeight - 50) / 300);
  2227. int videColumn = (int)(GridMyVideo.ActualWidth / 250);
  2228. PageShowNum = videoRow * videColumn;
  2229. //获取总页数
  2230. TotalPage = model_VideoList.Count / PageShowNum + (model_VideoList.Count % PageShowNum > 0 ? 1 : 0);
  2231. //如果当前页大于总页数 总页数为当前页
  2232. if (TotalPage < CurrentPage)
  2233. {
  2234. CurrentPage = TotalPage;
  2235. }
  2236. //横向间隔
  2237. IntervalX = (GridMyVideo.ActualWidth - (videColumn * 250)) / (videColumn + 1);
  2238. IntervalY = (GridMyVideo.ActualHeight - 50 - (videoRow * 300)) / (videoRow + 1);
  2239. LoadCurrentPageData();
  2240. }
  2241. else
  2242. {
  2243. lblVideoMess.Visibility = Visibility.Visible;
  2244. BtnVideoUpPage.Visibility = Visibility.Hidden;
  2245. lblVideoPageNum.Visibility = Visibility.Hidden;
  2246. BtnVideoDownPage.Visibility = Visibility.Hidden;
  2247. }
  2248. APP.myloading.Hide();
  2249. }
  2250. /// <summary>
  2251. /// 加载当前页数据
  2252. /// </summary>
  2253. private void LoadCurrentPageData()
  2254. {
  2255. lblVideoPageNum.Content = CurrentPage + "/" + TotalPage;
  2256. //隐藏显示的控件
  2257. if(VideoControlList.Count>0)
  2258. {
  2259. foreach(Uc_VideoItem item in VideoControlList)
  2260. {
  2261. if (item.Visibility != Visibility.Hidden)
  2262. {
  2263. item.Visibility = Visibility.Hidden;
  2264. }
  2265. }
  2266. }
  2267. double W = IntervalX;//每次增加250
  2268. double H = IntervalY;//每次增加300
  2269. //加载控件
  2270. for(int i=0;i< PageShowNum;i++)
  2271. {
  2272. int DataIndex = (CurrentPage - 1) * PageShowNum + i;
  2273. if(DataIndex== model_VideoList.Count)
  2274. {
  2275. return;
  2276. }
  2277. Uc_VideoItem videoItem;
  2278. if (VideoControlList.Exists(x => x.Tag.ToString() == model_VideoList[DataIndex].FileGuid))
  2279. {
  2280. videoItem = VideoControlList.Find(x => x.Tag.ToString() == model_VideoList[DataIndex].FileGuid);
  2281. }
  2282. else
  2283. {
  2284. videoItem = new Uc_VideoItem(model_VideoList[DataIndex]);
  2285. videoItem.Tag = model_VideoList[DataIndex].FileGuid;
  2286. videoItem.Click_refreshVideoList += LoadUploadInitData;
  2287. videoItem.Click_UploadLogin += Login;
  2288. videoItem.Width = 250;
  2289. videoItem.Height = 300;
  2290. videoItem.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
  2291. videoItem.VerticalAlignment = System.Windows.VerticalAlignment.Top;
  2292. GridMyVideo.Children.Add(videoItem);
  2293. VideoControlList.Add(videoItem);
  2294. }
  2295. videoItem.Margin = new Thickness(W, H, 0, 0);
  2296. videoItem.Visibility = Visibility.Visible;
  2297. if (W + 250+250>GridMyVideo.ActualWidth)
  2298. {
  2299. W = IntervalX;
  2300. H += 300+ IntervalY;
  2301. }
  2302. else
  2303. {
  2304. W += 250+ IntervalX;
  2305. }
  2306. //Uc_VideoItem videoItem = new Uc_VideoItem();
  2307. //return;
  2308. }
  2309. }
  2310. #region 分页
  2311. /// <summary>
  2312. /// 上一页
  2313. /// </summary>
  2314. /// <param name="sender"></param>
  2315. /// <param name="e"></param>
  2316. private void BtnVideoUpPage_Click(object sender, RoutedEventArgs e)
  2317. {
  2318. if(CurrentPage>1)
  2319. {
  2320. CurrentPage--;
  2321. LoadCurrentPageData();
  2322. }
  2323. }
  2324. /// <summary>
  2325. /// 下一页
  2326. /// </summary>
  2327. /// <param name="sender"></param>
  2328. /// <param name="e"></param>
  2329. private void BtnVideoDownPage_Click(object sender, RoutedEventArgs e)
  2330. {
  2331. if (CurrentPage < TotalPage)
  2332. {
  2333. CurrentPage++;
  2334. LoadCurrentPageData();
  2335. }
  2336. }
  2337. #endregion
  2338. #endregion
  2339. #region 录制窗口
  2340. #region 变量
  2341. /// <summary>
  2342. /// 视频保存路径
  2343. /// </summary>
  2344. //string RecordingPath;
  2345. /// <summary>
  2346. /// 图片保存路径
  2347. /// </summary>
  2348. private string ImgPath;
  2349. /// <summary>
  2350. /// 音频保存路径名
  2351. /// </summary>
  2352. private string AudioPathName;
  2353. /// <summary>
  2354. /// 视频保存路径名
  2355. /// </summary>
  2356. private string VideoSavePathName;
  2357. /// <summary>
  2358. /// 视频合成路径名
  2359. /// </summary>
  2360. private string VideoSynthesisPathName;
  2361. /// <summary>
  2362. /// 暂停录制
  2363. /// </summary>
  2364. private bool IsSuspendR = true;
  2365. /// <summary>
  2366. /// 录制是否已停止
  2367. /// </summary>
  2368. private bool IsFirstR = true;
  2369. /// <summary>
  2370. /// 图片
  2371. /// </summary>
  2372. private List<string> RsImgName = null;
  2373. /// <summary>
  2374. /// 是否开始截图计数
  2375. /// </summary>
  2376. private bool IsStartCount = false;
  2377. /// <summary>
  2378. /// 是否录制了音频
  2379. /// </summary>
  2380. private bool IsRecordAudio = false;
  2381. /// <summary>
  2382. /// 截图定时器
  2383. /// </summary>
  2384. private System.Threading.Timer timer;
  2385. /// <summary>
  2386. /// 录制计时
  2387. /// </summary>
  2388. private DateTime SRTime = DateTime.Now;
  2389. #endregion
  2390. #region 录屏
  2391. /// <summary>
  2392. /// 录屏事件
  2393. /// </summary>
  2394. /// <param name="sender"></param>
  2395. /// <param name="e"></param>
  2396. private void BtnScreenRecording_Click(object sender, RoutedEventArgs e)
  2397. {
  2398. Record();
  2399. if (!APP.CheckScreenCapturerRecorder())
  2400. {
  2401. MessageWindow.Show("使用此功能需安装环境,请在确定后依次点击“OK-Next>-Next>Install”完成安装!");
  2402. APP.InstallScreenCapturerRecorder();
  2403. return;
  2404. }
  2405. #region 限制只允许录制一个录屏 废弃
  2406. //string RecordScreenPathName = APP.WKData.WkPath + APP.WKData.WkName + "_录屏." + ((Enum_VideoType)int.Parse(FileToolsCommon.GetConfigValue("VideoType"))).ToString();
  2407. //if (FileToolsCommon.IsExistFile(RecordScreenPathName))
  2408. //{
  2409. // MessageBoxResult dr = MessageWindow.Show("已存在录屏,是否覆盖?", "提示", MessageBoxButton.OKCancel);
  2410. // if (dr == MessageBoxResult.OK)
  2411. // {
  2412. // try
  2413. // {
  2414. // FileToolsCommon.DeleteFile(RecordScreenPathName);
  2415. // APP.VideoList.RemoveAll(x => x.VideoPath == RecordScreenPathName);
  2416. // }
  2417. // catch (Exception ex)
  2418. // {
  2419. // LogHelper.WriteErrLog("【录屏】(BtnRecordingScreen_Click)无法移除视频," + ex.Message, ex);
  2420. // }
  2421. // }
  2422. // else
  2423. // {
  2424. // return;
  2425. // }
  2426. //}
  2427. #endregion
  2428. if (APP.W_ScreenRecordingToolbarWindow == null)
  2429. {
  2430. APP.W_ScreenRecordingToolbarWindow = new ScreenRecordingToolbarWindow
  2431. {
  2432. Topmost = true
  2433. };
  2434. APP.W_ScreenRecordingToolbarWindow.Initialize();
  2435. }
  2436. else
  2437. {
  2438. APP.W_ScreenRecordingToolbarWindow.Initialize();
  2439. }
  2440. APP.W_ScreenRecordingToolbarWindow.Click_stopRecordingScreen += W_ScreenRecordingToolbarWindow_Click_stopRecordingScreen;
  2441. //显示在右下角
  2442. APP.W_ScreenRecordingToolbarWindow.WindowStartupLocation = WindowStartupLocation.Manual;
  2443. Graphics graphics = Graphics.FromHwnd(IntPtr.Zero);
  2444. float DIP = graphics.DpiX;
  2445. float DIPY = graphics.DpiY;
  2446. APP.W_ScreenRecordingToolbarWindow.Left = PrimaryScreen.WorkingArea.Width / (DIP / 96) - APP.W_ScreenRecordingToolbarWindow.Width - 60;
  2447. APP.W_ScreenRecordingToolbarWindow.Top = PrimaryScreen.WorkingArea.Height / (DIP / 96) - APP.W_ScreenRecordingToolbarWindow.Height - 30;
  2448. APP.W_ScreenRecordingToolbarWindow.Topmost = true;
  2449. APP.W_ScreenRecordingToolbarWindow.Show();
  2450. Hide();
  2451. }
  2452. /// <summary>
  2453. /// 保存录屏中
  2454. /// </summary>
  2455. private void W_ScreenRecordingToolbarWindow_Click_stopRecordingScreen()
  2456. {
  2457. txbType.Visibility = Visibility.Visible;
  2458. txbType.Text = "保存中";
  2459. btnScreenRecording.IsEnabled = false;
  2460. new Thread(new ThreadStart(new Action(() =>
  2461. {
  2462. while (FileToolsCommon.IsExistDirectory(APP.WKData.WkPath + "temprs/"))
  2463. {
  2464. Thread.Sleep(100);
  2465. }
  2466. Thread.Sleep(100);
  2467. Dispatcher.Invoke(() =>
  2468. {
  2469. btnScreenRecording.IsEnabled = true;
  2470. txbType.Visibility = Visibility.Hidden;
  2471. //TxbRecordScreenWord.Text = "录屏";
  2472. });
  2473. }))).Start();
  2474. }
  2475. #endregion
  2476. /// <summary>
  2477. /// 录制窗口内容
  2478. /// </summary>
  2479. /// <param name="sender"></param>
  2480. /// <param name="e"></param>
  2481. private void BtnRecord_Click(object sender, RoutedEventArgs e)
  2482. {
  2483. Record();
  2484. if (!APP.CheckScreenCapturerRecorder())
  2485. {
  2486. MessageWindow.Show("使用此功能需安装环境,请在确定后依次点击“OK-Next>-Next>Install”完成安装!");
  2487. APP.InstallScreenCapturerRecorder();
  2488. return;
  2489. }
  2490. if (APP.pageData.currpage > 0)
  2491. {
  2492. blackboard_canvas.Visibility = Visibility.Visible;
  2493. }
  2494. else
  2495. {
  2496. MessageWindow.Show("请先导入文档或截图!");
  2497. return;
  2498. }
  2499. if (RectImgBorder.Visibility != Visibility.Hidden)
  2500. {
  2501. HideAngleBorder();
  2502. }
  2503. //btnStop.IsEnabled = true;//停止录制按钮可点击
  2504. StartRecord();
  2505. }
  2506. /// <summary>
  2507. /// 停止录制窗口内容
  2508. /// </summary>
  2509. /// <param name="sender"></param>
  2510. /// <param name="e"></param>
  2511. private void BtnStop_Click(object sender, RoutedEventArgs e)
  2512. {
  2513. blackboard_canvas.Visibility = Visibility.Collapsed;
  2514. EndRecord();
  2515. }
  2516. /// <summary>
  2517. /// 设置录屏文件地址
  2518. /// </summary>
  2519. private void SetUpVideoPathName()
  2520. {
  2521. }
  2522. /// <summary>
  2523. /// 开始录制和暂停录制
  2524. /// </summary>
  2525. private void StartRecord()
  2526. {
  2527. if (IsSuspendR)
  2528. {
  2529. if (IsFirstR)//是否第一次录制 初始化录制
  2530. {
  2531. #region 检测麦克风扬声器是否可用
  2532. string audioSpeakerPath = FileToolsCommon.GetFileAbsolutePath("adoS.m");
  2533. string audioMicrophonePath = FileToolsCommon.GetFileAbsolutePath("adoM.m");
  2534. try
  2535. {
  2536. FileToolsCommon.DeleteFile(audioSpeakerPath);
  2537. FileToolsCommon.DeleteFile(audioMicrophonePath);
  2538. }
  2539. catch (Exception)
  2540. {
  2541. }
  2542. //扬声器
  2543. if (APP.FFmpeg.StartRecordSpeakerAudio(audioSpeakerPath))
  2544. {
  2545. APP.FFmpeg.StopRecordAudio(2);
  2546. //Thread.Sleep(500);
  2547. //麦克风
  2548. if (APP.FFmpeg.StartRecordAudio(audioMicrophonePath))
  2549. {
  2550. }
  2551. else
  2552. {
  2553. //无法录制麦克风
  2554. MessageBoxResult Res = MessageWindow.Show("当前电脑无法录制麦克风,是否继续?", "消息提示", MessageBoxButton.OKCancel);
  2555. if (Res == MessageBoxResult.Cancel)
  2556. {
  2557. return;
  2558. }
  2559. }
  2560. APP.FFmpeg.StopRecordAudio(1);
  2561. }
  2562. else
  2563. {
  2564. //无法录制扬声器音频
  2565. MessageBoxResult Res = MessageWindow.Show("当前电脑无法录制音频,是否继续?", "消息提示", MessageBoxButton.OKCancel);
  2566. if (Res == MessageBoxResult.Cancel)
  2567. {
  2568. return;
  2569. }
  2570. }
  2571. #endregion
  2572. #region 计时器初始化
  2573. //if (t == null)
  2574. //{
  2575. // t = new DispatcherTimer();
  2576. // t.Tick += OnTimer;
  2577. // t.Interval = new TimeSpan(0, 0, 0, 1);
  2578. // t.IsEnabled = true;
  2579. // t.Start();
  2580. //}
  2581. //t.Interval = new TimeSpan(0, 0, 0, 1);
  2582. txbTime.Visibility = Visibility.Visible;
  2583. #endregion
  2584. VideoInfo = new Model_Video
  2585. {
  2586. VideoType = (Enum_VideoType)int.Parse(FileToolsCommon.GetConfigValue("VideoType")),
  2587. WkType = Enum_WKVidetype.RecordingLessons
  2588. };
  2589. ImgPath = APP.WKData.WkPath + "temp/Image/";
  2590. AudioPathName = APP.WKData.WkPath + "temp/audio/";
  2591. FileToolsCommon.DeleteDirectory(APP.WKData.WkPath + "temp/");
  2592. FileToolsCommon.CreateDirectory(APP.WKData.WkPath);
  2593. FileToolsCommon.CreateDirectory(ImgPath);
  2594. FileToolsCommon.CreateDirectory(AudioPathName);
  2595. AudioPathName += APP.WKData.WkName + ".MP3";
  2596. VideoSavePathName = APP.WKData.WkPath + APP.WKData.WkName + "_录制." + VideoInfo.VideoType.ToString();
  2597. VideoSynthesisPathName = APP.WKData.WkPath + APP.WKData.WkName + "_录制Syn." + VideoInfo.VideoType.ToString();
  2598. int num = 1;
  2599. while (FileToolsCommon.IsExistFile(VideoSavePathName))
  2600. {
  2601. VideoSavePathName = APP.WKData.WkPath + APP.WKData.WkName + "_录制_" + num + "." + VideoInfo.VideoType.ToString();
  2602. VideoSynthesisPathName = APP.WKData.WkPath + APP.WKData.WkName + "_录制Syn_" + num + "." + VideoInfo.VideoType.ToString();
  2603. num++;
  2604. }
  2605. #region 设置录屏唯一 废弃
  2606. //if (FileToolsCommon.IsExistFile(VideoSavePathName))
  2607. //{
  2608. // MessageBoxResult dr = MessageWindow.Show("课程已录制,是否覆盖?", "提示", MessageBoxButton.OKCancel);
  2609. // if (dr == MessageBoxResult.OK)
  2610. // {
  2611. // try
  2612. // {
  2613. // FileToolsCommon.DeleteFile(VideoSavePathName);
  2614. // APP.VideoList.RemoveAll(x => x.VideoPath == VideoSavePathName);
  2615. // }
  2616. // catch (Exception ex)
  2617. // {
  2618. // LogHelper.WriteErrLog("【录制】(StartRecord)无法移除视频," + ex.Message, ex);
  2619. // }
  2620. // }
  2621. // else
  2622. // {
  2623. // return;
  2624. // }
  2625. //}
  2626. #endregion
  2627. #region 禁用按钮
  2628. ImgPrint.Visibility = Visibility.Collapsed;//录制中不可打印
  2629. ImgPrintTwo.Visibility = Visibility.Visible;
  2630. btnPrint.IsEnabled = false;
  2631. ImgScreenshot.Visibility = Visibility.Collapsed;//录制中不可截图
  2632. ImgScreenshotTwo.Visibility = Visibility.Visible;
  2633. btnScreenshot.IsEnabled = false;
  2634. ImgImport.Visibility = Visibility.Collapsed;//录制中不可导入文档
  2635. ImgImportTwo.Visibility = Visibility.Visible;
  2636. btnImport.IsEnabled = false;
  2637. ImgScreenRecording.Visibility = Visibility.Collapsed;//录制中不可录屏
  2638. ImgScreenRecordingTwo.Visibility = Visibility.Visible;
  2639. btnScreenRecording.IsEnabled = false;
  2640. ImgUpload.Visibility = Visibility.Collapsed;//录制中不可上传
  2641. ImgUploadTwo.Visibility = Visibility.Visible;
  2642. btnUpload.IsEnabled = false;
  2643. ImgSetUp.Visibility = Visibility.Collapsed;//录制中不可设置
  2644. ImgSetUpTwo.Visibility = Visibility.Visible;
  2645. btnSetUp.IsEnabled = false;
  2646. btnLoginType.IsEnabled = false;
  2647. blackboard_canvas.Visibility = Visibility.Visible;//zxyceshi
  2648. //myblackboard = new BlackboardNew(blackboard_canvas);
  2649. //DataContext = APP.pageData;
  2650. //drawingAttributes = new DrawingAttributes();
  2651. ////将 InkCanvas 的 DefaultDrawingAttributes 属性的值赋成创建的 DrawingAttributes 类的对象的引用
  2652. ////InkCanvas 通过 DefaultDrawingAttributes 属性来获取墨迹的各种设置,该属性的类型为 DrawingAttributes 型
  2653. //blackboard_canvas.DefaultDrawingAttributes = drawingAttributes;
  2654. //blackboard_canvas.UseCustomCursor = true;
  2655. //drawingAttributes.FitToCurve = true;
  2656. //drawingAttributes.IgnorePressure = false;
  2657. //drawingAttributes.Width = PenSize;
  2658. //drawingAttributes.Height = PenSize;
  2659. //drawingAttributes.Color = Color;
  2660. //blackboard_canvas.Cursor = System.Windows.Input.Cursors.Pen;
  2661. #endregion
  2662. #region 录像倒计时
  2663. if (APP.W_CountdownWindow == null)
  2664. {
  2665. APP.W_CountdownWindow = new CountdownWindow();
  2666. APP.W_CountdownWindow.Initialize();
  2667. //APP.W_CountdownWindow.Topmost = true;
  2668. }
  2669. else
  2670. {
  2671. APP.W_CountdownWindow.Initialize();
  2672. //APP.W_CountdownWindow.Topmost = true;
  2673. }
  2674. APP.W_CountdownWindow.Show();
  2675. #endregion
  2676. IsFirstR = false;
  2677. RsImgName = new List<string>();
  2678. SRTime = Convert.ToDateTime("2020-01-01 00:00:00");
  2679. txbTime.Visibility = Visibility.Visible;
  2680. ///启动截图
  2681. timer = new System.Threading.Timer(new TimerCallback(Timer_Elapsed), null, 0, 20);
  2682. //{
  2683. // AutoReset = true//设置是否执行System.Timers.Timer.Elapsed事件
  2684. //};//设置执行一次(false)还是一直执行(true)
  2685. //timer.Elapsed += new System.Timers.ElapsedEventHandler(Timer_Elapsed);
  2686. //timer.Enabled = true; //启动计时器
  2687. }
  2688. //继续录制
  2689. IsSuspendR = false;
  2690. //BtnRecording.Content = "暂停录制";
  2691. ImgRecord.Source = new BitmapImage(new Uri("pack://application:,,,/Images/microLessonSystem_23.png"));
  2692. TxbRecordingWord.Text = "暂停";
  2693. #region 4秒内不可点击
  2694. new Thread(new ThreadStart(new Action(() =>
  2695. {
  2696. Dispatcher.Invoke(() =>
  2697. {
  2698. BtnRecord.IsEnabled = false;
  2699. btnStop.IsEnabled = false;
  2700. ImgStop.Visibility = Visibility.Visible;
  2701. ImgStopTwo.Visibility = Visibility.Collapsed;
  2702. });
  2703. }))).Start();
  2704. new Thread(new ThreadStart(new Action(() =>
  2705. {
  2706. Thread.Sleep(4000);
  2707. Dispatcher.Invoke(() =>
  2708. {
  2709. BtnRecord.IsEnabled = true;
  2710. btnStop.IsEnabled = true;
  2711. ImgStop.Visibility = Visibility.Collapsed;
  2712. ImgStopTwo.Visibility = Visibility.Visible;
  2713. });
  2714. }))).Start();
  2715. #endregion
  2716. try
  2717. {
  2718. new Thread(new ThreadStart(new Action(() =>
  2719. {
  2720. Thread.Sleep(1000);
  2721. IsRecordAudio = APP.FFmpeg.StartRecordingAudio(AudioPathName);
  2722. Thread.Sleep(1000);
  2723. Dispatcher.Invoke(() =>
  2724. {
  2725. Recorddt = DateTime.Now;
  2726. IsStartCount = true;
  2727. //Stack();
  2728. //timer.Start();
  2729. });
  2730. }))).Start();
  2731. }
  2732. catch (Exception ex)
  2733. {
  2734. MessageWindow.Show(ex.Message);
  2735. }
  2736. }
  2737. else
  2738. {
  2739. //暂停
  2740. IsSuspendR = true;
  2741. ImgRecord.Source = new BitmapImage(new Uri("pack://application:,,,/Images/microLessonSystem_14.png"));
  2742. ImgStop.Visibility = Visibility.Collapsed;
  2743. ImgStopTwo.Visibility = Visibility.Visible;
  2744. TxbRecordingWord.Text = "继续";
  2745. //TimeOut();
  2746. #region 2秒内不可点击
  2747. new Thread(new ThreadStart(new Action(() =>
  2748. {
  2749. Dispatcher.Invoke(() =>
  2750. {
  2751. BtnRecord.IsEnabled = false;
  2752. btnStop.IsEnabled = false;
  2753. });
  2754. Thread.Sleep(2000);
  2755. Dispatcher.Invoke(() =>
  2756. {
  2757. BtnRecord.IsEnabled = true;
  2758. btnStop.IsEnabled = true;
  2759. });
  2760. }))).Start();
  2761. #endregion
  2762. try
  2763. {
  2764. APP.FFmpeg.SuspendFFmpeg();
  2765. new Thread(new ThreadStart(new Action(() =>
  2766. {
  2767. while (APP.FFmpeg.myProcess != null)
  2768. {
  2769. Thread.Sleep(100);
  2770. }
  2771. IsStartCount = false;
  2772. }))).Start();
  2773. }
  2774. catch (Exception ex)
  2775. {
  2776. MessageWindow.Show(ex.Message);
  2777. }
  2778. }
  2779. }
  2780. /// <summary>
  2781. /// 记录上次截图时间
  2782. /// </summary>
  2783. DateTime Recorddt = DateTime.Now;
  2784. /// <summary>
  2785. /// 录制保存图片计时器
  2786. /// </summary>
  2787. /// <param name="sender"></param>
  2788. private void Timer_Elapsed(object sender)
  2789. {
  2790. if (IsStartCount)
  2791. {
  2792. DateTime dt = DateTime.Now;
  2793. TimeSpan ts = dt.Subtract(Recorddt);//时间差
  2794. double tsmi = ts.TotalMilliseconds;
  2795. if (tsmi > 200.0)
  2796. {
  2797. Recorddt = Recorddt.AddMilliseconds(200);
  2798. Thread thread = new Thread(RecordSaveImage);
  2799. //开启线程
  2800. thread.Start();
  2801. }
  2802. }
  2803. }
  2804. /// <summary>
  2805. /// 录制保存图片
  2806. /// </summary>
  2807. void RecordSaveImage()
  2808. {
  2809. try
  2810. {
  2811. Dispatcher.Invoke(() =>
  2812. {
  2813. if (IsStartCount)
  2814. {
  2815. string FilePathName = ImgPath + RsImgName.Count + ".png";
  2816. RsImgName.Add(FilePathName);
  2817. ImageHelper.SaveUIToImage(GridMain, FilePathName, (int)(ActualWidth * (PrimaryScreen.DpiX / 96f)), (int)(ActualHeight * (PrimaryScreen.DpiY / 96f)));
  2818. SRTime = SRTime.AddMilliseconds(200);
  2819. if (txbTime.Visibility == Visibility.Hidden)
  2820. {
  2821. txbTime.Visibility = Visibility.Visible;
  2822. }
  2823. if (SRTime.Hour > 0)
  2824. {
  2825. //Dispatcher.Invoke(() =>
  2826. //{
  2827. txbTime.Text = SRTime.ToString("HH:mm:ss");
  2828. //});
  2829. }
  2830. else
  2831. {
  2832. //Dispatcher.Invoke(() =>
  2833. //{
  2834. txbTime.Text = SRTime.ToString("mm:ss");
  2835. //});
  2836. }
  2837. }
  2838. });
  2839. }
  2840. catch (Exception ex)
  2841. {
  2842. LogHelper.WriteErrLog("【录制】(Timer_Elapsed)生成图片错误:" + ex.Message, ex);
  2843. }
  2844. }
  2845. /// <summary>
  2846. /// 停止录制并生成录制文件
  2847. /// </summary>
  2848. private void EndRecord()
  2849. {
  2850. if (!IsFirstR)
  2851. {
  2852. #region 恢复被禁用的按钮
  2853. ImgPrint.Visibility = Visibility.Visible;
  2854. ImgPrintTwo.Visibility = Visibility.Collapsed;
  2855. btnPrint.IsEnabled = true;
  2856. ImgScreenshot.Visibility = Visibility.Visible;
  2857. ImgScreenshotTwo.Visibility = Visibility.Collapsed;
  2858. btnScreenshot.IsEnabled = true;
  2859. ImgImport.Visibility = Visibility.Visible;
  2860. ImgImportTwo.Visibility = Visibility.Collapsed;
  2861. btnImport.IsEnabled = true;
  2862. ImgScreenRecording.Visibility = Visibility.Visible;
  2863. ImgScreenRecordingTwo.Visibility = Visibility.Collapsed;
  2864. btnScreenRecording.IsEnabled = true;
  2865. ImgUpload.Visibility = Visibility.Visible;
  2866. ImgUploadTwo.Visibility = Visibility.Collapsed;
  2867. btnUpload.IsEnabled = true;
  2868. ImgSetUp.Visibility = Visibility.Visible;
  2869. ImgSetUpTwo.Visibility = Visibility.Collapsed;
  2870. btnSetUp.IsEnabled = true;
  2871. btnLoginType.IsEnabled = true;
  2872. //btnStop.IsEnabled = false;//停止录制按钮不可点击
  2873. #endregion
  2874. IsSuspendR = true;
  2875. ImgRecord.Source = new BitmapImage(new Uri("pack://application:,,,/Images/microLessonSystem_14.png"));
  2876. ImgStop.Visibility = Visibility.Visible;
  2877. ImgStopTwo.Visibility = Visibility.Collapsed;
  2878. //TimeOut();
  2879. txbType.Visibility = Visibility.Visible;
  2880. txbType.Text = "保存中";
  2881. #region 2秒内不可点击
  2882. new Thread(new ThreadStart(new Action(() =>
  2883. {
  2884. Dispatcher.Invoke(() =>
  2885. {
  2886. BtnRecord.IsEnabled = false;
  2887. btnStop.IsEnabled = false;
  2888. });
  2889. }))).Start();
  2890. #endregion
  2891. try
  2892. {
  2893. #region 清空画板数据
  2894. APP.pageData.currpage = 0;
  2895. APP.pageData.pagenum = 0;
  2896. myblackboard.clear();
  2897. //myblackboard = new BlackboardNew(blackboard_canvas);
  2898. //DataContext = APP.pageData;
  2899. //drawingAttributes = new DrawingAttributes();
  2900. ////将 InkCanvas 的 DefaultDrawingAttributes 属性的值赋成创建的 DrawingAttributes 类的对象的引用
  2901. ////InkCanvas 通过 DefaultDrawingAttributes 属性来获取墨迹的各种设置,该属性的类型为 DrawingAttributes 型
  2902. //blackboard_canvas.DefaultDrawingAttributes = drawingAttributes;
  2903. //blackboard_canvas.UseCustomCursor = true;
  2904. //drawingAttributes.FitToCurve = true;
  2905. //drawingAttributes.IgnorePressure = false;
  2906. //drawingAttributes.Width = PenSize;
  2907. //drawingAttributes.Height = PenSize;
  2908. //drawingAttributes.Color = Color;
  2909. //blackboard_canvas.Cursor = System.Windows.Input.Cursors.Pen;
  2910. APP.PageDrawList.Clear();
  2911. imgCanvas.Source = null;
  2912. imgDocumentation.Source = null;
  2913. gridPage.Visibility = Visibility.Collapsed;
  2914. #endregion
  2915. //缩略图
  2916. string ThumbnailPath = FileToolsCommon.GetDirectoryName(VideoSavePathName) + "ThumbnailPath/";
  2917. FileToolsCommon.CreateDirectory(ThumbnailPath);
  2918. //缩略图存储位置
  2919. string ThumbnailPathName = ThumbnailPath + FileToolsCommon.GetIOFileName(VideoSavePathName).Replace(".", "") + ".JPG";
  2920. int gridActWidth = (int)GridMain.ActualWidth;
  2921. int gridActHeight = (int)GridMain.ActualHeight;
  2922. APP.FFmpeg.StopFFmpeg(AudioPathName);
  2923. new Thread(new ThreadStart(new Action(() =>
  2924. {
  2925. IsStartCount = false;
  2926. //停止截图
  2927. while (APP.FFmpeg.myProcess != null)
  2928. {
  2929. Thread.Sleep(100);
  2930. }
  2931. Dispatcher.Invoke(() =>
  2932. {
  2933. timer.Change(-1, 0);
  2934. timer.Dispose();
  2935. //End();
  2936. txbTime.Text = "";
  2937. txbTime.Visibility = Visibility.Hidden;
  2938. });
  2939. //}))).Start();
  2940. //new Thread(new ThreadStart(new Action(() =>
  2941. //{
  2942. //判断音频是否存在 判断音频临时文件夹是否存在
  2943. if (IsRecordAudio)
  2944. {
  2945. if (!FileToolsCommon.IsExistFile(AudioPathName))
  2946. {
  2947. Thread.Sleep(100);
  2948. }
  2949. if (FileToolsCommon.IsExistDirectory(FileToolsCommon.GetDirectoryName(AudioPathName) + "temp/"))
  2950. {
  2951. Thread.Sleep(100);
  2952. }
  2953. }
  2954. else
  2955. {
  2956. //没有录制音频
  2957. AudioPathName = null;
  2958. }
  2959. //合成视频
  2960. bool SynRes = APP.FFmpeg.SynthesisVideo(ImgPath, AudioPathName, VideoSynthesisPathName, 5, gridActWidth, gridActHeight);
  2961. //}))).Start();
  2962. //new Thread(new ThreadStart(new Action(() =>
  2963. //{
  2964. if (!SynRes)
  2965. {
  2966. Dispatcher.Invoke(() =>
  2967. {
  2968. MessageWindow.Show("视频录制失败,无法保存此视频!");
  2969. BtnRecord.IsEnabled = true;
  2970. btnStop.IsEnabled = true;
  2971. TxbRecordingWord.Text = "录制";
  2972. txbType.Text = "";
  2973. });
  2974. return;
  2975. }
  2976. Dispatcher.Invoke(() =>
  2977. {
  2978. txbType.Text = "转码中";
  2979. });
  2980. while (!FileToolsCommon.IsExistFile(VideoSynthesisPathName))
  2981. {
  2982. Thread.Sleep(100);
  2983. }
  2984. while (FileToolsCommon.IsExistDirectory(FileToolsCommon.GetDirectoryName(VideoSynthesisPathName) + "temp/"))
  2985. {
  2986. Thread.Sleep(100);
  2987. }
  2988. FileToolsCommon.DeleteFile(ThumbnailPathName);
  2989. VideoInfo.RSTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  2990. Thread.Sleep(500);
  2991. //VideoInfo.VideoSize = FileToolsCommon.GetFileSizeByMB(VideoSavePathName).ToString() + " MB";
  2992. VideoInfo.VideoPath = VideoSavePathName;
  2993. VideoInfo.ThumbnailPath = ThumbnailPathName;
  2994. //生成缩略图
  2995. bool ThuRes = APP.FFmpeg.GenerateThumbnails(VideoSynthesisPathName, ThumbnailPathName,200,130);
  2996. Thread.Sleep(500);
  2997. int imgW = (int)GridMain.ActualWidth + (GridMain.ActualWidth % 2 > 0 ? 1 : 0);
  2998. int imgH = (int)GridMain.ActualHeight + (GridMain.ActualHeight % 2 > 0 ? 1 : 0);
  2999. if (ThuRes)
  3000. {
  3001. Bitmap bmp = ImageHelper.ReadBitmapFile(ThumbnailPathName);
  3002. if (bmp != null)
  3003. {
  3004. imgW = bmp.Width + (bmp.Width % 2 > 0 ? 1 : 0);
  3005. imgH = bmp.Height + (bmp.Height % 2 > 0 ? 1 : 0);
  3006. }
  3007. }
  3008. APP.FFmpeg.VideoTranscode(VideoSynthesisPathName, VideoSavePathName, imgW, imgH);
  3009. VideoInfo.FileGuid = Guid.NewGuid().ToString();
  3010. VideoInfo.IsUpload = false;
  3011. VideoInfo.Uploaded = 0;
  3012. VideoInfo.Savefolder = APP.UserInfo.Schoolid + "/resource";
  3013. APP.VideoList.Add(VideoInfo);
  3014. //保存数据
  3015. APP.SaveWkData();
  3016. IsFirstR = true;
  3017. Dispatcher.Invoke(() =>
  3018. {
  3019. BtnRecord.IsEnabled = true;
  3020. btnStop.IsEnabled = true;
  3021. TxbRecordingWord.Text = "录制";
  3022. txbType.Text = "";
  3023. });
  3024. }))).Start();
  3025. //List<Model_Video> VideoList
  3026. }
  3027. catch (Exception ex)
  3028. {
  3029. MessageWindow.Show(ex.Message);
  3030. }
  3031. }
  3032. }
  3033. #endregion
  3034. /// <summary>
  3035. /// 登陆事件
  3036. /// </summary>
  3037. /// <param name="sender"></param>
  3038. /// <param name="e"></param>
  3039. private void BtnLoginType_Click(object sender, RoutedEventArgs e)
  3040. {
  3041. Login();
  3042. }
  3043. /// <summary>
  3044. /// 登陆
  3045. /// </summary>
  3046. private void Login()
  3047. {
  3048. if (APP.W_LoginWindow == null)
  3049. {
  3050. APP.W_LoginWindow = new LoginWindow
  3051. {
  3052. WindowStartupLocation = WindowStartupLocation.CenterOwner,
  3053. Owner = this
  3054. };
  3055. }
  3056. else
  3057. {
  3058. APP.W_LoginWindow.Initialize();
  3059. }
  3060. APP.W_LoginWindow.ShowDialog();
  3061. if (APP.IsLoginType)
  3062. {
  3063. txbLoginType.Text = APP.UserInfo.Username;
  3064. //ImgUpload.Visibility = Visibility.Visible;
  3065. //ImgUploadTwo.Visibility = Visibility.Collapsed;
  3066. }
  3067. else
  3068. {
  3069. txbLoginType.Text = "未登录";
  3070. //ImgUpload.Visibility = Visibility.Collapsed;
  3071. //ImgUploadTwo.Visibility = Visibility.Visible;
  3072. }
  3073. }
  3074. /// <summary>
  3075. /// 状态更改为未登陆
  3076. /// </summary>
  3077. private void LoginType()
  3078. {
  3079. APP.IsLoginType = false;
  3080. txbLoginType.Text = "未登录";
  3081. APP.UserInfo = new Model_UserInfo();
  3082. ImgUpload.Visibility = Visibility.Collapsed;
  3083. ImgUploadTwo.Visibility = Visibility.Visible;
  3084. }
  3085. /// <summary>
  3086. /// 获取时间戳
  3087. /// </summary>
  3088. /// <returns></returns>
  3089. public string GetTimeStamp()
  3090. {
  3091. TimeSpan ts = DateTime.Now - new DateTime(1970, 1, 1, 0, 0, 0, 0);
  3092. return Convert.ToInt64(ts.TotalSeconds).ToString();
  3093. }
  3094. /// <summary>
  3095. /// 返回一个时间戳到毫秒
  3096. /// </summary>
  3097. /// <returns></returns>
  3098. public static long Timestamp()
  3099. {
  3100. TimeSpan ts = DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0);
  3101. long timestr = Convert.ToInt64(ts.TotalMilliseconds);
  3102. return timestr;
  3103. }
  3104. /// <summary>
  3105. /// 增加事件
  3106. /// </summary>
  3107. /// <param name="sender"></param>
  3108. /// <param name="e"></param>
  3109. private void BtnAdd_Click(object sender, RoutedEventArgs e)
  3110. {
  3111. Record();
  3112. if (APP.pageData.currpage > 0)
  3113. {
  3114. APP.PageDrawList[APP.pageData.currpage - 1].IsImageLocation = true;
  3115. }
  3116. if (IsStartCount && blackboard_canvas.Visibility == Visibility.Collapsed)
  3117. {
  3118. blackboard_canvas.Visibility = Visibility.Visible;
  3119. }
  3120. APP.pageData.pagenum += 1;
  3121. HideAngleBorder();
  3122. gridPage.Visibility = Visibility.Visible;//页码大于0 显示
  3123. APP.pageData.currpage = APP.pageData.pagenum;
  3124. myblackboard.changepage(APP.pageData.currpage - 1);
  3125. ///清空页面图片UI
  3126. imgCanvas.Source = null;
  3127. imgDocumentation.Source = null;
  3128. ///画板模型增加一页
  3129. Model_DrawData model_DrawData = new Model_DrawData
  3130. {
  3131. PageNum = APP.pageData.currpage
  3132. };
  3133. APP.PageDrawList.Add(model_DrawData);
  3134. ImgPrint.Visibility = Visibility.Visible;//可打印
  3135. ImgPrintTwo.Visibility = Visibility.Collapsed;
  3136. btnPrint.IsEnabled = true;
  3137. //APP.SaveDraw();
  3138. if (btnImport.IsEnabled == true)
  3139. {
  3140. ///截图可用
  3141. ImgScreenshot.Visibility = Visibility.Visible;
  3142. ImgScreenshotTwo.Visibility = Visibility.Collapsed;
  3143. btnScreenshot.IsEnabled = true;
  3144. }
  3145. }
  3146. /// <summary>
  3147. /// 打印事件
  3148. /// </summary>
  3149. /// <param name="sender"></param>
  3150. /// <param name="e"></param>
  3151. private void BtnPrint_Click(object sender, RoutedEventArgs e)
  3152. {
  3153. try
  3154. {
  3155. //3种情况 1.文档图片 2.截图图片 3.没有图片
  3156. if(APP.PageDrawList.Count==0)
  3157. {
  3158. MessageWindow.Show("没有可打印的页,您可以新增、截图或导入来增加页!");
  3159. return;
  3160. }
  3161. iTextSharp.text.Document document = new iTextSharp.text.Document(iTextSharp.text.PageSize.A4, 25, 25, 25, 25);
  3162. //iTextSharp.text.Rectangle page = new iTextSharp.text.Rectangle(iTextSharp.text.PageSize.A4., 250f);//cs
  3163. ////设置纸张横向
  3164. //document.SetPageSize(iTextSharp.text.PageSize.A4.Rotate());
  3165. string imgPath = FileToolsCommon.GetFileAbsolutePath("temp");
  3166. FileToolsCommon.CreateFile(imgPath);
  3167. imgPath += "\\101.pdf";
  3168. iTextSharp.text.pdf.PdfWriter.GetInstance(document, new FileStream(imgPath, FileMode.Create, FileAccess.ReadWrite));
  3169. document.Open();
  3170. iTextSharp.text.Image image;
  3171. for (int i = 0; i < APP.PageDrawList.Count; i++)
  3172. {
  3173. long ii = Timestamp();
  3174. string directoryPath = AppDomain.CurrentDomain.BaseDirectory + "Temp\\";
  3175. string filePathOutPut = Path.Combine(directoryPath, string.Format("print{0}{1}.jpg", ii, i));
  3176. RectangleF rectangleFs = new RectangleF();
  3177. MergerImg("", filePathOutPut, rectangleFs, out string errmsg);
  3178. image = iTextSharp.text.Image.GetInstance(filePathOutPut);
  3179. if (string.IsNullOrEmpty(APP.PageDrawList[i].PageImagePath))//没有图片
  3180. {
  3181. }
  3182. else if (APP.PageDrawList[i].ImgDocumentation == true)
  3183. {
  3184. image = iTextSharp.text.Image.GetInstance(APP.PageDrawList[i].PageImagePath);
  3185. }
  3186. else
  3187. {
  3188. RectangleF rectangleF = new RectangleF
  3189. {
  3190. Width = (float)APP.PageDrawList[i].ImageSizes.CenterX,
  3191. Height = (float)APP.PageDrawList[i].ImageSizes.CenterY,
  3192. X = (float)APP.PageDrawList[i].ImageLocation.X,
  3193. Y = (float)APP.PageDrawList[i].ImageLocation.Y
  3194. };
  3195. string msg = string.Empty;
  3196. bool isImg = MergerImg(APP.PageDrawList[i].PageImagePath, filePathOutPut, rectangleF, out msg);
  3197. if (isImg)
  3198. {
  3199. image = iTextSharp.text.Image.GetInstance(filePathOutPut);
  3200. }
  3201. else
  3202. {
  3203. image = iTextSharp.text.Image.GetInstance(APP.PageDrawList[i].PageImagePath);
  3204. }
  3205. }
  3206. if (image.Height > iTextSharp.text.PageSize.A4.Height - 25)
  3207. {
  3208. image.ScaleToFit(iTextSharp.text.PageSize.A4.Width - 25, iTextSharp.text.PageSize.A4.Height - 25);
  3209. }
  3210. else if (image.Width > iTextSharp.text.PageSize.A4.Width - 25)
  3211. {
  3212. image.ScaleToFit(iTextSharp.text.PageSize.A4.Width - 25, iTextSharp.text.PageSize.A4.Height - 25);
  3213. }
  3214. image.Alignment = iTextSharp.text.Image.ALIGN_MIDDLE;
  3215. document.NewPage();
  3216. document.Add(image);
  3217. //iTextSharp.text.Chunk c1 = new iTextSharp.text.Chunk("Hello World");
  3218. //iTextSharp.text.Phrase p1 = new iTextSharp.text.Phrase();
  3219. //p1.Leading = 150; //行间距
  3220. //document.Add(p1);
  3221. }
  3222. Console.WriteLine("转换成功!");
  3223. document.Close();
  3224. }
  3225. catch (Exception ex)
  3226. {
  3227. Console.WriteLine("转换失败,原因:" + ex.Message);
  3228. }
  3229. //document.Close();
  3230. ////Console.ReadKey();
  3231. if (APP.W_PrintWindow == null)
  3232. {
  3233. APP.W_PrintWindow = new PrintWindow
  3234. {
  3235. //APP.W_PrintWindow.Topmost = true;
  3236. Owner = this
  3237. };
  3238. }
  3239. if (APP.PageDrawList.Count > 0 && !string.IsNullOrWhiteSpace(APP.PageDrawList[0].PageImagePath))
  3240. {
  3241. APP.W_PrintWindow.Initialize(APP.PageDrawList[0].PageImagePath);
  3242. }
  3243. else
  3244. {
  3245. APP.W_PrintWindow.Initialize("");
  3246. }
  3247. APP.W_PrintWindow.ShowDialog();
  3248. //int pr = 1;
  3249. //string msg = string.Empty;
  3250. //string outPut = string.Empty;
  3251. //LatticeFileHelper.GeneratingPDF(@"G:\101.pdf", @"G:\102.TPF",out pr, out msg, out outPut);
  3252. //if(pr==0)
  3253. //{
  3254. // outPut = outPut.Replace("[", "").Replace("]","").Replace("\"","").Trim();
  3255. // APP.OutPut = outPut.Split(',');
  3256. // string defa = string.Empty;
  3257. // List<string>defaList= LatticeFileHelper.GetPrinterList(out defa);
  3258. // int printResult = 1;
  3259. // string standardError = string.Empty;
  3260. // string standardOutput = string.Empty;
  3261. // LatticeFileHelper.PrinterTPFFile(@"G:\102.TPF",1, /*defa*/"导出为WPS PDF", out printResult,out standardError,out standardOutput);
  3262. //}
  3263. }
  3264. /// 上一页
  3265. /// </summary>
  3266. /// <param name="sender"></param>
  3267. /// <param name="e"></param>
  3268. private void last_button_Click(object sender, RoutedEventArgs e)
  3269. {
  3270. if (APP.pageData.currpage > 1)
  3271. {
  3272. mouseDown = false;
  3273. HideAngleBorder();
  3274. //if(!APP.PageDrawList[APP.pageData.currpage - 1].IsImageLocation)
  3275. //{
  3276. // ImgWG();
  3277. //}
  3278. APP.pageData.currpage -= 1;
  3279. myblackboard.changepage(APP.pageData.currpage - 1);
  3280. if (btnImport.IsEnabled == true)
  3281. {
  3282. ///截图可用
  3283. ImgScreenshot.Visibility = Visibility.Visible;
  3284. ImgScreenshotTwo.Visibility = Visibility.Collapsed;
  3285. btnScreenshot.IsEnabled = true;
  3286. }
  3287. if (APP.pageData.currpage <= APP.PageDrawList.Count)
  3288. {
  3289. if (APP.PageDrawList[APP.pageData.currpage - 1].ImageLocation != null)
  3290. {
  3291. APP.PageDrawList[APP.pageData.currpage - 1].IsImageLocation = true;
  3292. }
  3293. if (!string.IsNullOrWhiteSpace(txbCurrpage.Text) && APP.pageData.currpage <= APP.PageDrawList.Count && APP.pageData.currpage > 0 && !string.IsNullOrWhiteSpace(APP.PageDrawList[APP.pageData.currpage - 1].PageImagePath))
  3294. {
  3295. //imgCanvas.Source = new BitmapImage(new Uri(APP.Paths[APP.pageData.currpage - 1]));//cs
  3296. if (APP.PageDrawList[APP.pageData.currpage - 1].ImgDocumentation)
  3297. {
  3298. imgCanvas.Source = null;
  3299. imgDocumentation.Source = new BitmapImage(new Uri(APP.PageDrawList[APP.pageData.currpage - 1].PageImagePath));
  3300. ImgScreenshot.Visibility = Visibility.Collapsed;//当前页为导入时不可截图
  3301. ImgScreenshotTwo.Visibility = Visibility.Visible;
  3302. btnScreenshot.IsEnabled = false;
  3303. }
  3304. else
  3305. {
  3306. imgDocumentation.Source = null;
  3307. imgCanvas.Source = new BitmapImage(new Uri(APP.PageDrawList[APP.pageData.currpage - 1].PageImagePath));
  3308. APP.PageDrawList[APP.pageData.currpage - 1].IsImageLocation = false;
  3309. if (APP.PageDrawList[APP.pageData.currpage - 1].ImageLocation != null && APP.PageDrawList[APP.pageData.currpage - 1].ImageLocation.X > 0)
  3310. {
  3311. mouseDown = false;
  3312. ImgXY();
  3313. }
  3314. }
  3315. }
  3316. else
  3317. {
  3318. imgCanvas.Source = null;
  3319. imgDocumentation.Source = null;
  3320. }
  3321. }
  3322. }
  3323. }
  3324. private void ImgXY()
  3325. {
  3326. imgCanvas.Width = APP.PageDrawList[APP.pageData.currpage - 1].ImageSizes.CenterX;
  3327. imgCanvas.Height = APP.PageDrawList[APP.pageData.currpage - 1].ImageSizes.CenterY;
  3328. imgCanvas.Margin = new Thickness(APP.PageDrawList[APP.pageData.currpage - 1].ImageLocation.X, APP.PageDrawList[APP.pageData.currpage - 1].ImageLocation.Y, 0, 0);
  3329. //imgCanvas.Margin.Left= APP.PageDrawList[APP.pageData.currpage - 1].ImageLocation.X;
  3330. //transform.Y = APP.PageDrawList[APP.pageData.currpage - 1].ImageLocation.Y;
  3331. }
  3332. private void ImgWG()
  3333. {
  3334. mouseDown = false;
  3335. APP.PageDrawList[APP.pageData.currpage - 1].ImageLocation = new TranslateTransform
  3336. {
  3337. X = imgCanvas.Margin.Left,
  3338. Y = imgCanvas.Margin.Top
  3339. };
  3340. APP.PageDrawList[APP.pageData.currpage - 1].ImageSizes = new ScaleTransform
  3341. {
  3342. CenterX = imgCanvas.ActualWidth,
  3343. CenterY = imgCanvas.ActualHeight
  3344. };
  3345. }
  3346. /// <summary>
  3347. /// 下一页
  3348. /// </summary>
  3349. /// <param name="sender"></param>
  3350. /// <param name="e"></param>
  3351. private void next_btn_Click(object sender, RoutedEventArgs e)
  3352. {
  3353. if (APP.pageData.currpage < APP.pageData.pagenum)
  3354. {
  3355. mouseDown = false;
  3356. HideAngleBorder();
  3357. //if (!APP.PageDrawList[APP.pageData.currpage - 1].IsImageLocation)
  3358. //{
  3359. // ImgWG();
  3360. //}
  3361. APP.pageData.currpage += 1;
  3362. myblackboard.changepage(APP.pageData.currpage - 1);
  3363. if (btnImport.IsEnabled == true)
  3364. {
  3365. ///截图可用
  3366. ImgScreenshot.Visibility = Visibility.Visible;
  3367. ImgScreenshotTwo.Visibility = Visibility.Collapsed;
  3368. btnScreenshot.IsEnabled = true;
  3369. }
  3370. if (APP.pageData.currpage <= APP.PageDrawList.Count)
  3371. {
  3372. if (APP.PageDrawList[APP.pageData.currpage - 1].ImageLocation != null)
  3373. {
  3374. APP.PageDrawList[APP.pageData.currpage - 1].IsImageLocation = true;
  3375. }
  3376. if (!string.IsNullOrWhiteSpace(txbCurrpage.Text) && APP.pageData.currpage <= APP.PageDrawList.Count && !string.IsNullOrWhiteSpace(APP.PageDrawList[APP.pageData.currpage - 1].PageImagePath))
  3377. {
  3378. if (APP.PageDrawList[APP.pageData.currpage - 1].ImgDocumentation)
  3379. {
  3380. imgCanvas.Source = null;
  3381. imgDocumentation.Source = new BitmapImage(new Uri(APP.PageDrawList[APP.pageData.currpage - 1].PageImagePath));
  3382. ImgScreenshot.Visibility = Visibility.Collapsed;//当前页为导入时不可截图
  3383. ImgScreenshotTwo.Visibility = Visibility.Visible;
  3384. btnScreenshot.IsEnabled = false;
  3385. }
  3386. else
  3387. {
  3388. imgDocumentation.Source = null;
  3389. imgCanvas.Source = new BitmapImage(new Uri(APP.PageDrawList[APP.pageData.currpage - 1].PageImagePath));
  3390. APP.PageDrawList[APP.pageData.currpage - 1].IsImageLocation = false;
  3391. if (APP.PageDrawList[APP.pageData.currpage - 1].ImageLocation != null && APP.PageDrawList[APP.pageData.currpage - 1].ImageLocation.X > 0)
  3392. {
  3393. //var group = IMG.FindResource("Imageview") as TransformGroup;
  3394. //#region 高低 缩放比例
  3395. //if (APP.PageDrawList[APP.pageData.currpage - 1].ImageSize != null)
  3396. //{
  3397. // var transform1 = group.Children[0] as ScaleTransform;
  3398. // transform1.ScaleX = APP.PageDrawList[APP.pageData.currpage - 1].ImageSize.ScaleX;
  3399. // transform1.ScaleY = APP.PageDrawList[APP.pageData.currpage - 1].ImageSize.ScaleY;
  3400. // imgCanvas.Width = APP.PageDrawList[APP.pageData.currpage - 1].ImageSizes.CenterX;
  3401. // imgCanvas.Height = APP.PageDrawList[APP.pageData.currpage - 1].ImageSizes.CenterY;
  3402. //}
  3403. //#endregion
  3404. //#region 坐标XY轴
  3405. //var transform = group.Children[1] as TranslateTransform;
  3406. //transform.X = APP.PageDrawList[APP.pageData.currpage - 1].ImageLocation.X;
  3407. //transform.Y = APP.PageDrawList[APP.pageData.currpage - 1].ImageLocation.Y;
  3408. //#endregion
  3409. mouseDown = false;
  3410. ImgXY();
  3411. }
  3412. }
  3413. }
  3414. else
  3415. {
  3416. imgCanvas.Source = null;
  3417. imgDocumentation.Source = null;
  3418. }
  3419. }
  3420. }
  3421. }
  3422. /// <summary>
  3423. /// 生成图片
  3424. /// </summary>
  3425. /// <param name="_path">图片地址</param>
  3426. /// <param name="_saveimg">保存位置</param>
  3427. /// <param name="_rectangle">图片位置</param>
  3428. /// <param name="errmsg">错误消息</param>
  3429. /// <returns></returns>
  3430. private bool MergerImg(string _path, string _saveimg, RectangleF _rectangle, out string errmsg)
  3431. {
  3432. errmsg = null;
  3433. try
  3434. {
  3435. Bitmap bitmap = null;
  3436. //创建要显示的图片对象,根据参数的个数设置宽度
  3437. Bitmap backgroudImg = new Bitmap((int)gridM.ActualWidth, (int)gridM.ActualHeight);
  3438. Graphics g = Graphics.FromImage(backgroudImg);
  3439. //清除画布,背景设置为白色
  3440. g.Clear(System.Drawing.Color.White);
  3441. if (!string.IsNullOrWhiteSpace(_path))
  3442. {
  3443. bitmap = ImageHelper.ReadBitmapFile(_path);
  3444. g.DrawImage(bitmap, _rectangle);
  3445. }
  3446. backgroudImg.Save(_saveimg);
  3447. g.Dispose();
  3448. backgroudImg.Dispose();
  3449. if (bitmap != null)
  3450. {
  3451. bitmap.Dispose();
  3452. }
  3453. GC.Collect();
  3454. return true;
  3455. }
  3456. catch (Exception ex)
  3457. {
  3458. errmsg = ex.Message;
  3459. LogHelper.WriteErrLog("【截图合成】(MergerImg)图片合成失败:" + ex.Message, ex);
  3460. return false;
  3461. }
  3462. }
  3463. /// <summary>
  3464. /// 将Word文档转换为图片的方法(该方法基于第三方DLL),你可以像这样调用该方法: ConvertPDF2Image("F:\\PdfFile.doc", "F:\\",
  3465. /// "ImageFile", 1, 20, ImageFormat.Png, 256);
  3466. /// </summary>
  3467. /// <param name="pdfInputPath">Word文件路径</param>
  3468. /// <param name="imageOutputPath">图片输出路径,如果为空,默认值为Word所在路径</param>
  3469. /// <param name="imageName">图片的名字,不需要带扩展名,如果为空,默认值为Word的名称</param>
  3470. /// <param name="startPageNum">从PDF文档的第几页开始转换,如果为0,默认值为1</param>
  3471. /// <param name="endPageNum">从PDF文档的第几页开始停止转换,如果为0,默认值为Word总页数</param>
  3472. /// <param name="imageFormat">设置所需图片格式,如果为null,默认格式为PNG</param>
  3473. /// <param name="resolution">设置图片的像素,数字越大越清晰,如果为0,默认值为128,建议最大值不要超过1024</param>
  3474. public List<string> ConvertWordToImage(string wordInputPath, string imageOutputPath,
  3475. string imageName, int startPageNum, int endPageNum, ImageFormat imageFormat, float resolution)
  3476. {
  3477. // 返回的图片绝对路径集合
  3478. List<string> images = new List<string>();
  3479. try
  3480. {
  3481. // open word file
  3482. Aspose.Words.Document doc = new Aspose.Words.Document(wordInputPath);
  3483. // validate parameter
  3484. if (doc == null) { throw new Exception("Word文件无效或者Word文件被加密!"); }
  3485. if (imageOutputPath.Trim().Length == 0) { imageOutputPath = System.IO.Path.GetDirectoryName(wordInputPath); }
  3486. if (!Directory.Exists(imageOutputPath)) { Directory.CreateDirectory(imageOutputPath); }
  3487. if (imageName.Trim().Length == 0) { imageName = System.IO.Path.GetFileNameWithoutExtension(wordInputPath); }
  3488. if (startPageNum <= 0) { startPageNum = 1; }
  3489. if (endPageNum > doc.PageCount || endPageNum <= 0) { endPageNum = doc.PageCount; }
  3490. if (startPageNum > endPageNum) { int tempPageNum = startPageNum; startPageNum = endPageNum; endPageNum = startPageNum; }
  3491. if (imageFormat == null) { imageFormat = ImageFormat.Png; }
  3492. if (resolution <= 0) { resolution = 128; }
  3493. ImageSaveOptions imageSaveOptions = new ImageSaveOptions(GetSaveFormat(imageFormat))
  3494. {
  3495. Resolution = resolution
  3496. };
  3497. // start to convert each page
  3498. for (int i = startPageNum; i <= endPageNum; i++)
  3499. {
  3500. imageSaveOptions.PageIndex = i - 1;
  3501. doc.Save(System.IO.Path.Combine(imageOutputPath, imageName) + "_" + APP.num.ToString() + "." + imageFormat.ToString(), imageSaveOptions);
  3502. images.Add(System.IO.Path.Combine(imageOutputPath, imageName) + "_" + APP.num.ToString() + "." + imageFormat.ToString());
  3503. APP.num++;
  3504. }
  3505. imageSaveOptions = null;
  3506. doc = null;
  3507. }
  3508. catch (Exception ex)
  3509. {
  3510. //if(ex.Message.ToString().Equals("{\"The document appears to be corrupted and cannot be loaded.\"}"))
  3511. //{
  3512. // MessageWindow.Show("Word文件无效或者Word文件被加密!");
  3513. //}
  3514. //else
  3515. //{
  3516. MessageWindow.Show("该文件无法使用!");
  3517. //}
  3518. LogHelper.WriteErrLog("【导入方法(ConvertWordToImage)】错误日志:" + ex.Message, ex);
  3519. }
  3520. return images;
  3521. }
  3522. private static SaveFormat GetSaveFormat(ImageFormat imageFormat)
  3523. {
  3524. SaveFormat sf;// = SaveFormat.Unknown;
  3525. if (imageFormat.Equals(ImageFormat.Png))
  3526. {
  3527. sf = SaveFormat.Png;
  3528. }
  3529. else if (imageFormat.Equals(ImageFormat.Jpeg))
  3530. {
  3531. sf = SaveFormat.Jpeg;
  3532. }
  3533. else if (imageFormat.Equals(ImageFormat.Tiff))
  3534. {
  3535. sf = SaveFormat.Tiff;
  3536. }
  3537. else if (imageFormat.Equals(ImageFormat.Bmp))
  3538. {
  3539. sf = SaveFormat.Bmp;
  3540. }
  3541. else
  3542. {
  3543. sf = SaveFormat.Unknown;
  3544. }
  3545. return sf;
  3546. }
  3547. #region 图像缩放,移动
  3548. private bool mouseDown;
  3549. private System.Windows.Point mouseXY;
  3550. private void IMG1_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
  3551. {
  3552. ContentControl img = sender as ContentControl;
  3553. if (img == null)
  3554. {
  3555. return;
  3556. }
  3557. img.CaptureMouse();
  3558. mouseDown = true;
  3559. mouseXY = e.GetPosition(img);
  3560. Console.WriteLine("mouseXY.X = " + mouseXY.X + "; mouseXY.Y = " + mouseXY.Y);
  3561. }
  3562. private void IMG1_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
  3563. {
  3564. ContentControl img = sender as ContentControl;
  3565. if (img == null)
  3566. {
  3567. return;
  3568. }
  3569. img.ReleaseMouseCapture();
  3570. mouseDown = false;
  3571. }
  3572. private void IMG1_MouseMove(object sender, System.Windows.Input.MouseEventArgs e)
  3573. {
  3574. ContentControl img = sender as ContentControl;
  3575. if (img == null)
  3576. {
  3577. return;
  3578. }
  3579. if (mouseDown)
  3580. {
  3581. Domousemove(img, e);
  3582. }
  3583. }
  3584. /// <summary>
  3585. /// x y轴
  3586. /// </summary>
  3587. /// <param name="img"></param>
  3588. /// <param name="e"></param>
  3589. private void Domousemove(ContentControl img, System.Windows.Input.MouseEventArgs e)
  3590. {
  3591. if (e.LeftButton != MouseButtonState.Pressed)
  3592. {
  3593. return;
  3594. }
  3595. if (APP.PageDrawList[APP.pageData.currpage - 1].ImageLocation != null && APP.PageDrawList[APP.pageData.currpage - 1].IsImageLocation)
  3596. {
  3597. return;
  3598. }
  3599. TransformGroup group = IMG.FindResource("Imageview") as TransformGroup;
  3600. TranslateTransform transform = group.Children[1] as TranslateTransform;
  3601. System.Windows.Point position = e.GetPosition(img);
  3602. transform.X -= mouseXY.X - position.X;
  3603. transform.Y -= mouseXY.Y - position.Y;
  3604. mouseXY = position;
  3605. APP.PageDrawList[APP.pageData.currpage - 1].ImageLocation = new TranslateTransform
  3606. {
  3607. X = transform.X,
  3608. Y = transform.Y
  3609. };
  3610. //APP.PageDrawList[APP.pageData.currpage - 1].IsImageLocation = false;
  3611. }
  3612. private void IMG1_MouseWheel(object sender, MouseWheelEventArgs e)
  3613. {
  3614. ContentControl img = sender as ContentControl;
  3615. if (img == null)
  3616. {
  3617. return;
  3618. }
  3619. System.Windows.Point point = e.GetPosition(img);
  3620. Console.WriteLine("point.X = " + point.X + "; point.Y=" + point.Y);
  3621. System.Windows.Point PicLocate = e.GetPosition(imgCanvas);
  3622. Console.WriteLine("PicEmap.X = " + PicLocate.X + "; PicEmap.Y=" + PicLocate.Y);
  3623. TransformGroup group = IMG.FindResource("Imageview") as TransformGroup;
  3624. double delta = e.Delta * 0.001;
  3625. DowheelZoom(group, point, delta);
  3626. }
  3627. private void DowheelZoom(TransformGroup group, System.Windows.Point point, double delta)
  3628. {
  3629. System.Windows.Point pointToContent = group.Inverse.Transform(point);
  3630. ScaleTransform transform = group.Children[0] as ScaleTransform;
  3631. if (transform.ScaleX + delta < 0.1)
  3632. {
  3633. return;
  3634. }
  3635. transform.ScaleX += delta;
  3636. transform.ScaleY += delta;
  3637. TranslateTransform transform1 = group.Children[1] as TranslateTransform;
  3638. transform1.X = -1 * ((pointToContent.X * transform.ScaleX) - point.X);
  3639. transform1.Y = -1 * ((pointToContent.Y * transform.ScaleY) - point.Y);
  3640. LogHelper.WriteInfoLog("【img宽高】" + imgCanvas.ActualWidth.ToString() + ":"
  3641. + imgCanvas.ActualHeight.ToString() + "百分比:" + transform.ScaleX.ToString() + ":" + transform.ScaleY.ToString()
  3642. );
  3643. //Console.WriteLine("transform.ScaleX = " + transform.ScaleX + "; transform.ScaleY = " + transform.ScaleY);
  3644. //APP.PageDrawList[APP.pageData.currpage - 1].ImageSize = new ScaleTransform();
  3645. //APP.PageDrawList[APP.pageData.currpage - 1].ImageSize.ScaleX = transform.ScaleX;
  3646. //APP.PageDrawList[APP.pageData.currpage - 1].ImageSize.ScaleY = transform.ScaleY;
  3647. APP.PageDrawList[APP.pageData.currpage - 1].ImageLocation = new TranslateTransform
  3648. {
  3649. X = transform1.X,
  3650. Y = transform1.Y
  3651. };
  3652. APP.PageDrawList[APP.pageData.currpage - 1].ImageSizes = new ScaleTransform
  3653. {
  3654. CenterX = imgCanvas.ActualWidth,
  3655. CenterY = imgCanvas.ActualHeight
  3656. };
  3657. APP.PageDrawList[APP.pageData.currpage - 1].IsImageLocation = false;
  3658. }
  3659. #endregion
  3660. #region 点阵笔相关
  3661. #region 值初始化
  3662. // 不同尺寸点阵纸点阵宽高尺寸计算方法为:纸张物理尺寸(毫米)/0.3 *8,详见 开发必读.pdf 文档
  3663. /// <summary>
  3664. /// A4点阵纸点阵宽度
  3665. /// </summary>
  3666. private const int A4_WIDTH = 5600;
  3667. /// <summary>
  3668. /// A4点阵纸点阵高度
  3669. /// </summary>
  3670. private const int A4_HEIGHT = 7920;
  3671. ///// <summary>
  3672. ///// 画板
  3673. ///// </summary>
  3674. //private Graphics graphics;
  3675. /// <summary>
  3676. /// 笔画坐标数组
  3677. /// </summary>
  3678. private List<System.Drawing.Point> stroke;
  3679. /// <summary>
  3680. /// 笔序列号
  3681. /// </summary>
  3682. private string penSerial;
  3683. /// <summary>
  3684. /// 笔是否在点
  3685. /// </summary>
  3686. private bool isPenDown;
  3687. //当前点阵地址
  3688. private string currentPageSerial = string.Empty;
  3689. //不同点阵地址对应的笔迹绘制图片,用于实现在不同点阵地址书写切换时,显示书写内容自动切换
  3690. //本例图片放在内存中存储,对于大量或者需要在多个点阵地址对应图片进行切换演示,建议将图片存储到文件,以免内存溢出
  3691. private Dictionary<string, System.Drawing.Image> pagesDic = new Dictionary<string, System.Drawing.Image>();
  3692. #endregion
  3693. public void InitPen()
  3694. {
  3695. stroke = new List<System.Drawing.Point>();
  3696. //获取点阵笔实例,并绑定点阵笔事件
  3697. //将授权文件内容传入,获取点阵笔对象实例
  3698. APP.digitalPen = DigitalPenHID.GetInstance(certificates.MyLicense.Bytes);
  3699. //绑定笔连接事件
  3700. APP.digitalPen.PenConnected += OnPenConnect;
  3701. //绑定笔断开事件
  3702. APP.digitalPen.PenDisconnect += OnPenDisconnect;
  3703. //绑定笔书写输出坐标事件
  3704. APP.digitalPen.PenCoordinate += OnPenCoordinate;
  3705. //绑定抬笔事件
  3706. APP.digitalPen.PenUp += OnPenUp;
  3707. //绑定落笔事件
  3708. APP.digitalPen.PenDown += OnPenDown;
  3709. APP.digitalPen.PenBatteryCapacity += OnBatteryCapacity;
  3710. APP.digitalPen.PenMemoryFillLevel += OnMemoryFillLevel;
  3711. //完成初始化点阵笔,开始与点阵笔通信
  3712. ERROR_CODE ER = APP.digitalPen.Start();
  3713. ////绑定笔在新的点阵地址页面书写事件
  3714. //APP.digitalPen.PenNewPage += APP.digitalPen_OnPenNewPage;
  3715. ////绑定笔信息事件
  3716. //APP.digitalPen.PenInfo += APP.digitalPen_OnPenInfo;
  3717. //启动接收笔数据,完成初始化工作
  3718. ERROR_CODE rc = APP.digitalPen.Start();
  3719. //判断是否成功
  3720. if (ER != ERROR_CODE.ERROR_OK)
  3721. {
  3722. MessageWindow.Show("初始化失败,授权过期,返回值:" + ER.ToString());
  3723. }
  3724. }
  3725. /// <summary>
  3726. /// 落笔
  3727. /// </summary>
  3728. /// <param name="time">时间戳,1970年1月1日到现在的总毫秒数</param>
  3729. /// <param name="penSerial">点阵笔序列号</param>
  3730. /// <param name="penType">点阵笔型号编号</param>
  3731. private void OnPenDown(ulong time, string penSerial, int penType)
  3732. {
  3733. if (CheckAccess())
  3734. {
  3735. Action<ulong, string, int> action = new Action<ulong, string, int>(OnPenDown);
  3736. Dispatcher.Invoke(action, new object[] { time, penSerial, penType });
  3737. }
  3738. else
  3739. {
  3740. //labPenSerial.Text = penSerial;
  3741. //labPenStatus.Text = "PenDown";
  3742. isPenDown = true;
  3743. //Dispatcher.Invoke(new Action(() =>
  3744. //{
  3745. // for (int i = 0; i < APP.PageDrawList.Count; i++)
  3746. // {
  3747. // if (APP.PageDrawList[i].PageCode == penSerial)
  3748. // {
  3749. // if (i < APP.pageData.pagenum)
  3750. // {
  3751. // if (i < APP.pageData.currpage)
  3752. // {
  3753. // int num = APP.pageData.currpage - i;
  3754. // APP.pageData.currpage -= num;
  3755. // myblackboard.changepage(APP.pageData.currpage - 1);
  3756. // if (APP.PageDrawList.Count > 0)
  3757. // {
  3758. // if (!string.IsNullOrWhiteSpace(txbCurrpage.Text) && APP.pageData.currpage <= APP.PageDrawList.Count && APP.pageData.currpage > 0 && !string.IsNullOrWhiteSpace(APP.PageDrawList[APP.pageData.currpage - 1].PageImagePath))
  3759. // {
  3760. // //imgCanvas.Source = new BitmapImage(new Uri(APP.Paths[APP.pageData.currpage - 1]));//cs
  3761. // imgCanvas.Source = new BitmapImage(new Uri(APP.PageDrawList[APP.pageData.currpage - 1].PageImagePath));
  3762. // }
  3763. // else
  3764. // {
  3765. // imgCanvas.Source = null;
  3766. // }
  3767. // }
  3768. // }
  3769. // else
  3770. // {
  3771. // int num = i - APP.pageData.currpage;
  3772. // APP.pageData.currpage += num;
  3773. // myblackboard.changepage(APP.pageData.currpage - 1);
  3774. // if (APP.PageDrawList.Count > 0)
  3775. // {
  3776. // if (!string.IsNullOrWhiteSpace(txbCurrpage.Text) && APP.pageData.currpage <= APP.PageDrawList.Count && !string.IsNullOrWhiteSpace(APP.PageDrawList[APP.pageData.currpage - 1].PageImagePath))
  3777. // {
  3778. // //imgCanvas.Source = new BitmapImage(new Uri(APP.Paths[APP.pageData.currpage-1]));
  3779. // imgCanvas.Source = new BitmapImage(new Uri(APP.PageDrawList[APP.pageData.currpage - 1].PageImagePath));
  3780. // }
  3781. // else
  3782. // {
  3783. // imgCanvas.Source = null;
  3784. // }
  3785. // }
  3786. // }
  3787. // }
  3788. // return;
  3789. // }
  3790. // }
  3791. // //myblackboard.changepages(0, 0, true);
  3792. // //myblackboard.changepaget(0, 0, true, blackboard_canvas);
  3793. //}));
  3794. }
  3795. //myblackboard.changepages(0, 0, true);
  3796. }
  3797. /// <summary>
  3798. /// 抬笔
  3799. /// </summary>
  3800. /// <param name="time">时间戳,1970年1月1日到现在的总毫秒数</param>
  3801. /// <param name="penSerial">点阵笔序列号</param>
  3802. /// <param name="penType">点阵笔型号编号</param>
  3803. private void OnPenUp(ulong time, string penSerial, int penType)
  3804. {
  3805. if (CheckAccess())
  3806. {
  3807. Action<ulong, string, int> action = new Action<ulong, string, int>(OnPenUp);
  3808. Dispatcher.Invoke(action, new object[] { time, penSerial, penType });
  3809. }
  3810. else
  3811. {
  3812. isPenDown = false;
  3813. APP.PenSerial = penSerial;
  3814. //int leftPoints = stroke.Count % 3;
  3815. //if (0 != leftPoints)
  3816. //{
  3817. // int from = stroke.Count - leftPoints - 1;
  3818. // if (from < 0)
  3819. // from = 0;
  3820. // int to = stroke.Count - 1;
  3821. // DrawCoordinates(from, to);
  3822. //}
  3823. stroke.Clear();
  3824. }
  3825. if (APP.pageData.currpage > 0)
  3826. {
  3827. Dispatcher.Invoke(new Action(() =>
  3828. {
  3829. myblackboard.changepages(0, 0, true, Color, PenSize, APP.pageData.currpage - 1);
  3830. }));
  3831. }
  3832. }
  3833. /// <summary>
  3834. /// 笔断开
  3835. /// </summary>
  3836. /// <param name="time">时间戳,1970年1月1日到现在的总毫秒数</param>
  3837. /// <param name="penSerial">点阵笔序列号</param>
  3838. /// <param name="penType">点阵笔型号编号</param>
  3839. private void OnPenDisconnect(ulong time, string penSerial, int penType)
  3840. {
  3841. if (CheckAccess())
  3842. {
  3843. Action<ulong, string, int> action = new Action<ulong, string, int>(OnPenDisconnect);
  3844. Dispatcher.Invoke(action, new object[] { time, penSerial, penType });
  3845. }
  3846. else
  3847. {
  3848. APP.PenSerial = penSerial;
  3849. APP.PenStatus = false;
  3850. Dispatcher.Invoke(new Action(() =>
  3851. {
  3852. txbNotConnected.Text = "未连接";
  3853. txbNotConnecteds.Text = "未连接";
  3854. }));
  3855. }
  3856. }
  3857. /// <summary>
  3858. /// 笔连接
  3859. /// </summary>
  3860. /// <param name="time">时间戳,1970年1月1日到现在的总毫秒数</param>
  3861. /// <param name="penSerial">点阵笔序列号</param>
  3862. /// <param name="penType">点阵笔型号编号</param>
  3863. private void OnPenConnect(ulong time, string penSerial, int penType)
  3864. {
  3865. if (CheckAccess())
  3866. {
  3867. Action<ulong, string, int> action = new Action<ulong, string, int>(OnPenConnect);
  3868. Dispatcher.Invoke(action, new object[] { time, penSerial, penType });
  3869. }
  3870. else
  3871. {
  3872. APP.PenSerial = penSerial;
  3873. APP.PenStatus = true;
  3874. this.penSerial = penSerial;
  3875. //连接后,在获取笔数据前,可以清除笔内的历史数据
  3876. //APP.digitalPen.ClearMemory(penSerial);
  3877. //开始接收笔数据
  3878. APP.digitalPen.GetPenData(penSerial);
  3879. Dispatcher.Invoke(new Action(() =>
  3880. {
  3881. txbNotConnected.Text = "已连接";
  3882. txbNotConnecteds.Text = "已连接";
  3883. }));
  3884. }
  3885. }
  3886. /// <summary>
  3887. /// 电池电量
  3888. /// </summary>
  3889. /// <param name="time"></param>
  3890. /// <param name="penSerial"></param>
  3891. /// <param name="penType"></param>
  3892. /// <param name="capacity"></param>
  3893. private void OnBatteryCapacity(ulong time, string penSerial, int penType, byte capacity)
  3894. {
  3895. if (CheckAccess())
  3896. {
  3897. Action<ulong, string, int, byte> action = new Action<ulong, string, int, byte>(OnBatteryCapacity);
  3898. Dispatcher.Invoke(action, new object[] { time, penSerial, penType, capacity });
  3899. }
  3900. else
  3901. {
  3902. //System.Windows.MessageWindow.Show("电池电量:" + capacity.ToString());
  3903. }
  3904. }
  3905. /// <summary>
  3906. /// 已用存储
  3907. /// </summary>
  3908. /// <param name="time"></param>
  3909. /// <param name="penSerial"></param>
  3910. /// <param name="penType"></param>
  3911. /// <param name="fillLevel"></param>
  3912. private void OnMemoryFillLevel(ulong time, string penSerial, int penType, byte fillLevel)
  3913. {
  3914. if (CheckAccess())
  3915. {
  3916. Action<ulong, string, int, byte> action = new Action<ulong, string, int, byte>(OnMemoryFillLevel);
  3917. Dispatcher.Invoke(action, new object[] { time, penSerial, penType, fillLevel });
  3918. }
  3919. else
  3920. {
  3921. //System.Windows.MessageWindow.Show("存储:" + fillLevel.ToString());
  3922. }
  3923. }
  3924. /// <summary>
  3925. /// 笔书写,收到坐标
  3926. /// </summary>
  3927. /// <param name="time">时间戳,1970年1月1日到现在的总毫秒数</param>
  3928. /// <param name="penSerial">点阵笔序列号</param>
  3929. /// <param name="penType">点阵笔型号编号</param>
  3930. /// <param name="pageSerial">点阵地址</param>
  3931. /// <param name="cx">x坐标</param>
  3932. /// <param name="cy">y坐标</param>
  3933. /// <param name="force">压力值</param>
  3934. private void OnPenCoordinate(ulong time, string penSerial, int penType, string pageSerial, int cx, int cy, byte force)
  3935. {
  3936. if (CheckAccess())
  3937. {
  3938. Action<ulong, string, int, string, int, int, byte> ac = new Action<ulong, string, int, string, int, int, byte>(OnPenCoordinate);
  3939. Dispatcher.Invoke(ac, new object[] { time, pageSerial, penType, pageSerial, cx, cy, force });
  3940. }
  3941. else
  3942. {
  3943. //判断是否是落笔后输出的坐标,在设置悬浮模式下,落笔前的悬浮坐标不绘制
  3944. if (!isPenDown)
  3945. {
  3946. return;
  3947. }
  3948. stroke.Add(new System.Drawing.Point(cx, cy));
  3949. double PropW = blackboard_canvas.ActualWidth / A4_WIDTH;
  3950. double PropH = blackboard_canvas.ActualHeight / A4_HEIGHT;
  3951. //点
  3952. double testX = cx * PropW;
  3953. double testY = cy * PropH;
  3954. //pageSerial //点阵IP地址 与打印的页面关联
  3955. if (APP.pageData.currpage > 0)
  3956. {
  3957. Dispatcher.Invoke(new Action(() =>
  3958. {
  3959. //myblackboard.changepages(testX, testY,false);
  3960. myblackboard.changepages(testX, testY, false, Color, PenSize, APP.pageData.currpage - 1);
  3961. #region 设置滚动条位置
  3962. //点在显示页面上方
  3963. if (testY < scroMain.VerticalOffset)
  3964. {
  3965. //滚动条当前位置
  3966. double RollCurrentLocation = scroMain.VerticalOffset;
  3967. //向上滚动至以点为中心需要滚动的距离
  3968. double UpRoll = (RollCurrentLocation - testY) + (scroMain.ActualHeight / 2);
  3969. //如果小于0则等于0
  3970. double RollLocation = RollCurrentLocation - UpRoll;
  3971. if (RollLocation < 0)
  3972. {
  3973. RollLocation = 0;
  3974. }
  3975. ////滚动条实际偏移量
  3976. //double RollOffset = RollCurrentLocation - RollLocation;
  3977. scroMain.ScrollToVerticalOffset(RollLocation);
  3978. }
  3979. //点在显示页面下方
  3980. if (testY > scroMain.VerticalOffset + scroMain.ActualHeight)
  3981. {
  3982. //滚动条当前位置
  3983. double RollCurrentLocation = scroMain.VerticalOffset;
  3984. //向下滚动至以点为中心需要滚动的距离
  3985. double DownRoll = (testY - RollCurrentLocation) - (scroMain.ActualHeight / 2);
  3986. //如果小于0则等于0
  3987. double RollLocation = RollCurrentLocation + DownRoll;
  3988. //滚动条最大滚动值
  3989. double ScrollbarMaxNum = gridM.ActualHeight - scroMain.ActualHeight;
  3990. if (RollLocation > ScrollbarMaxNum)
  3991. {
  3992. RollLocation = ScrollbarMaxNum;
  3993. }
  3994. ////滚动条实际偏移量
  3995. //double RollOffset = RollLocation-RollCurrentLocation;
  3996. scroMain.ScrollToVerticalOffset(RollLocation);
  3997. }
  3998. #endregion
  3999. //gridM.Height //A4高度
  4000. //scroMain.VerticalOffset;//获取滚动条位置
  4001. //scroMain.ActualHeight//A4纸显示高度
  4002. //scroMain.ScrollToHorizontalOffset()//设置滚动条位置
  4003. //Mouse.GetPosition(this)
  4004. if (testX > 0 && testY > 0)
  4005. {
  4006. //System.Windows.Point getP = blackboard_canvas.PointToScreen(new System.Windows.Point(testX, testY));
  4007. System.Windows.Point getP = scroMain.PointToScreen(new System.Windows.Point(testX, testY - scroMain.VerticalOffset));
  4008. SetCursorPos((int)getP.X, (int)getP.Y);
  4009. }
  4010. }));
  4011. }
  4012. ////每3个点画一条曲线
  4013. //if (stroke.Count % 3 == 0)
  4014. //{
  4015. // int from = stroke.Count - 3 - 1;
  4016. // if (from < 0)
  4017. // from = 0;
  4018. // int to = stroke.Count - 1;
  4019. // DrawCoordinates(from, to);
  4020. //}
  4021. }
  4022. }
  4023. /// <summary>
  4024. /// 停止笔
  4025. /// </summary>
  4026. public void StopDigitalPen()
  4027. {
  4028. //停止,释放资源
  4029. APP.digitalPen.Stop();
  4030. }
  4031. /// <summary>
  4032. /// 清空笔内存储
  4033. /// </summary>
  4034. public void ClearPenStorage()
  4035. {
  4036. if (!string.IsNullOrEmpty(penSerial))
  4037. {
  4038. APP.digitalPen.ClearMemory(penSerial);
  4039. }
  4040. }
  4041. /// <summary>
  4042. /// 获取剩余电量
  4043. /// </summary>
  4044. public void GetPenElectricityQuantity()
  4045. {
  4046. if (!string.IsNullOrEmpty(penSerial))
  4047. {
  4048. APP.digitalPen.GetBatteryCapacity(penSerial);
  4049. }
  4050. }
  4051. /// <summary>
  4052. /// 获取存储空间
  4053. /// </summary>
  4054. public void GetUsedStorage()
  4055. {
  4056. if (!string.IsNullOrEmpty(penSerial))
  4057. {
  4058. APP.digitalPen.GetMemoryFillLevel(penSerial);
  4059. }
  4060. }
  4061. /// <summary>
  4062. /// 开启悬浮
  4063. /// </summary>
  4064. public void 开启悬浮()
  4065. {
  4066. if (!string.IsNullOrEmpty(penSerial))
  4067. {
  4068. APP.digitalPen.SetPenHoverMode(true, penSerial);
  4069. }
  4070. }
  4071. /// <summary>
  4072. /// 关闭悬浮
  4073. /// </summary>
  4074. public void 关闭悬浮()
  4075. {
  4076. if (!string.IsNullOrEmpty(penSerial))
  4077. {
  4078. APP.digitalPen.SetPenHoverMode(false, penSerial);
  4079. }
  4080. }
  4081. #endregion
  4082. /// <summary>
  4083. /// 最小化
  4084. /// </summary>
  4085. /// <param name="sender"></param>
  4086. /// <param name="e"></param>
  4087. private void BtnShrink_Click(object sender, RoutedEventArgs e)
  4088. {
  4089. if (WindowState == WindowState.Minimized)
  4090. {
  4091. WindowState = WindowState.Normal;
  4092. }
  4093. else
  4094. {
  4095. WindowState = WindowState.Minimized;
  4096. }
  4097. }
  4098. /// <summary>
  4099. /// 位置确定
  4100. /// </summary>
  4101. /// <param name="sender"></param>
  4102. /// <param name="e"></param>
  4103. private void BtnOk_Click(object sender, RoutedEventArgs e)
  4104. {
  4105. //APP.PageDrawList[APP.pageData.currpage - 1].IsImageLocation = true;
  4106. //btnOk.Visibility = Visibility.Collapsed;
  4107. //blackboard_canvas.Visibility = Visibility.Visible;
  4108. }
  4109. /// <summary>
  4110. /// 引用user32.dll动态链接库(windows api),
  4111. /// 使用库中定义 API:SetCursorPos
  4112. /// 设置光标位置
  4113. /// </summary>
  4114. [System.Runtime.InteropServices.DllImport("user32.dll")]
  4115. private static extern int SetCursorPos(int x, int y);
  4116. #region 图片拉伸移动
  4117. private System.Windows.Point initialPoint;
  4118. /// <summary>
  4119. /// 隐藏图片四个点和线
  4120. /// </summary>
  4121. private void HideAngleBorder()
  4122. {
  4123. RectLeftUp.Visibility = Visibility.Hidden;
  4124. RectRightUp.Visibility = Visibility.Hidden;
  4125. RectLeftDown.Visibility = Visibility.Hidden;
  4126. RectRightDown.Visibility = Visibility.Hidden;
  4127. RectImgBorder.Visibility = Visibility.Hidden;
  4128. }
  4129. private void ShowAngleBorder()
  4130. {
  4131. PointLocation();
  4132. RectLeftUp.Visibility = Visibility.Visible;
  4133. RectRightUp.Visibility = Visibility.Visible;
  4134. RectLeftDown.Visibility = Visibility.Visible;
  4135. RectRightDown.Visibility = Visibility.Visible;
  4136. RectImgBorder.Visibility = Visibility.Visible;
  4137. }
  4138. /// <summary>
  4139. /// 确定四个点和边框的位置大小
  4140. /// </summary>
  4141. private void PointLocation()
  4142. {
  4143. RectImgBorder.Width = imgCanvas.ActualWidth + 10.0;
  4144. RectImgBorder.Height = imgCanvas.ActualHeight + 10.0;
  4145. RectImgBorder.Margin = new Thickness(imgCanvas.Margin.Left - 5.0, imgCanvas.Margin.Top - 5.0, 0, 0);
  4146. Canvas.SetLeft(RectLeftUp, imgCanvas.Margin.Left - 10.0);
  4147. Canvas.SetTop(RectLeftUp, imgCanvas.Margin.Top - 10.0);
  4148. Canvas.SetLeft(RectRightUp, imgCanvas.Margin.Left + imgCanvas.ActualWidth - 10.0);
  4149. Canvas.SetTop(RectRightUp, imgCanvas.Margin.Top - 10.0);
  4150. Canvas.SetLeft(RectLeftDown, imgCanvas.Margin.Left - 10.0);
  4151. Canvas.SetTop(RectLeftDown, imgCanvas.Margin.Top + imgCanvas.ActualHeight - 10.0);
  4152. Canvas.SetLeft(RectRightDown, imgCanvas.Margin.Left + imgCanvas.ActualWidth - 10.0);
  4153. Canvas.SetTop(RectRightDown, imgCanvas.Margin.Top + imgCanvas.ActualHeight - 10.0);
  4154. }
  4155. private void PicEMap_MouseDown(object sender, MouseButtonEventArgs e)
  4156. {
  4157. System.Windows.Point point = e.GetPosition(imgCanvas);
  4158. initialPoint = point;
  4159. //Console.WriteLine("PicEmap.X = " + point.X + "; PicEmap.Y = " + point.Y);
  4160. //if ((point.X - 304) * (point.X - 304) + (point.Y - 86) * (point.Y - 86) < 100)
  4161. //{
  4162. // Console.WriteLine("在范围内");
  4163. //}
  4164. HideAngleBorder();
  4165. }
  4166. private void imgCanvas_MouseMove(object sender, System.Windows.Input.MouseEventArgs e)
  4167. {
  4168. if (e.LeftButton == MouseButtonState.Pressed && mouseDown)
  4169. {
  4170. System.Windows.Point point = e.GetPosition(imgCanvas);
  4171. imgCanvas.Margin = new Thickness(imgCanvas.Margin.Left + (point.X - initialPoint.X), imgCanvas.Margin.Top + (point.Y - initialPoint.Y), 0, 0);
  4172. APP.PageDrawList[APP.pageData.currpage - 1].ImageLocation = new TranslateTransform
  4173. {
  4174. X = imgCanvas.Margin.Left,
  4175. Y = imgCanvas.Margin.Top
  4176. };
  4177. APP.PageDrawList[APP.pageData.currpage - 1].ImageSizes = new ScaleTransform
  4178. {
  4179. CenterX = imgCanvas.ActualWidth,
  4180. CenterY = imgCanvas.ActualHeight
  4181. };
  4182. APP.PageDrawList[APP.pageData.currpage - 1].IsImageLocation = false;
  4183. }
  4184. }
  4185. private void imgCanvas_MouseUp(object sender, MouseButtonEventArgs e)
  4186. {
  4187. if (mouseDown)
  4188. {
  4189. ShowAngleBorder();
  4190. }
  4191. }
  4192. private System.Drawing.PointF imgRightDown;
  4193. /// <summary>
  4194. /// 设置控件最上层
  4195. /// </summary>
  4196. /// <param name="element"></param>
  4197. public void BringToFront(Thumb element)//图片置于最顶层显示
  4198. {
  4199. if (element == null)
  4200. {
  4201. return;
  4202. }
  4203. Canvas parent = element.Parent as Canvas;
  4204. if (parent == null)
  4205. {
  4206. return;
  4207. }
  4208. int maxZ = parent.Children.OfType<UIElement>()//linq语句,取Zindex的最大值
  4209. .Where(x => x != element)
  4210. .Select(x => Canvas.GetZIndex(x))
  4211. .Max();
  4212. Canvas.SetZIndex(element, maxZ + 1);
  4213. }
  4214. private void RectRightUp_DragStarted(object sender, System.Windows.Controls.Primitives.DragStartedEventArgs e)
  4215. {
  4216. try
  4217. {
  4218. Thumb thu = (Thumb)sender;
  4219. BringToFront(thu);
  4220. imgRightDown = new System.Drawing.PointF((float)(imgCanvas.Margin.Left + imgCanvas.ActualWidth), (float)(imgCanvas.Margin.Top + imgCanvas.ActualHeight));
  4221. HideAngleBorder();
  4222. switch (thu.Name)
  4223. {
  4224. case "RectLeftUp":
  4225. RectLeftUp.Visibility = Visibility.Visible;
  4226. break;
  4227. case "RectRightUp":
  4228. RectRightUp.Visibility = Visibility.Visible;
  4229. break;
  4230. case "RectLeftDown":
  4231. RectLeftDown.Visibility = Visibility.Visible;
  4232. break;
  4233. case "RectRightDown":
  4234. RectRightDown.Visibility = Visibility.Visible;
  4235. break;
  4236. default:
  4237. break;
  4238. }
  4239. }
  4240. catch (Exception ex)
  4241. {
  4242. MessageWindow.Show(ex.Message);
  4243. }
  4244. }
  4245. private void RectRightUp_DragDelta(object sender, System.Windows.Controls.Primitives.DragDeltaEventArgs e)
  4246. {
  4247. try
  4248. {
  4249. if (mouseDown)
  4250. {
  4251. Thumb thu = (Thumb)sender;
  4252. #region 判断是否超出 暂无
  4253. double plul = Canvas.GetLeft(RectLeftUp);
  4254. double plut = Canvas.GetTop(RectLeftUp);
  4255. double prdl = Canvas.GetLeft(RectRightDown);
  4256. double prdt = Canvas.GetTop(RectRightDown);
  4257. #endregion
  4258. //Canvas.SetLeft(thu, Canvas.GetLeft(thu) + e.HorizontalChange);
  4259. //Canvas.SetTop(thu, Canvas.GetTop(thu) + e.VerticalChange);
  4260. double imgW = 0;
  4261. double imgH = 0;
  4262. double imgX = 0;
  4263. double imgY = 0;
  4264. switch (thu.Name)
  4265. {
  4266. case "RectLeftUp":
  4267. #region 左上
  4268. imgW = imgRightDown.X - (Mouse.GetPosition(gridM).X);
  4269. imgH = imgRightDown.Y - (Mouse.GetPosition(gridM).Y);
  4270. imgX = 0;
  4271. imgY = 0;
  4272. if (imgW < 50)
  4273. {
  4274. imgCanvas.Width = 50;
  4275. imgX = imgCanvas.Margin.Left;
  4276. Canvas.SetLeft(thu, Canvas.GetLeft(RectRightDown) - 50);
  4277. }
  4278. else
  4279. {
  4280. imgCanvas.Width = imgW;
  4281. imgX = Mouse.GetPosition(gridM).X;
  4282. Canvas.SetLeft(thu, Canvas.GetLeft(thu) + e.HorizontalChange);
  4283. }
  4284. if (imgH < 50)
  4285. {
  4286. imgCanvas.Height = 50;
  4287. imgY = imgCanvas.Margin.Top;
  4288. Canvas.SetTop(thu, Canvas.GetTop(RectRightDown) - 50);
  4289. }
  4290. else
  4291. {
  4292. imgCanvas.Height = imgH;
  4293. imgY = Mouse.GetPosition(gridM).Y;
  4294. Canvas.SetTop(thu, Canvas.GetTop(thu) + e.VerticalChange);
  4295. }
  4296. imgCanvas.Margin = new Thickness(imgX, imgY, 0, 0);
  4297. #endregion
  4298. //imgCanvas.Width = imgRightDown.X - (Mouse.GetPosition(gridM).X);
  4299. //imgCanvas.Height = imgRightDown.Y - (Mouse.GetPosition(gridM).Y);
  4300. //imgCanvas.Margin = new Thickness(Mouse.GetPosition(gridM).X, Mouse.GetPosition(gridM).Y, 0, 0);
  4301. break;
  4302. case "RectRightUp":
  4303. #region 右上
  4304. imgW = Mouse.GetPosition(gridM).X - imgCanvas.Margin.Left;
  4305. imgH = imgRightDown.Y - (Mouse.GetPosition(gridM).Y);
  4306. imgX = 0;
  4307. imgY = 0;
  4308. if (imgW < 50)
  4309. {
  4310. imgCanvas.Width = 50;
  4311. imgX = imgCanvas.Margin.Left;
  4312. Canvas.SetLeft(thu, Canvas.GetLeft(RectLeftUp) + 50);
  4313. }
  4314. else
  4315. {
  4316. imgCanvas.Width = imgW;
  4317. imgX = imgCanvas.Margin.Left;
  4318. Canvas.SetLeft(thu, Canvas.GetLeft(thu) + e.HorizontalChange);
  4319. }
  4320. if (imgH < 50)
  4321. {
  4322. imgCanvas.Height = 50;
  4323. imgY = imgCanvas.Margin.Top;
  4324. Canvas.SetTop(thu, Canvas.GetTop(RectRightDown) - 50);
  4325. }
  4326. else
  4327. {
  4328. imgCanvas.Height = imgH;
  4329. imgY = Mouse.GetPosition(gridM).Y;
  4330. Canvas.SetTop(thu, Canvas.GetTop(thu) + e.VerticalChange);
  4331. }
  4332. imgCanvas.Margin = new Thickness(imgX, imgY, 0, 0);
  4333. //imgCanvas.Width = Mouse.GetPosition(gridM).X - imgCanvas.Margin.Left;
  4334. //imgCanvas.Height = imgRightDown.Y - (Mouse.GetPosition(gridM).Y);
  4335. //imgCanvas.Margin = new Thickness(imgCanvas.Margin.Left, Mouse.GetPosition(gridM).Y, 0, 0);
  4336. #endregion
  4337. break;
  4338. case "RectLeftDown":
  4339. #region 左下
  4340. imgW = imgRightDown.X - (Mouse.GetPosition(gridM).X);
  4341. imgH = Mouse.GetPosition(gridM).Y - imgCanvas.Margin.Top;
  4342. imgX = 0;
  4343. imgY = 0;
  4344. if (imgW < 50)
  4345. {
  4346. imgCanvas.Width = 50;
  4347. imgX = imgCanvas.Margin.Left;
  4348. Canvas.SetLeft(thu, Canvas.GetLeft(RectRightDown) - 50);
  4349. }
  4350. else
  4351. {
  4352. imgCanvas.Width = imgW;
  4353. imgX = Mouse.GetPosition(gridM).X;
  4354. Canvas.SetLeft(thu, Canvas.GetLeft(thu) + e.HorizontalChange);
  4355. }
  4356. if (imgH < 50)
  4357. {
  4358. imgCanvas.Height = 50;
  4359. imgY = imgCanvas.Margin.Top;
  4360. Canvas.SetTop(thu, Canvas.GetTop(RectLeftUp) + 50);
  4361. }
  4362. else
  4363. {
  4364. imgCanvas.Height = imgH;
  4365. imgY = imgCanvas.Margin.Top;
  4366. Canvas.SetTop(thu, Canvas.GetTop(thu) + e.VerticalChange);
  4367. }
  4368. imgCanvas.Margin = new Thickness(imgX, imgY, 0, 0);
  4369. //imgCanvas.Width = imgRightDown.X - (Mouse.GetPosition(gridM).X);
  4370. //imgCanvas.Height = Mouse.GetPosition(gridM).Y - imgCanvas.Margin.Top;
  4371. //imgCanvas.Margin = new Thickness(Mouse.GetPosition(gridM).X, imgCanvas.Margin.Top, 0, 0);
  4372. #endregion
  4373. break;
  4374. case "RectRightDown":
  4375. #region 右下
  4376. imgW = Mouse.GetPosition(gridM).X - imgCanvas.Margin.Left;
  4377. imgH = Mouse.GetPosition(gridM).Y - imgCanvas.Margin.Top;
  4378. if (imgW < 50)
  4379. {
  4380. imgCanvas.Width = 50;
  4381. Canvas.SetLeft(thu, Canvas.GetLeft(RectLeftUp) + 50);
  4382. }
  4383. else
  4384. {
  4385. imgCanvas.Width = imgW;
  4386. Canvas.SetLeft(thu, Canvas.GetLeft(thu) + e.HorizontalChange);
  4387. }
  4388. if (imgH < 50)
  4389. {
  4390. imgCanvas.Height = 50;
  4391. Canvas.SetTop(thu, Canvas.GetTop(RectLeftUp) + 50);
  4392. }
  4393. else
  4394. {
  4395. imgCanvas.Height = imgH;
  4396. Canvas.SetTop(thu, Canvas.GetTop(thu) + e.VerticalChange);
  4397. }
  4398. //imgCanvas.Margin = new Thickness(imgX, imgY, 0, 0);
  4399. //imgCanvas.Width += e.HorizontalChange;
  4400. //imgCanvas.Height += e.VerticalChange;
  4401. #endregion
  4402. break;
  4403. default:
  4404. break;
  4405. }
  4406. APP.PageDrawList[APP.pageData.currpage - 1].ImageLocation = new TranslateTransform
  4407. {
  4408. X = imgCanvas.Margin.Left,
  4409. Y = imgCanvas.Margin.Top
  4410. };
  4411. APP.PageDrawList[APP.pageData.currpage - 1].ImageSizes = new ScaleTransform
  4412. {
  4413. CenterX = imgCanvas.ActualWidth,
  4414. CenterY = imgCanvas.ActualHeight
  4415. };
  4416. APP.PageDrawList[APP.pageData.currpage - 1].IsImageLocation = false;
  4417. }
  4418. //lbl1.Content = imgCanvas.Margin.Left + "," + imgCanvas.Margin.Top;
  4419. //lbl2.Content = (imgCanvas.Margin.Left+ imgCanvas.Width) +"," + imgCanvas.Margin.Top;
  4420. //lbl3.Content = imgCanvas.Margin.Left + "," + (imgCanvas.Margin.Top+ imgCanvas.Height);
  4421. //lbl4.Content= (imgCanvas.Margin.Left + imgCanvas.Width )+ "," + (imgCanvas.Margin.Top + imgCanvas.Height);
  4422. }
  4423. catch (Exception)
  4424. {
  4425. MessageWindow.Show("图片过小!");
  4426. }
  4427. }
  4428. private void RectRightUp_DragCompleted(object sender, System.Windows.Controls.Primitives.DragCompletedEventArgs e)
  4429. {
  4430. ShowAngleBorder();
  4431. }
  4432. #endregion
  4433. #region 方法
  4434. /// <summary>
  4435. /// 录屏 录制 截图 导入文档 增加 主页面显示
  4436. /// </summary>
  4437. private void Record()
  4438. {
  4439. GridMain.Visibility = Visibility.Visible;
  4440. gridSetUp.Visibility = Visibility.Collapsed;
  4441. //gridUpload.Visibility = Visibility.Collapsed;
  4442. GridMyVideo.Visibility = Visibility.Collapsed;
  4443. if (APP.pageData.pagenum > 0)
  4444. {
  4445. gridPage.Visibility = Visibility.Visible;
  4446. }
  4447. DataContext = APP.pageData;
  4448. }
  4449. /// <summary>
  4450. /// 设置页面显示
  4451. /// </summary>
  4452. private void SetUp()
  4453. {
  4454. }
  4455. #endregion
  4456. private void imgCanvas_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
  4457. {
  4458. mouseDown = true;
  4459. }
  4460. private void Button_Click(object sender, RoutedEventArgs e)
  4461. {
  4462. System.Drawing.Size a = PrimaryScreen.DESKTOP;
  4463. System.Drawing.Size b = PrimaryScreen.WorkingArea;
  4464. int c = PrimaryScreen.DpiX;
  4465. int d = PrimaryScreen.DpiY;
  4466. float x = PrimaryScreen.ScaleX;
  4467. float y = PrimaryScreen.ScaleY;
  4468. }
  4469. /// <summary>
  4470. /// 点击标题栏 隐藏截图的四个点和线
  4471. /// </summary>
  4472. /// <param name="sender"></param>
  4473. /// <param name="e"></param>
  4474. private void Grid_MouseDown(object sender, MouseButtonEventArgs e)
  4475. {
  4476. HideAngleBorder();
  4477. }
  4478. /// <summary>
  4479. /// 鼠标左键点击事件
  4480. /// </summary>
  4481. /// <param name="sender"></param>
  4482. /// <param name="e"></param>
  4483. private void Window_MouseLeftButtonDown_1(object sender, MouseButtonEventArgs e)
  4484. {
  4485. if (RectImgBorder.Visibility != Visibility.Hidden)
  4486. {
  4487. HideAngleBorder();
  4488. }
  4489. }
  4490. }
  4491. }