星火微课系统客户端
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.

MainWindow.xaml.cs 153KB

4 yıl önce
4 yıl önce
4 yıl önce
4 yıl önce
1 yıl önce
4 yıl önce
4 yıl önce
4 yıl önce
1 yıl önce
4 yıl önce
3 yıl önce
3 yıl önce
3 yıl önce
3 yıl önce
3 yıl önce
3 yıl önce
1 yıl önce
3 yıl önce
4 yıl önce
4 yıl önce
1 yıl önce
3 yıl önce
4 yıl önce
3 yıl önce
4 yıl önce
4 yıl önce
3 yıl önce
3 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
3 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
4 yıl önce
3 yıl önce
4 yıl önce
4 yıl önce
3 yıl önce
4 yıl önce
3 yıl önce
3 yıl önce
3 yıl önce
1 yıl önce
1 yıl önce
3 yıl önce
4 yıl önce
3 yıl önce
4 yıl önce
4 yıl önce
4 yıl önce
4 yıl önce
1 yıl önce
4 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
3 yıl önce
4 yıl önce
3 yıl önce
4 yıl önce
4 yıl önce
4 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
4 yıl önce
3 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
4 yıl önce
3 yıl önce
3 yıl önce
4 yıl önce
4 yıl önce
4 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
4 yıl önce
1 yıl önce
1 yıl önce
4 yıl önce
1 yıl önce
3 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
4 yıl önce
3 yıl önce
4 yıl önce
4 yıl önce
4 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
3 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
3 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
4 yıl önce
4 yıl önce
1 yıl önce
3 yıl önce
3 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
3 yıl önce
1 yıl önce
3 yıl önce
1 yıl önce
3 yıl önce
4 yıl önce
1 yıl önce
3 yıl önce
1 yıl önce
3 yıl önce
1 yıl önce
3 yıl önce
1 yıl önce
3 yıl önce
3 yıl önce
3 yıl önce
1 yıl önce
3 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
3 yıl önce
4 yıl önce
4 yıl önce
4 yıl önce
4 yıl önce
4 yıl önce
4 yıl önce
3 yıl önce
4 yıl önce
4 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
4 yıl önce
4 yıl önce
4 yıl önce
4 yıl önce
3 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
3 yıl önce
1 yıl önce
1 yıl önce
3 yıl önce
1 yıl önce
1 yıl önce
3 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
3 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
4 yıl önce
4 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
4 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
4 yıl önce
1 yıl önce
4 yıl önce
3 yıl önce
1 yıl önce
3 yıl önce
1 yıl önce
4 yıl önce
4 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
4 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
3 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
3 yıl önce
3 yıl önce
3 yıl önce
3 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
3 yıl önce
1 yıl önce
4 yıl önce
4 yıl önce
4 yıl önce
1 yıl önce
3 yıl önce
4 yıl önce
3 yıl önce
1 yıl önce
1 yıl önce
4 yıl önce
1 yıl önce
1 yıl önce
3 yıl önce
3 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
3 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
3 yıl önce
3 yıl önce
1 yıl önce
1 yıl önce
3 yıl önce
1 yıl önce
1 yıl önce
3 yıl önce
3 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
3 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
3 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
3 yıl önce
1 yıl önce
3 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
3 yıl önce
3 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
3 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
3 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
3 yıl önce
3 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
3 yıl önce
3 yıl önce
1 yıl önce
1 yıl önce
3 yıl önce
1 yıl önce
3 yıl önce
3 yıl önce
1 yıl önce
3 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
3 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
3 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
3 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
3 yıl önce
3 yıl önce
3 yıl önce
3 yıl önce
3 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
3 yıl önce
3 yıl önce
3 yıl önce
3 yıl önce
3 yıl önce
3 yıl önce
3 yıl önce
1 yıl önce
1 yıl önce
3 yıl önce
1 yıl önce
3 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
3 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
3 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
3 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
1 yıl önce
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149
  1. using Accord.Video.FFMPEG;
  2. using Aspose.Slides;
  3. using ComeCapture;
  4. using Common.system;
  5. using NAudio.Wave;
  6. using NReco.VideoConverter;
  7. using System;
  8. using System.Collections.Generic;
  9. using System.Diagnostics;
  10. using System.Drawing;
  11. using System.IO;
  12. using System.Linq;
  13. using System.Threading;
  14. using System.Threading.Tasks;
  15. using System.Windows;
  16. using System.Windows.Ink;
  17. using System.Windows.Input;
  18. using System.Windows.Media;
  19. using System.Windows.Media.Imaging;
  20. using TmatrixLibrary;
  21. using XHWK.Model;
  22. using XHWK.WKTool.Models;
  23. using XHWK.WKTool.Skin;
  24. using XHWK.WKTool.UControl;
  25. using XHWK.WKTool.Utils;
  26. using XHWK.WKTool.Utils.luobo;
  27. using XHWK.WKTool.Utils.pen;
  28. namespace XHWK.WKTool
  29. {
  30. using System.Globalization;
  31. using system;
  32. /// <summary>
  33. /// 主页面
  34. /// </summary>
  35. public partial class MainWindow : PenEventI
  36. {
  37. #region 字段
  38. public BlackboardNew myblackboard;
  39. /// <summary>
  40. /// 当前颜色
  41. /// </summary>
  42. private System.Windows.Media.Color _color = Colors.Red;
  43. //声明一个 DrawingAttributes 类型的变量
  44. private DrawingAttributes _drawingAttributes;
  45. /// <summary>
  46. /// 键盘钩子
  47. /// </summary>
  48. private KeyboardHookCommon _kHook;
  49. private System.Windows.Forms.OpenFileDialog _ofd;
  50. private System.Windows.Forms.FolderBrowserDialog _fbd;
  51. /// <summary>
  52. /// 笔迹粗细
  53. /// </summary>
  54. private int _penSize = 2;
  55. private System.Windows.Forms.DialogResult _result;
  56. private System.Windows.Forms.DialogResult _result2;
  57. private Model_Video _videoInfo;
  58. //定义委托
  59. public delegate void ChangeTextHandler(string text);
  60. //定义委托
  61. public delegate void ChangeTextHandlers(string text, int i);
  62. #region 上传
  63. /// <summary>
  64. /// 视频模型
  65. /// </summary>
  66. private List<Model_Video> _modelVideoList;
  67. #endregion 上传
  68. #endregion 字段
  69. #region 初始化
  70. private readonly ImageOperationUtil _imageOperationUtil;
  71. private readonly LuoBoPenUtil _luoBoPenUtil;
  72. /// <summary>
  73. /// 主页面
  74. /// </summary>
  75. public MainWindow()
  76. {
  77. InitializeComponent();
  78. #region 调整文字大小
  79. App.PageContextData.WordSize20 = 20.00;
  80. App.PageContextData.WordSize18 = 18.00;
  81. App.PageContextData.WordSize16 = 16.00;
  82. App.PageContextData.WordSize14 = 14.00;
  83. App.PageContextData.WordSize12 = 12.00;
  84. #endregion 调整文字大小
  85. ResizeMode = ResizeMode.CanMinimize;
  86. BtnPrint.IsEnabled = false;
  87. myblackboard = new BlackboardNew(BlackboardCanvas);
  88. App.PageContextData.pagenum = 0;
  89. App.PageContextData.currpage = 0;
  90. DataContext = App.PageContextData;
  91. //APP.SaveDraw();//画板模型第一页初始化
  92. App.PageDrawList = new List<Model_DrawData>();
  93. Model_DrawData modelDrawData = new Model_DrawData { PageNum = App.PageContextData.currpage };
  94. App.PageDrawList.Add(modelDrawData);
  95. Txbv.Text = (App.isDebug ? "测试版" : "正式版") + " v" + FileToolsCommon.GetConfigValue("VersionName");
  96. TxbStoragePath.Content = FileToolsCommon.GetConfigValue("VideoType");
  97. TxbStoragePath.Content = FileToolsCommon.GetConfigValue("VideoSavePath");
  98. Initialize();
  99. //罗博手写板
  100. _luoBoPenUtil = new LuoBoPenUtil(this);
  101. _luoBoPenUtil.InitlbPen();
  102. //腾千里
  103. InitTqlpPen();
  104. SkinSelectInit();
  105. byte[] license = Convert.FromBase64String
  106. (
  107. "PExpY2Vuc2U+CiAgPERhdGE+CiAgICA8TGljZW5zZWRUbz5TdXpob3UgQXVuYm94IFNvZnR3YXJlIENvLiwgTHRkLjwvTGljZW5zZWRUbz4KICAgIDxFbWFpbFRvPnNhbGVzQGF1bnRlYy5jb208L0VtYWlsVG8+CiAgICA8TGljZW5zZVR5cGU+RGV2ZWxvcGVyIE9FTTwvTGljZW5zZVR5cGU+CiAgICA8TGljZW5zZU5vdGU+TGltaXRlZCB0byAxIGRldmVsb3BlciwgdW5saW1pdGVkIHBoeXNpY2FsIGxvY2F0aW9uczwvTGljZW5zZU5vdGU+CiAgICA8T3JkZXJJRD4xOTA4MjYwODA3NTM8L09yZGVySUQ+CiAgICA8VXNlcklEPjEzNDk3NjAwNjwvVXNlcklEPgogICAgPE9FTT5UaGlzIGlzIGEgcmVkaXN0cmlidXRhYmxlIGxpY2Vuc2U8L09FTT4KICAgIDxQcm9kdWN0cz4KICAgICAgPFByb2R1Y3Q+QXNwb3NlLlRvdGFsIGZvciAuTkVUPC9Qcm9kdWN0PgogICAgPC9Qcm9kdWN0cz4KICAgIDxFZGl0aW9uVHlwZT5FbnRlcnByaXNlPC9FZGl0aW9uVHlwZT4KICAgIDxTZXJpYWxOdW1iZXI+M2U0NGRlMzAtZmNkMi00MTA2LWIzNWQtNDZjNmEzNzE1ZmMyPC9TZXJpYWxOdW1iZXI+CiAgICA8U3Vic2NyaXB0aW9uRXhwaXJ5PjIwMjAwODI3PC9TdWJzY3JpcHRpb25FeHBpcnk+CiAgICA8TGljZW5zZVZlcnNpb24+My4wPC9MaWNlbnNlVmVyc2lvbj4KICAgIDxMaWNlbnNlSW5zdHJ1Y3Rpb25zPmh0dHBzOi8vcHVyY2hhc2UuYXNwb3NlLmNvbS9wb2xpY2llcy91c2UtbGljZW5zZTwvTGljZW5zZUluc3RydWN0aW9ucz4KICA8L0RhdGE+CiAgPFNpZ25hdHVyZT53UGJtNUt3ZTYvRFZXWFNIY1o4d2FiVEFQQXlSR0pEOGI3L00zVkV4YWZpQnd5U2h3YWtrNGI5N2c2eGtnTjhtbUFGY3J0c0cwd1ZDcnp6MytVYk9iQjRYUndTZWxsTFdXeXNDL0haTDNpN01SMC9jZUFxaVZFOU0rWndOQkR4RnlRbE9uYTFQajhQMzhzR1grQ3ZsemJLZFZPZXk1S3A2dDN5c0dqYWtaL1E9PC9TaWduYXR1cmU+CjwvTGljZW5zZT4="
  108. );
  109. new Aspose.Words.License().SetLicense(new MemoryStream(license));
  110. new Aspose.Pdf.License().SetLicense(new MemoryStream(license));
  111. new Aspose.Slides.License().SetLicense(new MemoryStream(license));
  112. _imageOperationUtil = new ImageOperationUtil
  113. (
  114. RectLeftUp,
  115. RectRightUp,
  116. RectLeftDown,
  117. RectRightDown,
  118. RectImgBorder,
  119. ImgCanvas,
  120. GridM
  121. );
  122. InitPrint();
  123. }
  124. private void LoadImage(BitmapImage image)
  125. {
  126. HeadImg.Source = image;
  127. try
  128. {
  129. switch (App.CameraPosition)
  130. {
  131. case "1":
  132. HeadImg.HorizontalAlignment = HorizontalAlignment.Right;
  133. HeadImg.VerticalAlignment = VerticalAlignment.Top;
  134. break;
  135. case "2":
  136. HeadImg.HorizontalAlignment = HorizontalAlignment.Left;
  137. HeadImg.VerticalAlignment = VerticalAlignment.Top;
  138. break;
  139. case "3":
  140. HeadImg.HorizontalAlignment = HorizontalAlignment.Right;
  141. HeadImg.VerticalAlignment = VerticalAlignment.Bottom;
  142. break;
  143. case "4":
  144. HeadImg.HorizontalAlignment = HorizontalAlignment.Left;
  145. HeadImg.VerticalAlignment = VerticalAlignment.Bottom;
  146. break;
  147. }
  148. }
  149. catch (Exception)
  150. {
  151. // ignored
  152. }
  153. }
  154. /// <summary>
  155. /// 初始化
  156. /// </summary>
  157. public void Initialize()
  158. {
  159. #region 数据初始化
  160. string pathTemp = AppDomain.CurrentDomain.BaseDirectory + "Temp\\";
  161. FileToolsCommon.CreateDirectory(pathTemp);
  162. App.PageContextData.pagenum = 0;
  163. App.PageContextData.currpage = App.PageContextData.pagenum;
  164. BtnStop.IsEnabled = false; //停止录制按钮不可点击
  165. #endregion 数据初始化
  166. _kHook = new KeyboardHookCommon();
  167. _kHook.KeyDownEvent += K_hook_KeyDownEvent;
  168. _kHook.Start(); //安装键盘钩子
  169. App.CameraPosition = FileToolsCommon.GetConfigValue("CameraPosition");
  170. //创建 DrawingAttributes 类的一个实例
  171. _drawingAttributes = new DrawingAttributes();
  172. //将 InkCanvas 的 DefaultDrawingAttributes 属性的值赋成创建的 DrawingAttributes 类的对象的引用
  173. //InkCanvas 通过 DefaultDrawingAttributes 属性来获取墨迹的各种设置,该属性的类型为 DrawingAttributes 型
  174. BlackboardCanvas.DefaultDrawingAttributes = _drawingAttributes;
  175. BlackboardCanvas.UseCustomCursor = true;
  176. _drawingAttributes.FitToCurve = true;
  177. _drawingAttributes.IgnorePressure = false;
  178. _drawingAttributes.Width = _penSize;
  179. _drawingAttributes.Height = _penSize;
  180. _drawingAttributes.Color = _color;
  181. BlackboardCanvas.Cursor = Cursors.Pen;
  182. }
  183. /// <summary>
  184. /// 初始化快捷键
  185. /// </summary>
  186. public void InitializeKeyDownEvent()
  187. {
  188. _kHook.Start(); //安装键盘钩子
  189. }
  190. /// <summary>
  191. /// 引用user32.dll动态链接库(windows api), 使用库中定义 API:SetCursorPos 设置光标位置
  192. /// </summary>
  193. [System.Runtime.InteropServices.DllImport("user32.dll")]
  194. private static extern int SetCursorPos(int x, int y);
  195. /// <summary>
  196. /// 快捷键
  197. /// </summary>
  198. /// <param name="sender">
  199. /// </param>
  200. /// <param name="e">
  201. /// </param>
  202. private void K_hook_KeyDownEvent(object sender, System.Windows.Forms.KeyEventArgs e)
  203. {
  204. if (e.KeyValue == (int)System.Windows.Forms.Keys.Left)
  205. {
  206. if (App.PageContextData.currpage > 1)
  207. {
  208. //上一页
  209. last_button_Click(null, null);
  210. }
  211. }
  212. if (e.KeyValue == (int)System.Windows.Forms.Keys.Right)
  213. {
  214. if (App.PageContextData.currpage < App.PageContextData.pagenum)
  215. {
  216. //下一页
  217. next_btn_Click(null, null);
  218. }
  219. }
  220. if (e.KeyValue == (int)System.Windows.Forms.Keys.Delete)
  221. {
  222. if (RectImgBorder.Visibility != Visibility.Hidden)
  223. {
  224. HideAngleBorder();
  225. ImgCanvas.Source = null;
  226. App.PageDrawList[App.PageContextData.currpage - 1].PdfImagePath = null;
  227. App.PageDrawList[App.PageContextData.currpage - 1].PageImagePath = null;
  228. }
  229. }
  230. }
  231. /// <summary>
  232. /// 加载完成后调整录制区域大小
  233. /// </summary>
  234. /// <param name="sender">
  235. /// </param>
  236. /// <param name="e">
  237. /// </param>
  238. private async void Window_Loaded(object sender, RoutedEventArgs e)
  239. {
  240. //调整录制区域宽高
  241. double proportion = 210.0 / 297.0;
  242. GridM.Height = GridM.ActualWidth / proportion;
  243. await CheckDevice();
  244. }
  245. private bool _microphoneGood;
  246. private bool _loudspeakerGood;
  247. private async Task CheckDevice()
  248. {
  249. Task<bool> checkMicrophone = Task.Run(() => ZAudioRecordHelper.IsDeviceGood(ZAudioRecordHelper.RecordType.microphone));
  250. Task<bool> checkLoudspeaker = Task.Run(() => ZAudioRecordHelper.IsDeviceGood(ZAudioRecordHelper.RecordType.loudspeaker));
  251. await Task.WhenAll(checkMicrophone, checkLoudspeaker);
  252. _microphoneGood = checkMicrophone.Result;
  253. _loudspeakerGood = checkMicrophone.Result;
  254. }
  255. #endregion 初始化
  256. #region 事件
  257. #region 登录
  258. /// <summary>
  259. /// 登录事件
  260. /// </summary>
  261. /// <param name="sender">
  262. /// </param>
  263. /// <param name="e">
  264. /// </param>
  265. private void BtnLoginType_Click(object sender, RoutedEventArgs e)
  266. {
  267. if ("未登录".Equals(TxbLoginType.Text) || ImgHeadImgN.Visibility == Visibility.Visible)
  268. {
  269. Login();
  270. }
  271. else
  272. {
  273. MessageBoxResult dr = MessageWindow.Show
  274. (
  275. "确定退出登录?",
  276. "提示",
  277. MessageBoxButton.OKCancel
  278. );
  279. if (dr != MessageBoxResult.OK)
  280. {
  281. return;
  282. }
  283. LoginType();
  284. Login();
  285. }
  286. }
  287. /// <summary>
  288. /// 登录
  289. /// </summary>
  290. private void Login()
  291. {
  292. if (App.W_LoginWindow == null)
  293. {
  294. App.W_LoginWindow = new LoginWindow
  295. {
  296. WindowStartupLocation = WindowStartupLocation.CenterOwner,
  297. Owner = this
  298. };
  299. }
  300. else
  301. {
  302. App.W_LoginWindow.Initialize();
  303. }
  304. App.W_LoginWindow.ShowDialog();
  305. if (App.IsLoginType)
  306. {
  307. string headpicPath = FileToolsCommon.GetFileAbsolutePath("/Data/" + App.UserInfo.Username + ".png");
  308. if (FileToolsCommon.IsExistFile(headpicPath))
  309. {
  310. ImgHead.ImageSource = new BitmapImage(new Uri(headpicPath));
  311. }
  312. else
  313. {
  314. ImgHead.ImageSource = new BitmapImage(new Uri("pack://application:,,,/BlackImages/HM_HeadImg.png"));
  315. }
  316. TxbLoginType.Text = App.UserInfo.Username;
  317. ImgHeadImgN.Visibility = Visibility.Collapsed;
  318. ImgHeadImg.Visibility = Visibility.Visible;
  319. }
  320. else
  321. {
  322. TxbLoginType.Text = "未登录";
  323. ImgHeadImgN.Visibility = Visibility.Visible;
  324. ImgHeadImg.Visibility = Visibility.Collapsed;
  325. }
  326. }
  327. /// <summary>
  328. /// 状态更改为未登录
  329. /// </summary>
  330. private void LoginType()
  331. {
  332. App.IsLoginType = false;
  333. TxbLoginType.Text = "未登录";
  334. ImgHeadImgN.Visibility = Visibility.Visible;
  335. ImgHeadImg.Visibility = Visibility.Collapsed;
  336. App.UserInfo = new Model_UserInfo();
  337. }
  338. #endregion 登录
  339. #region 设置
  340. /// <summary>
  341. /// 设置 浏览事件
  342. /// </summary>
  343. /// <param name="sender">
  344. /// </param>
  345. /// <param name="e">
  346. /// </param>
  347. private void BtnBrowse_Click(object sender, RoutedEventArgs e)
  348. {
  349. _fbd = new System.Windows.Forms.FolderBrowserDialog();
  350. _result2 = _fbd.ShowDialog();
  351. if (_result2 != System.Windows.Forms.DialogResult.OK)
  352. {
  353. return;
  354. }
  355. if (_fbd.SelectedPath != "")
  356. {
  357. TxbStoragePath.Content = _fbd.SelectedPath;
  358. }
  359. }
  360. /// <summary>
  361. /// 打开文件所在位置
  362. /// </summary>
  363. /// <param name="sender">
  364. /// </param>
  365. /// <param name="e">
  366. /// </param>
  367. private void btnOpen_Click(object sender, RoutedEventArgs e)
  368. {
  369. Process.Start(App.WKData.WkPath);
  370. }
  371. /// <summary>
  372. /// 设置 保存事件
  373. /// </summary>
  374. /// <param name="sender">
  375. /// </param>
  376. /// <param name="e">
  377. /// </param>
  378. private void BtnSave_Click(object sender, RoutedEventArgs e)
  379. {
  380. try
  381. {
  382. BtnRecord.IsEnabled = true; //设置结束时可录制
  383. if (RbnMp4.IsChecked == true)
  384. {
  385. //存储文件
  386. FileToolsCommon.SetConfigValue("VideoType", "1");
  387. }
  388. else if (RbnFlv.IsChecked == true)
  389. {
  390. FileToolsCommon.SetConfigValue("VideoType", "2");
  391. }
  392. else
  393. {
  394. FileToolsCommon.SetConfigValue("VideoType", "3");
  395. }
  396. UpdateHideSrToolConfig();
  397. // < !--摄像头位置 1.右上 2.左上 3.右下 4.左下-- >
  398. if (RbnRight.IsChecked == true)
  399. {
  400. FileToolsCommon.SetConfigValue("CameraPosition", "1");
  401. }
  402. else if (RbnLeft.IsChecked == true)
  403. {
  404. FileToolsCommon.SetConfigValue("CameraPosition", "2");
  405. }
  406. else if (RbnRightUnder.IsChecked == true)
  407. {
  408. FileToolsCommon.SetConfigValue("CameraPosition", "3");
  409. }
  410. else if (RbnLeftUnder.IsChecked == true)
  411. {
  412. FileToolsCommon.SetConfigValue("CameraPosition", "4");
  413. }
  414. //格式
  415. if (RbnMp4.IsChecked == true)
  416. {
  417. FileToolsCommon.SetConfigValue("VideoType", "1");
  418. }
  419. else if (RbnFlv.IsChecked == true)
  420. {
  421. FileToolsCommon.SetConfigValue("VideoType", "2");
  422. }
  423. else if (RbnAvi.IsChecked == true)
  424. {
  425. FileToolsCommon.SetConfigValue("VideoType", "3");
  426. }
  427. App.CameraPosition = FileToolsCommon.GetConfigValue("CameraPosition");
  428. GridMain.Visibility = Visibility.Visible;
  429. GridM.IsEnabled = true;
  430. GridRecordingTitle.Visibility = Visibility.Visible;
  431. GridSetUp.Visibility = Visibility.Collapsed;
  432. HeadImg.Visibility = Visibility.Hidden;
  433. if (_isRbnOpen)
  434. {
  435. HeadImg.Visibility = Visibility.Visible;
  436. }
  437. if (!TxbStoragePath.Content.ToString().Equals(App.WKData.WkPath))
  438. {
  439. //存储文件
  440. FileToolsCommon.SetConfigValue("VideoSavePath", TxbStoragePath.Content.ToString());
  441. MessageWindow.Show("路径已变更,下次创建微课时自动生效。");
  442. }
  443. }
  444. catch (Exception ex)
  445. {
  446. LogHelper.WriteErrLog("XHMicroLessonSystemWindow(设置保存事件报错:)" + ex.Message, ex);
  447. }
  448. }
  449. /// <summary>
  450. /// 设置事件
  451. /// </summary>
  452. /// <param name="sender">
  453. /// </param>
  454. /// <param name="e">
  455. /// </param>
  456. private void BtnSetUp_Click(object sender, RoutedEventArgs e)
  457. {
  458. if (GridSetUp.Visibility == Visibility.Collapsed)
  459. {
  460. PageHide();
  461. GridSetUp.Visibility = Visibility.Visible;
  462. TxbStoragePath.Content = App.WKData.WkPath;
  463. #region 读取用户配置
  464. // < !--摄像头位置 1.右上 2.左上 3.右下 4.左下-- >
  465. if ("1".Equals(App.CameraPosition))
  466. {
  467. RbnRight.IsChecked = true;
  468. }
  469. else if ("2".Equals(App.CameraPosition))
  470. {
  471. RbnLeft.IsChecked = true;
  472. }
  473. else if ("3".Equals(App.CameraPosition))
  474. {
  475. RbnRightUnder.IsChecked = true;
  476. }
  477. else if ("4".Equals(App.CameraPosition))
  478. {
  479. RbnLeftUnder.IsChecked = true;
  480. }
  481. string type = FileToolsCommon.GetConfigValue("VideoType"); //<!--视频格式 1、MP4 2、FlV 3、AVI-->
  482. if ("1".Equals(type))
  483. {
  484. RbnMp4.IsChecked = true;
  485. }
  486. else if ("2".Equals(type))
  487. {
  488. RbnFlv.IsChecked = true;
  489. }
  490. else if ("3".Equals(type))
  491. {
  492. RbnAvi.IsChecked = true;
  493. }
  494. string isHide = FileToolsCommon.GetConfigValue("IsHideSRTool"); //工具栏是否隐藏
  495. if (isHide.Equals("1"))
  496. {
  497. RbnHide.IsChecked = true;
  498. }
  499. else
  500. {
  501. Rbnvisi.IsChecked = true;
  502. }
  503. //加载皮肤按钮
  504. SkinSelectInit();
  505. #endregion 读取用户配置
  506. }
  507. else
  508. {
  509. GridMain.Visibility = Visibility.Visible;
  510. GridM.IsEnabled = true;
  511. GridRecordingTitle.Visibility = Visibility.Visible;
  512. GridSetUp.Visibility = Visibility.Collapsed;
  513. }
  514. }
  515. /// <summary>
  516. /// 更新隐藏录屏工具栏隐藏状态
  517. /// </summary>
  518. private void UpdateHideSrToolConfig()
  519. {
  520. if (RbnHide.IsChecked == true)
  521. {
  522. //隐藏
  523. FileToolsCommon.SetConfigValue("IsHideSRTool", "1");
  524. App.IsHideSRTool = true;
  525. }
  526. else
  527. {
  528. //显示
  529. FileToolsCommon.SetConfigValue("IsHideSRTool", "0");
  530. App.IsHideSRTool = false;
  531. }
  532. }
  533. #region 切换皮肤
  534. /// <summary>
  535. /// 科技蓝
  536. /// </summary>
  537. /// <param name="sender">
  538. /// </param>
  539. /// <param name="e">
  540. /// </param>
  541. private void BtnSkinTechnologyBlue_Click(object sender, RoutedEventArgs e)
  542. {
  543. if (App.SkinStyle != "1")
  544. {
  545. HideSkinSelect();
  546. SkinSelectTechnologyBlue.Visibility = Visibility.Visible;
  547. App.SkinStyle = "1";
  548. FileToolsCommon.SetConfigValue("SkinStyle", "1");
  549. SkinConfig.SwitchSkin(1);
  550. }
  551. }
  552. /// <summary>
  553. /// 白色
  554. /// </summary>
  555. /// <param name="sender">
  556. /// </param>
  557. /// <param name="e">
  558. /// </param>
  559. private void BtnSkinWhite_Click(object sender, RoutedEventArgs e)
  560. {
  561. if (App.SkinStyle != "0")
  562. {
  563. HideSkinSelect();
  564. SkinSelectWhite.Visibility = Visibility.Visible;
  565. App.SkinStyle = "0";
  566. FileToolsCommon.SetConfigValue("SkinStyle", "0");
  567. SkinConfig.SwitchSkin(0);
  568. }
  569. }
  570. /// <summary>
  571. /// 隐藏皮肤选择键
  572. /// </summary>
  573. private void HideSkinSelect()
  574. {
  575. SkinSelectWhite.Visibility = Visibility.Hidden;
  576. SkinSelectTechnologyBlue.Visibility = Visibility.Hidden;
  577. }
  578. /// <summary>
  579. /// 加载皮肤选项
  580. /// </summary>
  581. private void SkinSelectInit()
  582. {
  583. if (App.SkinStyle == "0")
  584. {
  585. HideSkinSelect();
  586. SkinSelectWhite.Visibility = Visibility.Visible;
  587. SkinConfig.SwitchSkin(0);
  588. }
  589. else if (App.SkinStyle == "1")
  590. {
  591. HideSkinSelect();
  592. SkinSelectTechnologyBlue.Visibility = Visibility.Visible;
  593. SkinConfig.SwitchSkin(1);
  594. }
  595. else
  596. {
  597. HideSkinSelect();
  598. SkinSelectWhite.Visibility = Visibility.Visible;
  599. }
  600. }
  601. #endregion 切换皮肤
  602. #endregion 设置
  603. private bool _isHasCode;
  604. /// <summary>
  605. /// 加页事件
  606. /// </summary>
  607. /// <param name="sender">
  608. /// </param>
  609. /// <param name="e">
  610. /// </param>
  611. private void BtnAdd_Click(object sender, RoutedEventArgs e)
  612. {
  613. _luoBoPenUtil.lb_device_hand();
  614. PrepareRecord();
  615. if (App.PageContextData.currpage > 0)
  616. {
  617. App.PageDrawList[App.PageContextData.currpage - 1].IsImageLocation = true;
  618. }
  619. if (BlackboardCanvas.Visibility == Visibility.Collapsed)
  620. {
  621. BlackboardCanvas.Visibility = Visibility.Visible;
  622. }
  623. App.PageContextData.pagenum += 1;
  624. HideAngleBorder();
  625. GridPage.Visibility = Visibility.Visible; //页码大于0 显示
  626. App.PageContextData.currpage = App.PageContextData.pagenum;
  627. myblackboard.changepage(App.PageContextData.currpage - 1);
  628. ScroMain.ScrollToVerticalOffset(0);
  629. //清空页面图片UI
  630. ImgCanvas.Source = null;
  631. ImgDocumentation.Source = null;
  632. ImgPpt.Source = null;
  633. if (App.PageContextData.pagenum == 1)
  634. {
  635. App.PageDrawList = new List<Model_DrawData>();
  636. }
  637. //画板模型增加一页
  638. Model_DrawData modelDrawData = new Model_DrawData { PageNum = App.PageContextData.currpage };
  639. App.PageDrawList.Add(modelDrawData);
  640. if (_recordType == 0)
  641. {
  642. BtnPrint.IsEnabled = true;
  643. }
  644. if (BtnImport.IsEnabled)
  645. {
  646. //截图可用
  647. BtnScreenshot.IsEnabled = true;
  648. }
  649. }
  650. /// <summary>
  651. /// 关闭事件
  652. /// </summary>
  653. /// <param name="sender">
  654. /// </param>
  655. /// <param name="e">
  656. /// </param>
  657. private void BtnClose_Click(object sender, RoutedEventArgs e)
  658. {
  659. if (_recordType == 0)
  660. {
  661. try
  662. {
  663. MessageBoxResult br = MessageWindow.Show
  664. (
  665. "确定退出系统?",
  666. "退出",
  667. MessageBoxButton.OKCancel
  668. );
  669. if (br == MessageBoxResult.OK)
  670. {
  671. try
  672. {
  673. App.Killffmpeg();
  674. }
  675. catch (Exception ex)
  676. {
  677. LogHelper.WriteErrLog("获取进程失败," + ex.Message, ex);
  678. }
  679. App.SaveWkData();
  680. App.SaveDraw();
  681. _tmc.TmatrixUninitialize();
  682. Environment.Exit(0);
  683. }
  684. }
  685. catch (Exception ex)
  686. {
  687. LogHelper.WriteErrLog("关闭微课失败," + ex.Message, ex);
  688. Close();
  689. Application.Current.Shutdown();
  690. _tmc.TmatrixUninitialize();
  691. Environment.Exit(0);
  692. }
  693. }
  694. else
  695. {
  696. MessageWindow.Show("当前正在录制,请先停止录制。");
  697. }
  698. }
  699. /// <summary>
  700. /// 打印事件
  701. /// </summary>
  702. /// <param name="sender">
  703. /// </param>
  704. /// <param name="e">
  705. /// </param>
  706. private void BtnPrint_Click(object sender, RoutedEventArgs e)
  707. {
  708. try
  709. {
  710. //3种情况 1.文档图片 2.截图图片 3.没有图片
  711. if (App.PageDrawList.Count == 0)
  712. {
  713. MessageWindow.Show("没有可打印的页,您可以通过加页、截图或导入来增加页!");
  714. return;
  715. }
  716. }
  717. catch (Exception ex)
  718. {
  719. MessageWindow.Show(ex.Message);
  720. Console.WriteLine(@"转换失败,原因:" + ex.Message);
  721. }
  722. if (GridPrintingTitle.Visibility == Visibility.Visible)
  723. {
  724. GridPrintingTitle.Visibility = Visibility.Collapsed;
  725. }
  726. else
  727. {
  728. GridPrintingTitle.Visibility = Visibility.Visible;
  729. if (App.PageDrawList.Count > 0 && !string.IsNullOrWhiteSpace(App.PageDrawList[0].PageImagePath))
  730. {
  731. InitializePrint
  732. (
  733. App.PageDrawList[0].PageImagePath,
  734. GridM.ActualWidth,
  735. GridM.ActualHeight
  736. );
  737. }
  738. else
  739. {
  740. InitializePrint
  741. (
  742. "",
  743. GridM.ActualWidth,
  744. _gridActHeight
  745. );
  746. }
  747. }
  748. }
  749. /// <summary>
  750. /// 打印
  751. /// </summary>
  752. /// <param name="sender">
  753. /// </param>
  754. /// <param name="e">
  755. /// </param>
  756. private void BtnPrint_Print_Click(object sender, RoutedEventArgs e)
  757. {
  758. _isHasCode = true;
  759. Print();
  760. }
  761. private void BtnPrintCloseClick(object sender, RoutedEventArgs e)
  762. {
  763. GridPrintingTitle.Visibility = Visibility.Collapsed;
  764. }
  765. /// <summary>
  766. /// 打印说明
  767. /// </summary>
  768. /// <param name="sender">
  769. /// </param>
  770. /// <param name="e">
  771. /// </param>
  772. private void btnPrintExplain_Click(object sender, RoutedEventArgs e)
  773. {
  774. Process.Start(FileToolsCommon.GetFileAbsolutePath("/星火微课点阵码打印及印刷指导手册.docx"));
  775. }
  776. private void PageHide()
  777. {
  778. //设置
  779. GridSetUp.Visibility = Visibility.Collapsed;
  780. //我的
  781. GridMyVideo.Visibility = Visibility.Collapsed;
  782. //首页
  783. GridMain.Visibility = Visibility.Collapsed;
  784. GridM.IsEnabled = true;
  785. //打印
  786. GridPrintContent.Visibility = Visibility.Collapsed;
  787. //标题 录制
  788. GridRecordingTitle.Visibility = Visibility.Collapsed;
  789. //标题 打印
  790. GridPrintingTitle.Visibility = Visibility.Collapsed;
  791. }
  792. private void Print()
  793. {
  794. if (!ZPrintUtils.IsExistAcroRd32())
  795. {
  796. MessageBoxResult dr = MessageWindow.Show
  797. (
  798. "需要安装PDF阅读器,是否下载安装?",
  799. "提示",
  800. MessageBoxButton.OKCancel
  801. );
  802. if (dr == MessageBoxResult.OK)
  803. {
  804. ZPrintUtils.InstallAcroRd32ByUser();
  805. }
  806. return;
  807. }
  808. BtnPrint.IsEnabled = false;
  809. PrintModel printmodel = new PrintModel();
  810. string imgPath = FileToolsCommon.GetFileAbsolutePath("temp/");
  811. imgPath = imgPath + DateTime.Now.ToString("yyyyMMddHHmmss") + ".pdf";
  812. printmodel.filepath = imgPath;
  813. //打印数量
  814. printmodel.num = 1;
  815. _printMsg = "准备中";
  816. _msgnum = 0;
  817. _num = 0;
  818. GridPrintMask.Visibility = Visibility.Visible;
  819. Task.Run
  820. (
  821. () =>
  822. {
  823. StartPrint(printmodel);
  824. }
  825. );
  826. _timesPrint = new System.Timers.Timer(100);
  827. _timesPrint.Elapsed += Times_ElapsedClick;
  828. _timesPrint.Start();
  829. _timesPrintMsg = new System.Timers.Timer(500);
  830. _timesPrintMsg.Elapsed += TimesPrintMsg_Elapsed;
  831. _timesPrintMsg.Start();
  832. GridPrintingTitle.Visibility = Visibility.Collapsed;
  833. }
  834. private void Print_No_Code_Click(object sender, RoutedEventArgs e)
  835. {
  836. _isHasCode = false;
  837. Print();
  838. }
  839. /// <summary>
  840. /// 窗体移动
  841. /// </summary>
  842. /// <param name="sender">
  843. /// </param>
  844. /// <param name="e">
  845. /// </param>
  846. private void Window_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
  847. {
  848. DragMove();
  849. }
  850. #region 摄像头
  851. private bool _isRbnOpen;
  852. private System.Timers.Timer _times;
  853. /// <summary>
  854. /// 摄像头打开事件
  855. /// </summary>
  856. /// <param name="sender">
  857. /// </param>
  858. /// <param name="e">
  859. /// </param>
  860. private void RbnOpen_Click(object sender, RoutedEventArgs e)
  861. {
  862. if (!_isRbnOpen)
  863. {
  864. #region 防止连击
  865. if (_isPressButton)
  866. {
  867. return;
  868. }
  869. _isPressButton = true;
  870. Task.Run
  871. (
  872. () =>
  873. {
  874. Thread.Sleep(3000);
  875. _isPressButton = false;
  876. }
  877. );
  878. #endregion 防止连击
  879. CameraHelper.UpdateCameraDevices();
  880. if (CameraHelper.CameraDevices.Count > 0)
  881. {
  882. if (string.IsNullOrWhiteSpace(App.CameraName))
  883. {
  884. App.CameraName = CameraHelper.CameraDevices[0].MonikerString;
  885. }
  886. int cameraIndex = 0;
  887. for (int i = 0; i < CameraHelper.CameraDevices.Count; i++)
  888. {
  889. if (CameraHelper.CameraDevices[i].MonikerString == App.CameraName)
  890. {
  891. cameraIndex = i;
  892. }
  893. }
  894. CameraHelper.imageCallback = LoadImage;
  895. CameraHelper.StartCameraDevice(cameraIndex, this.Dispatcher);
  896. if (_timer != null)
  897. {
  898. _times.Elapsed -= Times_Elapsed;
  899. _times.Enabled = false;
  900. _times.Dispose();
  901. }
  902. _times = new System.Timers.Timer(200) //初始值为300
  903. {
  904. AutoReset = true //设置是否执行System.Timers.Timer.Elapsed事件
  905. }; //设置执行一次(false)还是一直执行(true)
  906. _times.Elapsed += Times_Elapsed;
  907. _times.Enabled = true; //启动计时器
  908. _isRbnOpen = true;
  909. string imgPath = FileToolsCommon.GetFileAbsolutePath("Temp/imgplayer");
  910. FileToolsCommon.CreateDirectory(imgPath);
  911. HeadImg.Visibility = Visibility.Visible;
  912. // < !--摄像头位置 1.右上 2.左上 3.右下 4.左下-- >
  913. switch (App.CameraPosition)
  914. {
  915. case "1":
  916. HeadImg.HorizontalAlignment = HorizontalAlignment.Right;
  917. HeadImg.VerticalAlignment = VerticalAlignment.Top;
  918. break;
  919. case "2":
  920. HeadImg.HorizontalAlignment = HorizontalAlignment.Left;
  921. HeadImg.VerticalAlignment = VerticalAlignment.Top;
  922. break;
  923. case "3":
  924. HeadImg.HorizontalAlignment = HorizontalAlignment.Right;
  925. HeadImg.VerticalAlignment = VerticalAlignment.Bottom;
  926. break;
  927. case "4":
  928. HeadImg.HorizontalAlignment = HorizontalAlignment.Left;
  929. HeadImg.VerticalAlignment = VerticalAlignment.Bottom;
  930. break;
  931. }
  932. RbnTurnOff.IsEnabled = false;
  933. Task.Run
  934. (
  935. () =>
  936. {
  937. Thread.Sleep(3000);
  938. Dispatcher.Invoke
  939. (
  940. () =>
  941. {
  942. RbnTurnOff.IsEnabled = true;
  943. }
  944. );
  945. }
  946. );
  947. }
  948. }
  949. }
  950. /// <summary>
  951. /// 摄像头关闭事件
  952. /// </summary>
  953. /// <param name="sender">
  954. /// </param>
  955. /// <param name="e">
  956. /// </param>
  957. private void RbnTurnOff_Click(object sender, RoutedEventArgs e)
  958. {
  959. if (_isRbnOpen)
  960. {
  961. #region 防止连击
  962. if (_isPressButton)
  963. {
  964. return;
  965. }
  966. _isPressButton = true;
  967. Task.Run
  968. (
  969. () =>
  970. {
  971. Thread.Sleep(500);
  972. _isPressButton = false;
  973. }
  974. );
  975. #endregion 防止连击
  976. _isRbnOpen = false;
  977. HeadImg.Visibility = Visibility.Hidden;
  978. RbnOpen.IsEnabled = false;
  979. CameraHelper.CloseDevice();
  980. RbnOpen.IsEnabled = true;
  981. if (_timer != null)
  982. {
  983. _times.Elapsed -= Times_Elapsed;
  984. _times.Enabled = false;
  985. _times.Dispose();
  986. _times = null;
  987. }
  988. }
  989. }
  990. private void Times_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
  991. {
  992. if (_isRbnOpen)
  993. {
  994. try
  995. {
  996. long time = Timestamp();
  997. string imgPath = FileToolsCommon.GetFileAbsolutePath("Temp/imgplayer");
  998. CameraHelper.CaptureImage(imgPath, time.ToString());
  999. }
  1000. catch (Exception ex)
  1001. {
  1002. LogHelper.WriteErrLog("【摄像】(Times_Elapsed)生成图片错误:" + ex.Message, ex);
  1003. }
  1004. }
  1005. }
  1006. #endregion 摄像头
  1007. #region 设备检测
  1008. /// <summary>
  1009. /// 设备检测
  1010. /// </summary>
  1011. /// <param name="sender">
  1012. /// </param>
  1013. /// <param name="e">
  1014. /// </param>
  1015. private async void BtnDevice_Click(object sender, RoutedEventArgs e)
  1016. {
  1017. if (RbnTurnOff.IsChecked != null && !(bool)RbnTurnOff.IsChecked)
  1018. {
  1019. RbnTurnOff.IsChecked = true;
  1020. RbnTurnOff_Click(null, null);
  1021. await Task.Delay(1000);
  1022. }
  1023. DeviceWindow deviceWin = new DeviceWindow();
  1024. deviceWin.ShowDialog();
  1025. }
  1026. #endregion 设备检测
  1027. #endregion 事件
  1028. #region 画笔
  1029. /// <summary>
  1030. /// 画笔颜色事件 蓝色
  1031. /// </summary>
  1032. /// <param name="sender">
  1033. /// </param>
  1034. /// <param name="e">
  1035. /// </param>
  1036. private void BtnBlue_Click(object sender, RoutedEventArgs e)
  1037. {
  1038. _drawingAttributes.Color = Colors.DeepSkyBlue;
  1039. _color = Colors.DeepSkyBlue;
  1040. ImgRed.Visibility = Visibility.Collapsed;
  1041. ImgGray.Visibility = Visibility.Collapsed;
  1042. ImgCyanBlue.Visibility = Visibility.Collapsed;
  1043. ImgYellow.Visibility = Visibility.Collapsed;
  1044. ImgBlue.Visibility = Visibility.Visible;
  1045. }
  1046. /// <summary>
  1047. /// 画笔颜色事件 青色
  1048. /// </summary>
  1049. /// <param name="sender">
  1050. /// </param>
  1051. /// <param name="e">
  1052. /// </param>
  1053. private void BtnCyanBlue_Click(object sender, RoutedEventArgs e)
  1054. {
  1055. _drawingAttributes.Color = Colors.LimeGreen;
  1056. _color = Colors.LimeGreen;
  1057. ImgRed.Visibility = Visibility.Collapsed;
  1058. ImgGray.Visibility = Visibility.Collapsed;
  1059. ImgCyanBlue.Visibility = Visibility.Visible;
  1060. ImgYellow.Visibility = Visibility.Collapsed;
  1061. ImgBlue.Visibility = Visibility.Collapsed;
  1062. }
  1063. /// <summary>
  1064. /// 画笔颜色事件 黑色
  1065. /// </summary>
  1066. /// <param name="sender">
  1067. /// </param>
  1068. /// <param name="e">
  1069. /// </param>
  1070. private void BtnGray_Click(object sender, RoutedEventArgs e)
  1071. {
  1072. _drawingAttributes.Color = Colors.Black;
  1073. _color = Colors.Black;
  1074. ImgRed.Visibility = Visibility.Collapsed;
  1075. ImgGray.Visibility = Visibility.Visible;
  1076. ImgCyanBlue.Visibility = Visibility.Collapsed;
  1077. ImgYellow.Visibility = Visibility.Collapsed;
  1078. ImgBlue.Visibility = Visibility.Collapsed;
  1079. }
  1080. /// <summary>
  1081. /// 画笔颜色事件 红色
  1082. /// </summary>
  1083. /// <param name="sender">
  1084. /// </param>
  1085. /// <param name="e">
  1086. /// </param>
  1087. private void BtnRed_Click(object sender, RoutedEventArgs e)
  1088. {
  1089. //设置 DrawingAttributes 的 Color 属性设置颜色
  1090. _drawingAttributes.Color = Colors.Red;
  1091. _color = Colors.Red;
  1092. ImgRed.Visibility = Visibility.Visible;
  1093. ImgGray.Visibility = Visibility.Collapsed;
  1094. ImgCyanBlue.Visibility = Visibility.Collapsed;
  1095. ImgYellow.Visibility = Visibility.Collapsed;
  1096. ImgBlue.Visibility = Visibility.Collapsed;
  1097. }
  1098. /// <summary>
  1099. /// 画笔颜色事件 白色
  1100. /// </summary>
  1101. /// <param name="sender">
  1102. /// </param>
  1103. /// <param name="e">
  1104. /// </param>
  1105. private void BtnWhite_Click(object sender, RoutedEventArgs e)
  1106. {
  1107. _drawingAttributes.Color = Colors.White;
  1108. _color = Colors.White;
  1109. }
  1110. /// <summary>
  1111. /// 画笔颜色事件 黄色
  1112. /// </summary>
  1113. /// <param name="sender">
  1114. /// </param>
  1115. /// <param name="e">
  1116. /// </param>
  1117. private void BtnYellow_Click(object sender, RoutedEventArgs e)
  1118. {
  1119. _drawingAttributes.Color = Colors.Gold;
  1120. _color = Colors.Gold;
  1121. ImgRed.Visibility = Visibility.Collapsed;
  1122. ImgGray.Visibility = Visibility.Collapsed;
  1123. ImgCyanBlue.Visibility = Visibility.Collapsed;
  1124. ImgYellow.Visibility = Visibility.Visible;
  1125. ImgBlue.Visibility = Visibility.Collapsed;
  1126. }
  1127. private void imgCanvas_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
  1128. {
  1129. _mouseDown = true;
  1130. _imageOperationUtil.setMouseDown(_mouseDown);
  1131. }
  1132. /// <summary>
  1133. /// 画笔粗细事件 粗
  1134. /// </summary>
  1135. /// <param name="sender">
  1136. /// </param>
  1137. /// <param name="e">
  1138. /// </param>
  1139. private void RbnCrude_Click(object sender, RoutedEventArgs e)
  1140. {
  1141. _drawingAttributes.Width = 5;
  1142. _drawingAttributes.Height = 5;
  1143. _penSize = 5;
  1144. }
  1145. /// <summary>
  1146. /// 画笔粗细事件 细
  1147. /// </summary>
  1148. /// <param name="sender">
  1149. /// </param>
  1150. /// <param name="e">
  1151. /// </param>
  1152. private void RbnFine_Click(object sender, RoutedEventArgs e)
  1153. {
  1154. _drawingAttributes.Width = 1;
  1155. _drawingAttributes.Height = 1;
  1156. _penSize = 1;
  1157. }
  1158. /// <summary>
  1159. /// 画笔粗细事件 中
  1160. /// </summary>
  1161. /// <param name="sender">
  1162. /// </param>
  1163. /// <param name="e">
  1164. /// </param>
  1165. private void RbnIn_Click(object sender, RoutedEventArgs e)
  1166. {
  1167. _drawingAttributes.Width = 3;
  1168. _drawingAttributes.Height = 3;
  1169. _penSize = 3;
  1170. }
  1171. #endregion 画笔
  1172. #region 导入截图
  1173. /// <summary>
  1174. /// 防止图片地址重复
  1175. /// </summary>
  1176. private long _wordImgNum = 9999;
  1177. /// <summary>
  1178. /// 返回一个时间戳到毫秒
  1179. /// </summary>
  1180. /// <returns>
  1181. /// </returns>
  1182. public static long Timestamp()
  1183. {
  1184. TimeSpan ts = DateTime.UtcNow
  1185. - new DateTime
  1186. (
  1187. 1970,
  1188. 1,
  1189. 1,
  1190. 0,
  1191. 0,
  1192. 0,
  1193. 0
  1194. );
  1195. long timestr = Convert.ToInt64(ts.TotalMilliseconds);
  1196. return timestr;
  1197. }
  1198. /// <summary>
  1199. /// 获取时间戳
  1200. /// </summary>
  1201. /// <returns>
  1202. /// </returns>
  1203. public string GetTimeStamp()
  1204. {
  1205. TimeSpan ts = DateTime.Now
  1206. - new DateTime
  1207. (
  1208. 1970,
  1209. 1,
  1210. 1,
  1211. 0,
  1212. 0,
  1213. 0,
  1214. 0
  1215. );
  1216. return Convert.ToInt64(ts.TotalSeconds).ToString();
  1217. }
  1218. /// <summary>
  1219. /// 导入-结束
  1220. /// </summary>
  1221. /// <returns>
  1222. /// </returns>
  1223. public void InvokeServerCompate(object obj)
  1224. {
  1225. //APP.myloading.Hide();
  1226. App.myloading.Hide();
  1227. }
  1228. public void WindowType()
  1229. {
  1230. this.Activate();
  1231. }
  1232. /// <summary>
  1233. /// 导入事件
  1234. /// </summary>
  1235. /// <param name="sender">
  1236. /// </param>
  1237. /// <param name="e">
  1238. /// </param>
  1239. private void BtnImport_Click(object sender, RoutedEventArgs e)
  1240. {
  1241. try
  1242. {
  1243. PrepareRecord();
  1244. HideAngleBorder();
  1245. string desktopPath = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
  1246. _ofd = new System.Windows.Forms.OpenFileDialog
  1247. {
  1248. //Filter = "文档|*.docx;*.doc;*.ppt;*.pptx",
  1249. //增加导入图片
  1250. Filter = @"文档|*.docx;*.doc;*.ppt;*.pptx;*.pdf|图片|*.jpg;*.jpeg;*.png;*.bmp",
  1251. InitialDirectory = desktopPath,
  1252. Multiselect = false,
  1253. AddExtension = true,
  1254. DereferenceLinks = true
  1255. };
  1256. App.BackgroundWorkerHelper.RunWorkerAsync(InvokeServering, InvokeServerCompate);
  1257. }
  1258. catch (Exception ex)
  1259. {
  1260. LogHelper.WriteErrLog("【导入(BtnImport_Click)" + ex.Message, ex);
  1261. }
  1262. }
  1263. /// <summary>
  1264. /// 截图事件
  1265. /// </summary>
  1266. /// <param name="sender">
  1267. /// </param>
  1268. /// <param name="e">
  1269. /// </param>
  1270. private void BtnScreenshot_Click(object sender, RoutedEventArgs e)
  1271. {
  1272. JietuAction();
  1273. }
  1274. private async void JietuAction()
  1275. {
  1276. PrepareRecord();
  1277. HideAngleBorder();
  1278. if (WindowState == WindowState.Normal) //截图隐藏窗口
  1279. {
  1280. WindowState = WindowState.Minimized;
  1281. }
  1282. await Task.Delay(300);
  1283. ImgCanvas.Margin = new Thickness
  1284. (
  1285. 0,
  1286. 0,
  1287. 0,
  1288. 0
  1289. );
  1290. App.ImgPath = string.Empty;
  1291. string time = GetTimeStamp();
  1292. string desktopPath = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory) + time + ".jpg";
  1293. App.ImgPath = desktopPath;
  1294. ImageHelper.GetScreenshot
  1295. (
  1296. new Rectangle
  1297. (
  1298. 0,
  1299. 0,
  1300. 0,
  1301. 0
  1302. )
  1303. {
  1304. Location = default,
  1305. Size = default
  1306. },
  1307. desktopPath,
  1308. false,
  1309. out var _
  1310. );
  1311. _kHook.Stop();
  1312. if (App.W_JieTuWindow != null)
  1313. {
  1314. App.W_JieTuWindow.initialization();
  1315. App.W_JieTuWindow.Screenshot();
  1316. App.W_JieTuWindow.InitializeKeyDownEvent();
  1317. App.W_JieTuWindow.WindowState = WindowState.Maximized;
  1318. App.W_JieTuWindow.Visibility = Visibility.Visible;
  1319. }
  1320. else
  1321. {
  1322. App.W_JieTuWindow = new JieTuWindow();
  1323. App.W_JieTuWindow.InitializeKeyDownEvent();
  1324. // 订阅事件
  1325. App.W_JieTuWindow.ChangeTextEvent += frm_ChangeTextEvent;
  1326. App.W_JieTuWindow.click_closeJietuWindowClick += JietuWindow_click_closeJietuWindowClick;
  1327. App.W_JieTuWindow.Show();
  1328. }
  1329. }
  1330. /// <summary>
  1331. /// 截图关闭窗口
  1332. /// </summary>
  1333. /// <param name="text">
  1334. /// </param>
  1335. private void frm_ChangeTextEvent(string text)
  1336. {
  1337. if ("关闭窗口".Equals(text))
  1338. {
  1339. if (WindowState == WindowState.Minimized) //截图完恢复窗口
  1340. {
  1341. WindowState = WindowState.Normal;
  1342. Activate();
  1343. }
  1344. InitializeKeyDownEvent();
  1345. if (!string.IsNullOrWhiteSpace(App.ImgPath) && File.Exists(App.ImgPath))
  1346. {
  1347. if (App.PageContextData.currpage == 0)
  1348. {
  1349. App.PageContextData.pagenum += 1;
  1350. App.PageContextData.currpage = App.PageContextData.pagenum;
  1351. myblackboard.changepage(App.PageContextData.currpage - 1);
  1352. GridPage.Visibility = Visibility.Visible; //页码大于0 显示
  1353. #region 插入页码
  1354. #endregion 插入页码
  1355. }
  1356. if (App.PageDrawList.Count >= App.PageContextData.currpage)
  1357. {
  1358. App.PageDrawList[App.PageContextData.currpage - 1].PageImagePath = App.ImgPath; //zxycs
  1359. App.PageDrawList[App.PageContextData.currpage - 1].PdfImagePath = App.ImgPath;
  1360. }
  1361. else
  1362. {
  1363. Model_DrawData modelDrawData = new Model_DrawData
  1364. {
  1365. PageImagePath = App.ImgPath,
  1366. PdfImagePath = App.ImgPath
  1367. };
  1368. App.PageDrawList.Add(modelDrawData);
  1369. }
  1370. if (App.PageDrawList.Count >= App.PageContextData.currpage && !string.IsNullOrWhiteSpace(App.PageDrawList[App.PageContextData.currpage - 1].PageImagePath))
  1371. {
  1372. ImgDocumentation.Source = null;
  1373. BitmapImage bitImg = new BitmapImage(new Uri(App.PageDrawList[App.PageContextData.currpage - 1].PageImagePath));
  1374. _mouseDown = false;
  1375. _imageOperationUtil.setMouseDown(_mouseDown);
  1376. App.PageDrawList[App.PageContextData.currpage - 1].ImageLocation = new TranslateTransform
  1377. {
  1378. X = 0.1,
  1379. Y = 0.1
  1380. };
  1381. App.PageDrawList[App.PageContextData.currpage - 1].Type = "截图";
  1382. App.PageDrawList[App.PageContextData.currpage - 1].IsImageLocation = false;
  1383. ImgCanvas.Source = bitImg;
  1384. ImgCanvas.Width = bitImg.Width;
  1385. ImgCanvas.Height = bitImg.Height;
  1386. ScroMain.ScrollToVerticalOffset(0);
  1387. App.PageDrawList[App.PageContextData.currpage - 1].ImageSizes = new ScaleTransform
  1388. {
  1389. CenterX = ImgCanvas.Width,
  1390. CenterY = ImgCanvas.Height
  1391. };
  1392. BtnPrint.IsEnabled = true;
  1393. }
  1394. }
  1395. }
  1396. else if ("取消".Equals(text))
  1397. {
  1398. if (WindowState == WindowState.Minimized) //截图完恢复窗口
  1399. {
  1400. WindowState = WindowState.Normal;
  1401. }
  1402. }
  1403. }
  1404. /// <summary>
  1405. /// 导入-开始
  1406. /// </summary>
  1407. /// <returns>
  1408. /// </returns>
  1409. private object InvokeServering()
  1410. {
  1411. Dispatcher.Invoke
  1412. (
  1413. () =>
  1414. {
  1415. _result = _ofd.ShowDialog();
  1416. }
  1417. );
  1418. if (_result == System.Windows.Forms.DialogResult.OK)
  1419. {
  1420. if (_ofd.FileName != "")
  1421. {
  1422. List<string> imagelist = new List<string>()
  1423. {
  1424. "jpg",
  1425. "jpeg",
  1426. "png",
  1427. "bmp"
  1428. };
  1429. Dispatcher.Invoke
  1430. (
  1431. () =>
  1432. {
  1433. App.myloading.Show();
  1434. myblackboard.changepage(App.PageContextData.pagenum);
  1435. }
  1436. );
  1437. string filepath = _ofd.FileName;
  1438. string filesuff = filepath.Substring(filepath.LastIndexOf(".", StringComparison.Ordinal) + 1).ToLower();
  1439. if (_ofd.SafeFileName != null)
  1440. {
  1441. string path = _ofd.SafeFileName.Replace(".ppt", "").Replace(".pptx", "").Trim();
  1442. string type = _ofd.SafeFileName.Replace(".ppt", "typezsygppt").Replace(".pptx", "typezsygppt").Replace(".pdf", "typepdf").Trim();
  1443. if (type.Contains("typezsygppt")) //ppt
  1444. {
  1445. try
  1446. {
  1447. #region PPT转PDF
  1448. string pathTemp = AppDomain.CurrentDomain.BaseDirectory + "Temp\\";
  1449. path = pathTemp + path + ".pdf";
  1450. FileToolsCommon.CreateDirectory(pathTemp);
  1451. //PPT转PDF
  1452. Presentation ppt = new Presentation(filepath);
  1453. ppt.Save(path, Aspose.Slides.Export.SaveFormat.Pdf);
  1454. #endregion PPT转PDF
  1455. #region PDF转图片
  1456. // 图片绝对路径集合
  1457. List<string> images = new List<string>();
  1458. string directoryPath = pathTemp;
  1459. //定义Jpeg转换设备
  1460. Aspose.Pdf.Document pdfDoc = new Aspose.Pdf.Document(path);
  1461. Directory.CreateDirectory(directoryPath);
  1462. //默认质量为100,设置质量的好坏与处理速度不成正比,甚至是设置的质量越低反而花的时间越长,怀疑处理过程是先生成高质量的再压缩
  1463. var device = new Aspose.Pdf.Devices.JpegDevice(100);
  1464. //遍历每一页转为jpg
  1465. for (int i = 1; i <= pdfDoc.Pages.Count; i++)
  1466. {
  1467. long ii = Timestamp();
  1468. string filePathOutPut = Path.Combine
  1469. (
  1470. directoryPath,
  1471. string.Format
  1472. (
  1473. "{0}{1}.jpg",
  1474. ii,
  1475. i
  1476. )
  1477. );
  1478. images.Add(filePathOutPut);
  1479. FileStream fs = new FileStream(filePathOutPut, FileMode.OpenOrCreate);
  1480. try
  1481. {
  1482. device.Process(pdfDoc.Pages[i], fs);
  1483. fs.Close();
  1484. }
  1485. catch (Exception)
  1486. {
  1487. fs.Close();
  1488. File.Delete(filePathOutPut);
  1489. }
  1490. }
  1491. #endregion PDF转图片
  1492. Dispatcher.Invoke
  1493. (
  1494. () =>
  1495. {
  1496. string[] page = images.ToArray();
  1497. int num = 0;
  1498. int iStart = App.PageContextData.pagenum; //导入文档的开始下标
  1499. int iEnd = page.Length + App.PageContextData.pagenum; //导入文档的结束下标
  1500. for (int i = 0 + App.PageContextData.pagenum; i < page.Length + App.PageContextData.pagenum; i++) //给画板模型加图片路径
  1501. {
  1502. if (App.PageDrawList != null && App.PageDrawList.Count > i)
  1503. {
  1504. App.PageDrawList[i].PageImagePath = page[i - App.PageContextData.pagenum]; //zxycs
  1505. App.PageDrawList[i].PdfImagePath = page[i - App.PageContextData.pagenum];
  1506. App.PageDrawList[i].PageNum = i + 1;
  1507. App.PageDrawList[i].ImgDocumentation = true;
  1508. App.PageDrawList[i].Type = "ppt";
  1509. }
  1510. else
  1511. {
  1512. Model_DrawData modelDrawData = new Model_DrawData
  1513. {
  1514. PageImagePath = page[i - App.PageContextData.pagenum],
  1515. PdfImagePath = page[i - App.PageContextData.pagenum],
  1516. PageNum = i + 1,
  1517. ImgDocumentation = true,
  1518. Type = "ppt"
  1519. };
  1520. if (App.PageDrawList != null)
  1521. {
  1522. App.PageDrawList.Add(modelDrawData);
  1523. }
  1524. }
  1525. BtnPrint.IsEnabled = true;
  1526. App.SaveDraw();
  1527. num++;
  1528. }
  1529. if (num > 0)
  1530. {
  1531. App.PageContextData.currpage = App.PageContextData.pagenum + 1;
  1532. App.PageContextData.pagenum += num;
  1533. GridPage.Visibility = Visibility.Visible; //页码大于0 显示
  1534. }
  1535. if (App.PageDrawList != null && App.PageContextData.currpage > 0 && App.PageContextData.currpage <= App.PageDrawList.Count)
  1536. {
  1537. ImgCanvas.Source = null;
  1538. BtnScreenshot.IsEnabled = false;
  1539. ImgDocumentation.Source = null;
  1540. ImgPpt.Source = new BitmapImage(new Uri(App.PageDrawList[App.PageContextData.currpage - 1].PageImagePath));
  1541. ScroMain.ScrollToVerticalOffset(0);
  1542. for (int i = iStart; i < iEnd; i++)
  1543. {
  1544. App.PageDrawList[i].ImageLocation = new TranslateTransform
  1545. {
  1546. X = 0.1,
  1547. Y = 0.1
  1548. };
  1549. App.PageDrawList[i].IsImageLocation = true;
  1550. App.PageDrawList[i].ImageSizes = new ScaleTransform
  1551. {
  1552. CenterX = ImgCanvas.Width,
  1553. CenterY = ImgCanvas.Height
  1554. };
  1555. }
  1556. }
  1557. else
  1558. {
  1559. ImgDocumentation.Source = null;
  1560. ImgCanvas.Source = null;
  1561. ImgPpt.Source = null;
  1562. //截图可用
  1563. BtnScreenshot.IsEnabled = true;
  1564. }
  1565. }
  1566. );
  1567. }
  1568. catch (Exception ex)
  1569. {
  1570. Dispatcher.Invoke
  1571. (
  1572. () =>
  1573. {
  1574. MessageWindow.Show("无法访问文件,请检查文件是否有效或解除文件占用!");
  1575. }
  1576. );
  1577. LogHelper.WriteErrLog("【打开ppt】(OpenDialog PPT)" + ex.Message, ex);
  1578. }
  1579. }
  1580. else if (type.Contains("typepdf"))
  1581. {
  1582. try
  1583. {
  1584. string pathTemp = AppDomain.CurrentDomain.BaseDirectory + "Temp\\";
  1585. #region PDF转图片
  1586. // 图片绝对路径集合
  1587. List<string> images = new List<string>();
  1588. string directoryPath = pathTemp;
  1589. //aspose许可证
  1590. //Aspose.Pdf.License l = new Aspose.Pdf.License();
  1591. //string licenseName = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Aspose.Total.Product.Family.lic");
  1592. //l.SetLicense(licenseName);
  1593. //定义Jpeg转换设备
  1594. Aspose.Pdf.Document pdfDoc = new Aspose.Pdf.Document(filepath);
  1595. //int quality = int.Parse(this.comboBox1.SelectedItem.ToString());
  1596. //directoryPath += quality;
  1597. Directory.CreateDirectory(directoryPath);
  1598. //默认质量为100,设置质量的好坏与处理速度不成正比,甚至是设置的质量越低反而花的时间越长,怀疑处理过程是先生成高质量的再压缩
  1599. var device = new Aspose.Pdf.Devices.JpegDevice(100);
  1600. //遍历每一页转为jpg
  1601. for (int i = 1; i <= pdfDoc.Pages.Count; i++)
  1602. {
  1603. long ii = Timestamp();
  1604. string filePathOutPut = Path.Combine
  1605. (
  1606. directoryPath,
  1607. string.Format
  1608. (
  1609. "{0}{1}.jpg",
  1610. ii,
  1611. i
  1612. )
  1613. );
  1614. images.Add(filePathOutPut);
  1615. FileStream fs = new FileStream(filePathOutPut, FileMode.OpenOrCreate);
  1616. try
  1617. {
  1618. device.Process(pdfDoc.Pages[i], fs);
  1619. fs.Close();
  1620. }
  1621. catch (Exception)
  1622. {
  1623. fs.Close();
  1624. File.Delete(filePathOutPut);
  1625. }
  1626. }
  1627. #endregion PDF转图片
  1628. string[] page = images.ToArray();
  1629. int num = 0;
  1630. Dispatcher.Invoke
  1631. (
  1632. () =>
  1633. {
  1634. for (int i = App.PageContextData.pagenum; i < page.Length + App.PageContextData.pagenum; i++) //给画板模型加图片路径
  1635. {
  1636. if (App.PageDrawList != null && App.PageDrawList.Count > i)
  1637. {
  1638. App.PageDrawList[i].PageImagePath = page[i - App.PageContextData.pagenum]; //zxycs
  1639. App.PageDrawList[i].PdfImagePath = page[i - App.PageContextData.pagenum];
  1640. App.PageDrawList[i].PageNum = i + 1;
  1641. App.PageDrawList[i].ImgDocumentation = true;
  1642. App.PageDrawList[i].Type = "word";
  1643. }
  1644. else
  1645. {
  1646. Model_DrawData modelDrawData = new Model_DrawData
  1647. {
  1648. PageImagePath = page[i - App.PageContextData.pagenum],
  1649. PdfImagePath = page[i - App.PageContextData.pagenum],
  1650. PageNum = i + 1,
  1651. ImgDocumentation = true,
  1652. Type = "word"
  1653. };
  1654. if (App.PageDrawList != null)
  1655. {
  1656. App.PageDrawList.Add(modelDrawData);
  1657. }
  1658. }
  1659. BtnPrint.IsEnabled = true;
  1660. App.SaveDraw();
  1661. num++;
  1662. }
  1663. if (num > 0)
  1664. {
  1665. App.PageContextData.currpage = App.PageContextData.pagenum + 1;
  1666. App.PageContextData.pagenum += num;
  1667. GridPage.Visibility = Visibility.Visible; //页码大于0 显示
  1668. }
  1669. if (App.PageDrawList != null && App.PageContextData.currpage > 0 && App.PageContextData.currpage <= App.PageDrawList.Count)
  1670. {
  1671. ImgCanvas.Source = null;
  1672. ImgPpt.Source = null;
  1673. BtnScreenshot.IsEnabled = false;
  1674. ImgDocumentation.Visibility = Visibility.Visible;
  1675. ImgDocumentation.Source = new BitmapImage(new Uri(App.PageDrawList[App.PageContextData.currpage - 1].PageImagePath)); //给当前页面展示图片
  1676. ScroMain.ScrollToVerticalOffset(0);
  1677. }
  1678. else
  1679. {
  1680. ImgDocumentation.Source = null;
  1681. ImgCanvas.Source = null;
  1682. ImgPpt.Source = null;
  1683. //截图可用
  1684. BtnScreenshot.IsEnabled = true;
  1685. }
  1686. }
  1687. );
  1688. }
  1689. catch (Exception ex)
  1690. {
  1691. Dispatcher.Invoke
  1692. (
  1693. () =>
  1694. {
  1695. MessageWindow.Show(ex.Message);
  1696. }
  1697. );
  1698. LogHelper.WriteErrLog("【打开pdf】(OpenDialog pdf)" + ex.Message, ex);
  1699. }
  1700. }
  1701. else if (imagelist.Contains(filesuff)) //导入图片
  1702. {
  1703. string imagepath = AppDomain.CurrentDomain.BaseDirectory + "temp";
  1704. if (!Directory.Exists(imagepath))
  1705. {
  1706. Directory.CreateDirectory(imagepath);
  1707. }
  1708. TimeSpan ts = DateTime.UtcNow
  1709. - new DateTime
  1710. (
  1711. 1970,
  1712. 1,
  1713. 1,
  1714. 0,
  1715. 0,
  1716. 0,
  1717. 0
  1718. );
  1719. string timestr = Convert.ToInt64(ts.TotalMilliseconds).ToString();
  1720. string filepathCopy = Path.Combine(imagepath, timestr + _ofd.SafeFileName);
  1721. File.Copy(filepath, filepathCopy);
  1722. filepath = filepathCopy;
  1723. App.ImgPath = filepath;
  1724. Dispatcher.Invoke
  1725. (
  1726. () =>
  1727. {
  1728. if (App.PageContextData.currpage == 0)
  1729. {
  1730. App.PageContextData.pagenum += 1;
  1731. App.PageContextData.currpage = App.PageContextData.pagenum;
  1732. myblackboard.changepage(App.PageContextData.currpage - 1);
  1733. GridPage.Visibility = Visibility.Visible; //页码大于0 显示
  1734. #region 插入页码
  1735. #endregion 插入页码
  1736. }
  1737. else
  1738. {
  1739. App.PageContextData.pagenum += 1;
  1740. App.PageContextData.currpage = App.PageContextData.pagenum;
  1741. myblackboard.changepage(App.PageContextData.currpage - 1);
  1742. }
  1743. if (App.PageDrawList.Count >= App.PageContextData.currpage)
  1744. {
  1745. App.PageDrawList[App.PageContextData.currpage - 1].PageImagePath = App.ImgPath; //zxycs
  1746. App.PageDrawList[App.PageContextData.currpage - 1].PdfImagePath = App.ImgPath;
  1747. }
  1748. else
  1749. {
  1750. Model_DrawData modelDrawData = new Model_DrawData
  1751. {
  1752. PageImagePath = App.ImgPath,
  1753. PdfImagePath = App.ImgPath
  1754. };
  1755. App.PageDrawList.Add(modelDrawData);
  1756. }
  1757. if (App.PageDrawList.Count >= App.PageContextData.currpage && !string.IsNullOrWhiteSpace(App.PageDrawList[App.PageContextData.currpage - 1].PageImagePath))
  1758. {
  1759. ImgDocumentation.Source = null;
  1760. BitmapImage bitImg = new BitmapImage(new Uri(App.PageDrawList[App.PageContextData.currpage - 1].PageImagePath));
  1761. _mouseDown = false;
  1762. _imageOperationUtil.setMouseDown(_mouseDown);
  1763. App.PageDrawList[App.PageContextData.currpage - 1].ImageLocation = new TranslateTransform
  1764. {
  1765. X = 0.1,
  1766. Y = 0.1
  1767. };
  1768. App.PageDrawList[App.PageContextData.currpage - 1].Type = "截图";
  1769. App.PageDrawList[App.PageContextData.currpage - 1].IsImageLocation = false;
  1770. ImgCanvas.Source = bitImg;
  1771. ImgCanvas.Width = bitImg.Width;
  1772. ImgCanvas.Height = bitImg.Height;
  1773. ScroMain.ScrollToVerticalOffset(0);
  1774. ImgCanvas.Margin = new Thickness
  1775. (
  1776. App.PageDrawList[App.PageContextData.currpage - 1].ImageLocation.X,
  1777. App.PageDrawList[App.PageContextData.currpage - 1].ImageLocation.Y,
  1778. 0,
  1779. 0
  1780. );
  1781. App.PageDrawList[App.PageContextData.currpage - 1].ImageSizes = new ScaleTransform
  1782. {
  1783. CenterX = ImgCanvas.Width,
  1784. CenterY = ImgCanvas.Height
  1785. };
  1786. BtnPrint.IsEnabled = true;
  1787. }
  1788. }
  1789. );
  1790. }
  1791. else //word
  1792. {
  1793. try
  1794. {
  1795. string paths = AppDomain.CurrentDomain.BaseDirectory + "Temp\\";
  1796. _wordImgNum += 1;
  1797. string[] page = ZAsposeUtil.ConvertWordToImage
  1798. (
  1799. filepath,
  1800. paths,
  1801. "" + _wordImgNum
  1802. )
  1803. .ToArray();
  1804. int num = 0;
  1805. Dispatcher.Invoke
  1806. (
  1807. () =>
  1808. {
  1809. for (int i = 0 + App.PageContextData.pagenum; i < page.Length + App.PageContextData.pagenum; i++) //给画板模型加图片路径
  1810. {
  1811. if (App.PageDrawList != null && App.PageDrawList.Count > i)
  1812. {
  1813. App.PageDrawList[i].PageImagePath = page[i - App.PageContextData.pagenum]; //zxycs
  1814. App.PageDrawList[i].PdfImagePath = page[i - App.PageContextData.pagenum];
  1815. App.PageDrawList[i].PageNum = i + 1;
  1816. App.PageDrawList[i].ImgDocumentation = true;
  1817. App.PageDrawList[i].Type = "word";
  1818. }
  1819. else
  1820. {
  1821. Model_DrawData modelDrawData = new Model_DrawData
  1822. {
  1823. PageImagePath = page[i - App.PageContextData.pagenum],
  1824. PdfImagePath = page[i - App.PageContextData.pagenum],
  1825. PageNum = i + 1,
  1826. ImgDocumentation = true,
  1827. Type = "word"
  1828. };
  1829. if (App.PageDrawList != null)
  1830. {
  1831. App.PageDrawList.Add(modelDrawData);
  1832. }
  1833. }
  1834. BtnPrint.IsEnabled = true;
  1835. App.SaveDraw();
  1836. num++;
  1837. }
  1838. if (num > 0)
  1839. {
  1840. App.PageContextData.currpage = App.PageContextData.pagenum + 1;
  1841. App.PageContextData.pagenum += num;
  1842. GridPage.Visibility = Visibility.Visible; //页码大于0 显示
  1843. }
  1844. if (App.PageDrawList != null && App.PageContextData.currpage > 0 && App.PageContextData.currpage <= App.PageDrawList.Count)
  1845. {
  1846. ImgCanvas.Source = null;
  1847. ImgPpt.Source = null;
  1848. BtnScreenshot.IsEnabled = false;
  1849. ImgDocumentation.Visibility = Visibility.Visible;
  1850. ImgDocumentation.Source = new BitmapImage(new Uri(App.PageDrawList[App.PageContextData.currpage - 1].PageImagePath)); //给当前页面展示图片
  1851. ScroMain.ScrollToVerticalOffset(0);
  1852. }
  1853. else
  1854. {
  1855. ImgDocumentation.Source = null;
  1856. ImgCanvas.Source = null;
  1857. ImgPpt.Source = null;
  1858. //截图可用
  1859. BtnScreenshot.IsEnabled = true;
  1860. }
  1861. }
  1862. );
  1863. }
  1864. catch (Exception ex)
  1865. {
  1866. Dispatcher.Invoke
  1867. (
  1868. () =>
  1869. {
  1870. MessageWindow.Show("无法访问文件,请检查文件是否有效或解除文件占用!");
  1871. }
  1872. );
  1873. LogHelper.WriteErrLog("【XHMicroLessonSystemWindow】(OpenDialog 导入文档)" + ex.Message, ex);
  1874. }
  1875. }
  1876. }
  1877. #region 插入页码
  1878. #endregion 插入页码
  1879. }
  1880. }
  1881. //OpenDialog();
  1882. return "";
  1883. }
  1884. /// <summary>
  1885. /// 截图关闭 非正常关闭截图时,截图清空
  1886. /// </summary>
  1887. private void JietuWindow_click_closeJietuWindowClick()
  1888. {
  1889. if (WindowState == WindowState.Minimized) //截图完恢复窗口
  1890. {
  1891. WindowState = WindowState.Normal;
  1892. }
  1893. App.W_JieTuWindow = null;
  1894. }
  1895. #region 导入转换图片
  1896. #endregion 导入转换图片
  1897. #endregion 导入截图
  1898. #region 上传 列表
  1899. /// <summary>
  1900. /// 搜索集合匹配的索引
  1901. /// </summary>
  1902. /// <typeparam name="T">
  1903. /// </typeparam>
  1904. /// <param name="parent">
  1905. /// </param>
  1906. /// <param name="childName">
  1907. /// </param>
  1908. /// <returns>
  1909. /// </returns>
  1910. public static List<T> FindChilds<T>(DependencyObject parent, string childName) 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. FindChilds<T>(child, childName);
  1927. list.AddRange(FindChilds<T>(child, childName));
  1928. }
  1929. else if (!string.IsNullOrEmpty(childName))
  1930. {
  1931. FrameworkElement frameworkElement = child as FrameworkElement;
  1932. // 如果控件名称符合参数条件
  1933. if (frameworkElement != null && frameworkElement.Name == childName)
  1934. {
  1935. list.Add((T)child);
  1936. }
  1937. }
  1938. else
  1939. {
  1940. // 查找到了控件
  1941. list.Add((T)child);
  1942. }
  1943. }
  1944. return list;
  1945. }
  1946. /// <summary>
  1947. /// 加载视频列表
  1948. /// </summary>
  1949. public void LoadingVideoList()
  1950. {
  1951. try
  1952. {
  1953. _modelVideoList = new List<Model_Video>();
  1954. foreach (Model_WKData vdata in App.WKDataList)
  1955. {
  1956. #region 计时器初始化
  1957. if (vdata.VideoList == null)
  1958. {
  1959. continue;
  1960. }
  1961. foreach (Model_Video videoinfo in vdata.VideoList)
  1962. {
  1963. try
  1964. {
  1965. if (string.IsNullOrWhiteSpace(videoinfo.VideoPath))
  1966. {
  1967. continue;
  1968. }
  1969. if (string.IsNullOrWhiteSpace(videoinfo.VideoSize) || videoinfo.VideoSize == "0 MB")
  1970. {
  1971. videoinfo.VideoSize = FileToolsCommon.GetFileSizeByMB(videoinfo.VideoPath).ToString(CultureInfo.InvariantCulture) + " MB";
  1972. videoinfo.VideoSizebyte = FileToolsCommon.GetFileSize(videoinfo.VideoPath);
  1973. }
  1974. _modelVideoList.Add(videoinfo);
  1975. }
  1976. catch (Exception ex)
  1977. {
  1978. LogHelper.WriteErrLog("【加载视频列表】(LoadingVideoList)" + ex.Message, ex);
  1979. }
  1980. }
  1981. #endregion 计时器初始化
  1982. }
  1983. //翻转
  1984. if (_modelVideoList.Count > 1)
  1985. {
  1986. _modelVideoList.Reverse();
  1987. }
  1988. }
  1989. catch (Exception ex)
  1990. {
  1991. LogHelper.WriteErrLog("【加载视频列表】(LoadingVideoList)" + ex.Message, ex);
  1992. }
  1993. }
  1994. /// <summary>
  1995. /// 上传事件
  1996. /// </summary>
  1997. /// <param name="sender">
  1998. /// </param>
  1999. /// <param name="e">
  2000. /// </param>
  2001. private void BtnUpload_Click(object sender, RoutedEventArgs e)
  2002. {
  2003. if (GridMyVideo.Visibility == Visibility.Visible)
  2004. {
  2005. GridMyVideo.Visibility = Visibility.Collapsed;
  2006. GridMain.Visibility = Visibility.Visible;
  2007. GridM.IsEnabled = true;
  2008. GridRecordingTitle.Visibility = Visibility.Visible;
  2009. }
  2010. else
  2011. {
  2012. PageHide();
  2013. GridMyVideo.Visibility = Visibility.Visible;
  2014. LoadUploadInitData();
  2015. }
  2016. }
  2017. #endregion 上传 列表
  2018. #region 新上传 显示缩略图
  2019. #region 初始值
  2020. private readonly double _controlHeight = 260;
  2021. private readonly double _controlWidth = 250;
  2022. /// <summary>
  2023. /// 当前页
  2024. /// </summary>
  2025. private int _currentPage = 1;
  2026. /// <summary>
  2027. /// 横向间隔
  2028. /// </summary>
  2029. private double _intervalX;
  2030. /// <summary>
  2031. /// 纵向间隔
  2032. /// </summary>
  2033. private double _intervalY;
  2034. /// <summary>
  2035. /// 页面高
  2036. /// </summary>
  2037. private double _pageH;
  2038. /// <summary>
  2039. /// 每页显示的视频数
  2040. /// </summary>
  2041. private int _pageShowNum;
  2042. /// <summary>
  2043. /// 页面宽
  2044. /// </summary>
  2045. private double _pageW;
  2046. /// <summary>
  2047. /// 总页数
  2048. /// </summary>
  2049. private int _totalPage;
  2050. /// <summary>
  2051. /// 视频信息列表
  2052. /// </summary>
  2053. private readonly List<Uc_VideoItem> _videoControlList = new List<Uc_VideoItem>();
  2054. #endregion 初始值
  2055. /// <summary>
  2056. /// 加载当前页数据
  2057. /// </summary>
  2058. private void LoadCurrentPageData()
  2059. {
  2060. LblVideoPageNum.Content = _currentPage + "/" + _totalPage;
  2061. //隐藏显示的控件
  2062. if (_videoControlList.Count > 0)
  2063. {
  2064. foreach (Uc_VideoItem item in _videoControlList)
  2065. {
  2066. if (item.Visibility != Visibility.Hidden)
  2067. {
  2068. item.Visibility = Visibility.Hidden;
  2069. }
  2070. }
  2071. }
  2072. double w = _intervalX; //每次增加250
  2073. double h = _intervalY; //每次增加260
  2074. //加载控件
  2075. for (int i = 0; i < _pageShowNum; i++)
  2076. {
  2077. int dataIndex = (_currentPage - 1) * _pageShowNum + i;
  2078. if (dataIndex == _modelVideoList.Count)
  2079. {
  2080. return;
  2081. }
  2082. Uc_VideoItem videoItem;
  2083. if (_videoControlList.Exists(x => x.Tag.ToString() == _modelVideoList[dataIndex].FileGuid))
  2084. {
  2085. videoItem = _videoControlList.Find(x => x.Tag.ToString() == _modelVideoList[dataIndex].FileGuid);
  2086. }
  2087. else
  2088. {
  2089. if (!FileToolsCommon.IsExistFile(_modelVideoList[dataIndex].ThumbnailPath))
  2090. {
  2091. continue;
  2092. }
  2093. videoItem = new Uc_VideoItem(_modelVideoList[dataIndex]) { Tag = _modelVideoList[dataIndex].FileGuid };
  2094. videoItem.Click_refreshVideoList += LoadUploadInitData;
  2095. videoItem.Click_UploadLogin += Login;
  2096. videoItem.Width = _controlWidth;
  2097. videoItem.Height = _controlHeight;
  2098. videoItem.HorizontalAlignment = HorizontalAlignment.Left;
  2099. videoItem.VerticalAlignment = VerticalAlignment.Top;
  2100. GridMyVideo.Children.Add(videoItem);
  2101. _videoControlList.Add(videoItem);
  2102. }
  2103. videoItem.Margin = new Thickness
  2104. (
  2105. w,
  2106. h,
  2107. 0,
  2108. 0
  2109. );
  2110. videoItem.Visibility = Visibility.Visible;
  2111. if (w + _controlWidth + _controlWidth > _pageW)
  2112. {
  2113. w = _intervalX;
  2114. h += _controlHeight + _intervalY;
  2115. }
  2116. else
  2117. {
  2118. w += _controlWidth + _intervalX;
  2119. }
  2120. //Uc_VideoItem videoItem = new Uc_VideoItem();
  2121. //return;
  2122. }
  2123. }
  2124. /// <summary>
  2125. /// 初始化加载上传页面数据
  2126. /// </summary>
  2127. private void LoadUploadInitData()
  2128. {
  2129. App.myloading.Show();
  2130. //加载视频列表
  2131. LoadingVideoList();
  2132. if (_modelVideoList.Count > 0)
  2133. {
  2134. LblVideoMess.Visibility = Visibility.Hidden;
  2135. BtnVideoUpPage.Visibility = Visibility.Visible;
  2136. LblVideoPageNum.Visibility = Visibility.Visible;
  2137. BtnVideoDownPage.Visibility = Visibility.Visible;
  2138. if (GridMyVideo.ActualHeight > 0)
  2139. {
  2140. _pageW = GridMyVideo.ActualWidth;
  2141. _pageH = GridMyVideo.ActualHeight;
  2142. }
  2143. else
  2144. {
  2145. _pageW = GridRecordingArea.ActualWidth;
  2146. _pageH = GridRecordingArea.ActualHeight;
  2147. }
  2148. //获取设置控件大小 新增 页面原始1061 911
  2149. //ControlWidth = 250.00 * PropWid;
  2150. //ControlHeight = 260.00 * PropHei;
  2151. //ControlWidth=
  2152. //ControlHeight=
  2153. //根据页面大小获取每页显示的数量 H260W250
  2154. int videoRow = (int)((_pageH - 50) / _controlHeight);
  2155. int videColumn = (int)(_pageW / _controlWidth);
  2156. //横向间隔
  2157. _intervalX = (_pageW - (videColumn * _controlWidth)) / (videColumn + 1);
  2158. _intervalY = (_pageH - 50 - (videoRow * _controlHeight)) / (videoRow + 1);
  2159. _pageShowNum = (videoRow == 0 ? 1 : videoRow) * (videColumn == 0 ? 1 : videColumn);
  2160. //获取总页数
  2161. _totalPage = _modelVideoList.Count / _pageShowNum + (_modelVideoList.Count % _pageShowNum > 0 ? 1 : 0);
  2162. //如果当前页大于总页数 总页数为当前页
  2163. if (_totalPage < _currentPage)
  2164. {
  2165. _currentPage = _totalPage;
  2166. }
  2167. LoadCurrentPageData();
  2168. }
  2169. else
  2170. {
  2171. LblVideoMess.Visibility = Visibility.Visible;
  2172. BtnVideoUpPage.Visibility = Visibility.Hidden;
  2173. LblVideoPageNum.Visibility = Visibility.Hidden;
  2174. BtnVideoDownPage.Visibility = Visibility.Hidden;
  2175. //隐藏显示的控件
  2176. if (_videoControlList.Count > 0)
  2177. {
  2178. foreach (Uc_VideoItem item in _videoControlList)
  2179. {
  2180. if (item.Visibility != Visibility.Hidden)
  2181. {
  2182. item.Visibility = Visibility.Hidden;
  2183. }
  2184. }
  2185. }
  2186. }
  2187. App.myloading.Hide();
  2188. }
  2189. #region 分页
  2190. /// <summary>
  2191. /// 下一页
  2192. /// </summary>
  2193. /// <param name="sender">
  2194. /// </param>
  2195. /// <param name="e">
  2196. /// </param>
  2197. private void BtnVideoDownPage_Click(object sender, RoutedEventArgs e)
  2198. {
  2199. if (_currentPage < _totalPage)
  2200. {
  2201. _currentPage++;
  2202. LoadCurrentPageData();
  2203. }
  2204. }
  2205. /// <summary>
  2206. /// 上一页
  2207. /// </summary>
  2208. /// <param name="sender">
  2209. /// </param>
  2210. /// <param name="e">
  2211. /// </param>
  2212. private void BtnVideoUpPage_Click(object sender, RoutedEventArgs e)
  2213. {
  2214. if (_currentPage > 1)
  2215. {
  2216. _currentPage--;
  2217. LoadCurrentPageData();
  2218. }
  2219. }
  2220. #endregion 分页
  2221. #endregion 新上传 显示缩略图
  2222. #region 录屏
  2223. /// <summary>
  2224. /// 录屏事件
  2225. /// </summary>
  2226. /// <param name="sender">
  2227. /// </param>
  2228. /// <param name="e">
  2229. /// </param>
  2230. private void BtnScreenRecording_Click(object sender, RoutedEventArgs e)
  2231. {
  2232. _luoBoPenUtil.lb_device_mouse();
  2233. if (!_microphoneGood)
  2234. {
  2235. MessageWindow.Show("麦克风不可用");
  2236. return;
  2237. }
  2238. if (!_loudspeakerGood)
  2239. {
  2240. MessageWindow.Show("扬声器不可用");
  2241. return;
  2242. }
  2243. PrepareRecord();
  2244. _kHook.Stop();
  2245. if (App.W_ScreenRecordingToolbarWindow == null)
  2246. {
  2247. App.W_ScreenRecordingToolbarWindow = new ScreenRecordingToolbarWindow { Topmost = true };
  2248. App.W_ScreenRecordingToolbarWindow.Initialize();
  2249. }
  2250. else
  2251. {
  2252. App.W_ScreenRecordingToolbarWindow.Initialize();
  2253. }
  2254. App.W_ScreenRecordingToolbarWindow.ClickStopRecordingScreen += W_ScreenRecordingToolbarWindow_Click_stopRecordingScreen;
  2255. //显示在右下角
  2256. App.W_ScreenRecordingToolbarWindow.WindowStartupLocation = WindowStartupLocation.Manual;
  2257. Graphics graphics = Graphics.FromHwnd(IntPtr.Zero);
  2258. float dip = graphics.DpiX;
  2259. App.W_ScreenRecordingToolbarWindow.Left = PrimaryScreen.WorkingArea.Width / (dip / 96) - App.W_ScreenRecordingToolbarWindow.Width;
  2260. App.W_ScreenRecordingToolbarWindow.Top = PrimaryScreen.WorkingArea.Height / (dip / 96) - App.W_ScreenRecordingToolbarWindow.Height - 100;
  2261. App.W_ScreenRecordingToolbarWindow.Topmost = true;
  2262. App.W_ScreenRecordingToolbarWindow.Show();
  2263. Hide();
  2264. }
  2265. /// <summary>
  2266. /// 保存录屏中
  2267. /// </summary>
  2268. private void W_ScreenRecordingToolbarWindow_Click_stopRecordingScreen()
  2269. {
  2270. TxbTime.Text = "00:00";
  2271. TxbType.Text = "保存中";
  2272. _recordType = 4;
  2273. RecordBtnStatus();
  2274. new Thread
  2275. (
  2276. () =>
  2277. {
  2278. while (FileToolsCommon.IsExistDirectory(App.WKData.WkPath + "_temppath/"))
  2279. {
  2280. Thread.Sleep(100);
  2281. }
  2282. Thread.Sleep(100);
  2283. Dispatcher.Invoke
  2284. (
  2285. () =>
  2286. {
  2287. _recordType = 0;
  2288. RecordBtnStatus();
  2289. }
  2290. );
  2291. }
  2292. ).Start();
  2293. }
  2294. #endregion 录屏
  2295. #region 录制窗口
  2296. #region 变量
  2297. /// <summary>
  2298. /// 录制大小
  2299. /// </summary>
  2300. private int _gridActHeight = 898;
  2301. /// <summary>
  2302. /// 录制大小
  2303. /// </summary>
  2304. private int _gridActWidth = 1276;
  2305. /// <summary>
  2306. /// 录制类型 0停止,1录制中,2暂停中 3倒计时 4合并中
  2307. /// </summary>
  2308. private int _recordType;
  2309. /// <summary>
  2310. /// 录制计时
  2311. /// </summary>
  2312. private DateTime _srTime = DateTime.Now;
  2313. /// <summary>
  2314. /// 音频保存路径名
  2315. /// </summary>
  2316. private string _tempAudioPathName;
  2317. /// <summary>
  2318. /// 视频合成前路径名
  2319. /// </summary>
  2320. private string _tempVideoPathName;
  2321. /// <summary>
  2322. /// 截图定时器
  2323. /// </summary>
  2324. private Timer _timer;
  2325. /// <summary>
  2326. /// 视频保存路径名
  2327. /// </summary>
  2328. private string _videoSavePathName;
  2329. #endregion 变量
  2330. private bool _isPressButton;
  2331. //视频写入
  2332. private readonly VideoFileWriter _videoWriter = new VideoFileWriter();
  2333. //录制麦克风的声音
  2334. private WaveInEvent _waveIn;
  2335. private bool _waveInRuning;
  2336. //音频写入
  2337. private WaveFileWriter _writer;
  2338. /// <summary>
  2339. /// 录制窗口内容
  2340. /// </summary>
  2341. /// <param name="sender">
  2342. /// </param>
  2343. /// <param name="e">
  2344. /// </param>
  2345. private void BtnRecord_Click(object sender, RoutedEventArgs e)
  2346. {
  2347. RecordAction();
  2348. }
  2349. private async void RecordAction()
  2350. {
  2351. #region 防止连击
  2352. if (_isPressButton)
  2353. {
  2354. return;
  2355. }
  2356. _isPressButton = true;
  2357. new Thread
  2358. (
  2359. () =>
  2360. {
  2361. Thread.Sleep(500);
  2362. _isPressButton = false;
  2363. }
  2364. ).Start();
  2365. #endregion 防止连击
  2366. if (_recordType == 4)
  2367. {
  2368. return;
  2369. }
  2370. if (_recordType != 0)
  2371. {
  2372. if (_recordType == 1)
  2373. {
  2374. //录制中暂停
  2375. _recordType = 2;
  2376. RecordBtnStatus();
  2377. }
  2378. else if (_recordType == 2)
  2379. {
  2380. //暂停中继续录制
  2381. _recordType = 1;
  2382. RecordBtnStatus();
  2383. }
  2384. }
  2385. else
  2386. {
  2387. if (App.PageContextData.currpage == 0)
  2388. {
  2389. MessageWindow.Show("请先导入文档或截图!");
  2390. return;
  2391. }
  2392. StartPauseGrid.Visibility = Visibility.Hidden;
  2393. StopGrid.Visibility = Visibility.Hidden;
  2394. CloseGrid.Visibility = Visibility.Hidden;
  2395. if (!_microphoneGood)
  2396. {
  2397. StartPauseGrid.Visibility = Visibility.Visible;
  2398. StopGrid.Visibility = Visibility.Visible;
  2399. CloseGrid.Visibility = Visibility.Visible;
  2400. MessageWindow.Show("麦克风不可用");
  2401. return;
  2402. }
  2403. BlackboardCanvas.Visibility = Visibility.Visible;
  2404. if (RectImgBorder.Visibility != Visibility.Hidden)
  2405. {
  2406. HideAngleBorder();
  2407. }
  2408. PrepareRecord();
  2409. BtnPrint.IsEnabled = false;
  2410. BtnScreenshot.IsEnabled = false;
  2411. BtnImport.IsEnabled = false;
  2412. BtnScreenRecording.IsEnabled = false;
  2413. BtnUpload.IsEnabled = false;
  2414. BtnSetUp.IsEnabled = false;
  2415. BtnDevice.IsEnabled = false;
  2416. BtnLoginType.IsEnabled = false;
  2417. BlackboardCanvas.Visibility = Visibility.Visible;
  2418. TxbType.Text = "准备录制";
  2419. BtnRecord.Visibility = Visibility.Collapsed;
  2420. BtnRecordSuspend.Visibility = Visibility.Visible;
  2421. BtnRecord.IsEnabled = true;
  2422. BtnStop.IsEnabled = true;
  2423. #region 录像倒计时
  2424. if (App.W_CountdownWindow == null)
  2425. {
  2426. App.W_CountdownWindow = new CountdownWindow();
  2427. App.W_CountdownWindow.Initialize();
  2428. }
  2429. else
  2430. {
  2431. App.W_CountdownWindow.Initialize();
  2432. }
  2433. App.W_CountdownWindow.Show();
  2434. #endregion 录像倒计时
  2435. await Task.Delay(3000);
  2436. //停止中开始录制
  2437. CloseGrid.Visibility = Visibility.Visible;
  2438. _recordType = 1;
  2439. RecordBtnStatus();
  2440. await StartRecord();
  2441. StartPauseGrid.Visibility = Visibility.Visible;
  2442. StopGrid.Visibility = Visibility.Visible;
  2443. }
  2444. RecordBtnStatus();
  2445. }
  2446. private void RecordBtnStatus()
  2447. {
  2448. if (_recordType == 0)
  2449. {
  2450. StartPauseGrid.Visibility = Visibility.Visible;
  2451. TxbType.Text = "准备录制";
  2452. BtnRecord.Visibility = Visibility.Visible;
  2453. BtnRecordSuspend.Visibility = Visibility.Collapsed;
  2454. BtnScreenRecording.IsEnabled = true;
  2455. BtnRecord.IsEnabled = true;
  2456. BtnStop.IsEnabled = false;
  2457. }
  2458. else if (_recordType == 1)
  2459. {
  2460. StartPauseGrid.Visibility = Visibility.Visible;
  2461. TxbType.Text = "录制中";
  2462. BtnRecord.Visibility = Visibility.Collapsed;
  2463. BtnRecordSuspend.Visibility = Visibility.Visible;
  2464. }
  2465. else if (_recordType == 2)
  2466. {
  2467. StartPauseGrid.Visibility = Visibility.Visible;
  2468. TxbType.Text = "暂停中";
  2469. BtnRecord.Visibility = Visibility.Visible;
  2470. BtnRecordSuspend.Visibility = Visibility.Collapsed;
  2471. }
  2472. else if (_recordType == 3)
  2473. {
  2474. TxbType.Text = "倒计时";
  2475. }
  2476. else if (_recordType == 4)
  2477. {
  2478. TxbType.Text = "合并中";
  2479. StartPauseGrid.Visibility = Visibility.Hidden;
  2480. BtnScreenRecording.IsEnabled = false;
  2481. }
  2482. }
  2483. /// <summary>
  2484. /// 停止录制窗口内容
  2485. /// </summary>
  2486. /// <param name="sender">
  2487. /// </param>
  2488. /// <param name="e">
  2489. /// </param>
  2490. private async void BtnStop_Click(object sender, RoutedEventArgs e)
  2491. {
  2492. #region 防止连击
  2493. if (_isPressButton)
  2494. {
  2495. return;
  2496. }
  2497. else
  2498. {
  2499. _isPressButton = true;
  2500. new Thread
  2501. (
  2502. () =>
  2503. {
  2504. Thread.Sleep(500);
  2505. _isPressButton = false;
  2506. }
  2507. ).Start();
  2508. }
  2509. #endregion 防止连击
  2510. if (_recordType != 0)
  2511. {
  2512. _recordType = 4;
  2513. BlackboardCanvas.Visibility = Visibility.Collapsed;
  2514. RecordBtnStatus();
  2515. //鼠标模式
  2516. _luoBoPenUtil.lb_device_mouse();
  2517. await EndRecord();
  2518. _recordType = 0;
  2519. RecordBtnStatus();
  2520. }
  2521. }
  2522. /// <summary>
  2523. /// 停止录制并生成录制文件
  2524. /// </summary>
  2525. private async Task EndRecord()
  2526. {
  2527. #region 恢复被禁用的按钮
  2528. BtnScreenshot.IsEnabled = true;
  2529. BtnImport.IsEnabled = true;
  2530. BtnScreenRecording.IsEnabled = true;
  2531. BtnUpload.IsEnabled = true;
  2532. BtnSetUp.IsEnabled = true;
  2533. BtnDevice.IsEnabled = true;
  2534. BtnLoginType.IsEnabled = true;
  2535. #endregion 恢复被禁用的按钮
  2536. App.PageContextData.currpage = 0;
  2537. App.PageContextData.pagenum = 0;
  2538. myblackboard.clear();
  2539. App.PageDrawList.Clear();
  2540. ImgCanvas.Source = null;
  2541. ImgDocumentation.Source = null;
  2542. ImgPpt.Source = null;
  2543. GridPage.Visibility = Visibility.Collapsed;
  2544. BtnRecord.IsEnabled = false;
  2545. BtnStop.IsEnabled = false;
  2546. BtnScreenRecording.IsEnabled = false;
  2547. _timer.Change(-1, 0);
  2548. _timer.Dispose();
  2549. TxbTime.Text = "00:00";
  2550. TxbType.Text = "保存中";
  2551. _recordType = 4;
  2552. RecordBtnStatus();
  2553. await Task.Run
  2554. (
  2555. () =>
  2556. {
  2557. try
  2558. {
  2559. _videoWriter.Close();
  2560. _waveIn.StopRecording();
  2561. //等待音频结束回调
  2562. while (_waveInRuning)
  2563. {
  2564. Thread.Sleep(300);
  2565. }
  2566. Process[] killProcessArray = Process.GetProcessesByName("ffmpeg");
  2567. foreach (Process killProcess in killProcessArray)
  2568. {
  2569. killProcess.Kill();
  2570. }
  2571. FFMpegConverter ffMpeg = new FFMpegConverter();
  2572. FFMpegInput[] input = new FFMpegInput[]
  2573. {
  2574. new FFMpegInput(_tempVideoPathName),
  2575. new FFMpegInput(_tempAudioPathName)
  2576. };
  2577. // 音视频合并
  2578. ffMpeg.ConvertMedia
  2579. (
  2580. input,
  2581. _videoSavePathName,
  2582. "mp4",
  2583. new OutputSettings()
  2584. );
  2585. //生成缩略图
  2586. string thumbnailPath = FileToolsCommon.GetDirectoryName(_videoSavePathName) + "ThumbnailPath/";
  2587. FileToolsCommon.CreateDirectory(thumbnailPath);
  2588. //缩略图存储位置
  2589. string thumbnailPathName = thumbnailPath + FileToolsCommon.GetIOFileName(_videoSavePathName).Replace(".", "") + ".JPG";
  2590. FileToolsCommon.DeleteFile(thumbnailPathName);
  2591. _videoInfo.RSTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  2592. _videoInfo.VideoPath = _videoSavePathName;
  2593. _videoInfo.ThumbnailPath = thumbnailPathName;
  2594. _videoInfo.FileGuid = Guid.NewGuid().ToString();
  2595. _videoInfo.IsUpload = false;
  2596. _videoInfo.Uploaded = 0;
  2597. try
  2598. {
  2599. App.FFmpeg.GenerateThumbnails
  2600. (
  2601. _tempVideoPathName,
  2602. thumbnailPathName,
  2603. 200,
  2604. 130
  2605. );
  2606. }
  2607. catch (Exception ex)
  2608. {
  2609. LogHelper.WriteErrLog("录制生成缩略图", ex);
  2610. }
  2611. if (!App.VideoList.Exists(x => x.FileGuid == _videoInfo.FileGuid) || !App.VideoList.Exists(x => x.VideoPath == _videoInfo.VideoPath))
  2612. {
  2613. App.VideoList.Add(_videoInfo);
  2614. //保存数据
  2615. App.SaveWkData();
  2616. }
  2617. try
  2618. {
  2619. FileToolsCommon.DeleteFile(_tempVideoPathName);
  2620. FileToolsCommon.DeleteFile(_tempAudioPathName);
  2621. }
  2622. catch (Exception ex)
  2623. {
  2624. LogHelper.WriteErrLog("删除录制临时文件", ex);
  2625. }
  2626. }
  2627. catch (Exception ex)
  2628. {
  2629. Dispatcher.Invoke
  2630. (
  2631. () =>
  2632. {
  2633. MessageWindow.Show(ex.Message);
  2634. }
  2635. );
  2636. }
  2637. }
  2638. );
  2639. BtnRecord.IsEnabled = true;
  2640. BtnStop.IsEnabled = false;
  2641. BtnPrint.IsEnabled = false;
  2642. BtnScreenRecording.IsEnabled = true;
  2643. TxbType.Text = "准备就绪";
  2644. _recordType = 0;
  2645. RecordBtnStatus();
  2646. }
  2647. /// <summary>
  2648. /// 录制保存图片
  2649. /// </summary>
  2650. private void RecordSaveImage()
  2651. {
  2652. try
  2653. {
  2654. //保存图片
  2655. try
  2656. {
  2657. Dispatcher.Invoke
  2658. (
  2659. () =>
  2660. {
  2661. Bitmap bm = ImageHelper.SaveUI2Bitmap
  2662. (
  2663. GridMain,
  2664. _gridActWidth,
  2665. _gridActHeight
  2666. );
  2667. _videoWriter.WriteVideoFrame(bm);
  2668. bm.Dispose();
  2669. }
  2670. );
  2671. }
  2672. catch (Exception e)
  2673. {
  2674. Console.WriteLine(e.Message);
  2675. }
  2676. }
  2677. catch (Exception ex)
  2678. {
  2679. LogHelper.WriteErrLog("【录制】(Timer_Elapsed)生成图片错误:" + ex.Message, ex);
  2680. }
  2681. }
  2682. //new WaveInEvent();
  2683. /// <summary>
  2684. /// 开始录制和暂停录制
  2685. /// </summary>
  2686. private async Task StartRecord()
  2687. {
  2688. await Task.Run
  2689. (
  2690. () =>
  2691. {
  2692. //电子版切换笔模式
  2693. _luoBoPenUtil.lb_device_hand();
  2694. _videoInfo = new Model_Video
  2695. {
  2696. VideoType = (Enum_VideoType)int.Parse(FileToolsCommon.GetConfigValue("VideoType")),
  2697. WkType = Enum_WKVidetype.RecordingLessons
  2698. };
  2699. FileToolsCommon.DeleteDirectory(App.WKData.WkPath + "temp/");
  2700. FileToolsCommon.CreateDirectory(App.WKData.WkPath);
  2701. _videoSavePathName = App.WKData.WkPath + App.WKData.WkName + "_录制." + _videoInfo.VideoType.ToString();
  2702. _tempVideoPathName = App.WKData.WkPath + App.WKData.WkName + "_录制Syn.avi";
  2703. int num = 1;
  2704. while (FileToolsCommon.IsExistFile(_videoSavePathName))
  2705. {
  2706. _videoSavePathName = App.WKData.WkPath + App.WKData.WkName + "_录制_" + num + "." + _videoInfo.VideoType.ToString();
  2707. _tempVideoPathName = App.WKData.WkPath + App.WKData.WkName + "_录制Syn_" + num + ".avi";
  2708. num++;
  2709. }
  2710. _tempAudioPathName = _tempVideoPathName.Replace(".avi", ".mp3");
  2711. _gridActWidth = (int)(GridMain.ActualWidth * (PrimaryScreen.DpiX / 96f) / 2) * 2;
  2712. _gridActHeight = (int)(GridMain.ActualHeight * (PrimaryScreen.DpiY / 96f) / 2) * 2;
  2713. lock (this)
  2714. {
  2715. _videoWriter.Open
  2716. (
  2717. _tempVideoPathName,
  2718. _gridActWidth,
  2719. _gridActHeight,
  2720. 5,
  2721. VideoCodec.MPEG4,
  2722. _gridActWidth * _gridActHeight * 10
  2723. );
  2724. _waveIn = new WaveInEvent();
  2725. _waveInRuning = true;
  2726. _writer = new WaveFileWriter(_tempAudioPathName, _waveIn.WaveFormat);
  2727. //开始录音,写数据
  2728. _waveIn.DataAvailable += (s, a) =>
  2729. {
  2730. if (_recordType == 1)
  2731. {
  2732. _writer.Write
  2733. (
  2734. a.Buffer,
  2735. 0,
  2736. a.BytesRecorded
  2737. );
  2738. }
  2739. };
  2740. //结束录音
  2741. _waveIn.RecordingStopped += (s, a) =>
  2742. {
  2743. _writer.Dispose();
  2744. _writer = null;
  2745. _waveIn.Dispose();
  2746. _waveInRuning = false;
  2747. };
  2748. _waveIn.StartRecording();
  2749. }
  2750. }
  2751. );
  2752. _srTime = Convert.ToDateTime("2020-01-01 00:00:00");
  2753. //启动截图
  2754. _timer = new Timer
  2755. (
  2756. Timer_Elapsed,
  2757. null,
  2758. 0,
  2759. 200
  2760. );
  2761. }
  2762. /// <summary>
  2763. /// 录制保存图片计时器
  2764. /// </summary>
  2765. /// <param name="sender">
  2766. /// </param>
  2767. private void Timer_Elapsed(object sender)
  2768. {
  2769. if (_recordType == 1)
  2770. {
  2771. Dispatcher.Invoke
  2772. (
  2773. () =>
  2774. {
  2775. _srTime = _srTime.AddMilliseconds(200);
  2776. if (_srTime.Hour > 0)
  2777. {
  2778. TxbTime.Text = _srTime.ToString("HH:mm:ss");
  2779. }
  2780. else
  2781. {
  2782. TxbTime.Text = _srTime.ToString("mm:ss");
  2783. }
  2784. }
  2785. );
  2786. ThreadPool.QueueUserWorkItem
  2787. (
  2788. o =>
  2789. {
  2790. RecordSaveImage();
  2791. }
  2792. );
  2793. }
  2794. }
  2795. #endregion 录制窗口
  2796. #region 分页
  2797. private void ImgXy()
  2798. {
  2799. ImgCanvas.Width = App.PageDrawList[App.PageContextData.currpage - 1].ImageSizes.CenterX;
  2800. ImgCanvas.Height = App.PageDrawList[App.PageContextData.currpage - 1].ImageSizes.CenterY;
  2801. ImgCanvas.Margin = new Thickness
  2802. (
  2803. App.PageDrawList[App.PageContextData.currpage - 1].ImageLocation.X,
  2804. App.PageDrawList[App.PageContextData.currpage - 1].ImageLocation.Y,
  2805. 0,
  2806. 0
  2807. );
  2808. }
  2809. /// <summary>
  2810. /// 跳转
  2811. /// </summary>
  2812. private void JumpPageClick()
  2813. {
  2814. myblackboard.changepage(App.PageContextData.currpage - 1);
  2815. ScroMain.ScrollToVerticalOffset(0);
  2816. if (BtnImport.IsEnabled)
  2817. {
  2818. //截图可用
  2819. BtnScreenshot.IsEnabled = true;
  2820. }
  2821. if (App.PageContextData.currpage <= App.PageDrawList.Count)
  2822. {
  2823. if (App.PageDrawList[App.PageContextData.currpage - 1].ImageLocation != null)
  2824. {
  2825. App.PageDrawList[App.PageContextData.currpage - 1].IsImageLocation = true;
  2826. }
  2827. if (!string.IsNullOrWhiteSpace(TxbCurrpage.Text) && App.PageContextData.currpage <= App.PageDrawList.Count && App.PageContextData.currpage > 0 && !string.IsNullOrWhiteSpace(App.PageDrawList[App.PageContextData.currpage - 1].PageImagePath))
  2828. {
  2829. if (App.PageDrawList[App.PageContextData.currpage - 1].ImgDocumentation)
  2830. {
  2831. if ("ppt".Equals(App.PageDrawList[App.PageContextData.currpage - 1].Type))
  2832. {
  2833. ImgCanvas.Source = null;
  2834. ImgDocumentation.Source = null;
  2835. ImgPpt.Source = new BitmapImage(new Uri(App.PageDrawList[App.PageContextData.currpage - 1].PageImagePath));
  2836. BtnScreenshot.IsEnabled = false;
  2837. }
  2838. else
  2839. {
  2840. ImgPpt.Source = null;
  2841. ImgCanvas.Source = null;
  2842. ImgDocumentation.Source = new BitmapImage(new Uri(App.PageDrawList[App.PageContextData.currpage - 1].PageImagePath));
  2843. BtnScreenshot.IsEnabled = false;
  2844. }
  2845. }
  2846. else
  2847. {
  2848. ImgPpt.Source = null;
  2849. ImgDocumentation.Source = null;
  2850. ImgCanvas.Source = new BitmapImage(new Uri(App.PageDrawList[App.PageContextData.currpage - 1].PageImagePath));
  2851. App.PageDrawList[App.PageContextData.currpage - 1].IsImageLocation = false;
  2852. if (App.PageDrawList[App.PageContextData.currpage - 1].ImageLocation != null && App.PageDrawList[App.PageContextData.currpage - 1].ImageLocation.X > 0)
  2853. {
  2854. _mouseDown = false;
  2855. _imageOperationUtil.setMouseDown(_mouseDown);
  2856. ImgXy();
  2857. }
  2858. }
  2859. }
  2860. else
  2861. {
  2862. ImgPpt.Source = null;
  2863. ImgCanvas.Source = null;
  2864. ImgDocumentation.Source = null;
  2865. }
  2866. }
  2867. }
  2868. // 上一页
  2869. private void last_button_Click(object sender, RoutedEventArgs e)
  2870. {
  2871. if (App.PageContextData.currpage > 1)
  2872. {
  2873. _mouseDown = false;
  2874. _imageOperationUtil.setMouseDown(_mouseDown);
  2875. HideAngleBorder();
  2876. App.PageContextData.currpage -= 1;
  2877. JumpPageClick();
  2878. }
  2879. }
  2880. /// <summary>
  2881. /// 下一页
  2882. /// </summary>
  2883. /// <param name="sender">
  2884. /// </param>
  2885. /// <param name="e">
  2886. /// </param>
  2887. private void next_btn_Click(object sender, RoutedEventArgs e)
  2888. {
  2889. if (App.PageContextData.currpage < App.PageContextData.pagenum)
  2890. {
  2891. _mouseDown = false;
  2892. _imageOperationUtil.setMouseDown(_mouseDown);
  2893. HideAngleBorder();
  2894. App.PageContextData.currpage += 1;
  2895. JumpPageClick();
  2896. }
  2897. }
  2898. #endregion 分页
  2899. #region 图像缩放,移动
  2900. private bool _mouseDown;
  2901. #endregion 图像缩放,移动
  2902. #region 更改设备连接状态
  2903. /// <summary>
  2904. /// 更新设备状态显示
  2905. /// </summary>
  2906. public void UpdateDevStatus()
  2907. {
  2908. if (App.BoardStatus && (App.PenStatus || App.TQLPenStatus))
  2909. {
  2910. Dispatcher.Invoke
  2911. (
  2912. () =>
  2913. {
  2914. TxbNotConnected.Text = "笔/板已连接";
  2915. TxbNotConnecteds.Text = "笔/板已连接";
  2916. }
  2917. );
  2918. }
  2919. else if (App.BoardStatus)
  2920. {
  2921. Dispatcher.Invoke
  2922. (
  2923. () =>
  2924. {
  2925. TxbNotConnected.Text = "手写板已连接";
  2926. TxbNotConnecteds.Text = "手写板已连接";
  2927. }
  2928. );
  2929. }
  2930. else if (App.PenStatus)
  2931. {
  2932. Dispatcher.Invoke
  2933. (
  2934. () =>
  2935. {
  2936. TxbNotConnected.Text = "智能笔已连接";
  2937. TxbNotConnecteds.Text = "智能笔已连接";
  2938. }
  2939. );
  2940. }
  2941. else if (App.TQLPenStatus)
  2942. {
  2943. Dispatcher.Invoke
  2944. (
  2945. () =>
  2946. {
  2947. TxbNotConnected.Text = "智能笔已连接";
  2948. TxbNotConnecteds.Text = "智能笔已连接";
  2949. }
  2950. );
  2951. }
  2952. else
  2953. {
  2954. Dispatcher.Invoke
  2955. (
  2956. () =>
  2957. {
  2958. TxbNotConnected.Text = "未连接";
  2959. TxbNotConnecteds.Text = "未连接";
  2960. }
  2961. );
  2962. }
  2963. }
  2964. #endregion 更改设备连接状态
  2965. #region 腾千里手写笔
  2966. private const float TQLA4_HEIGHT = 1.0f * 3509 / 300 * (float)25.4 / (float)1.524;
  2967. /// <summary>
  2968. /// TQL点阵笔宽高
  2969. /// </summary>
  2970. private const float TQLA4_WIDTH = 1.0f * 2480 / 300 * (float)25.4 / (float)1.524;
  2971. /// <summary>
  2972. /// 是否在书写
  2973. /// </summary>
  2974. private bool _isTqlPenDown;
  2975. //(float)1075 / (float)150 * (float)25.4 / (float)1.524; //OID4
  2976. //(float)1512 / (float)150 * (float)25.4 / (float)1.524;
  2977. /// <summary>
  2978. /// TQL初始化
  2979. /// </summary>
  2980. public void InitTqlpPen()
  2981. {
  2982. if (App.TQLPenevents == null)
  2983. {
  2984. App.TQLPenevents = new PenEvents(1);
  2985. }
  2986. else
  2987. {
  2988. App.TQLPenevents.InToType = 1;
  2989. }
  2990. }
  2991. /// <summary>
  2992. /// 笔落下
  2993. /// </summary>
  2994. public void TqlDown()
  2995. {
  2996. _isTqlPenDown = true;
  2997. if (App.PageContextData.currpage > 0)
  2998. {
  2999. Dispatcher.Invoke
  3000. (
  3001. () =>
  3002. {
  3003. myblackboard.changepages
  3004. (
  3005. 0,
  3006. 0,
  3007. true,
  3008. _color,
  3009. _penSize,
  3010. App.PageContextData.currpage - 1,
  3011. 0
  3012. );
  3013. }
  3014. );
  3015. }
  3016. }
  3017. /// <summary>
  3018. /// 笔书写
  3019. /// </summary>
  3020. /// <param name="cx">
  3021. /// </param>
  3022. /// <param name="cy">
  3023. /// </param>
  3024. /// <param name="force">
  3025. /// </param>
  3026. public void TqlPenWrite
  3027. (
  3028. double cx,
  3029. double cy,
  3030. int force
  3031. )
  3032. {
  3033. //判断是否是落笔后输出的坐标,在设置悬浮模式下,落笔前的悬浮坐标不绘制
  3034. if (!_isTqlPenDown)
  3035. {
  3036. return;
  3037. }
  3038. double propW = BlackboardCanvas.ActualWidth / TQLA4_WIDTH;
  3039. double propH = BlackboardCanvas.ActualHeight / TQLA4_HEIGHT;
  3040. //点
  3041. double tempX = cx * propW;
  3042. double tempY = cy * propH;
  3043. if (App.PageContextData.currpage > 0)
  3044. {
  3045. Dispatcher.Invoke
  3046. (
  3047. () =>
  3048. {
  3049. //0~1023,亦即有 1024 阶供应用软件后续应用之用,如笔锋笔触,暂无用
  3050. float pressure = 1.0f * force / 1023f;
  3051. myblackboard.changepages
  3052. (
  3053. tempX,
  3054. tempY,
  3055. false,
  3056. _color,
  3057. _penSize,
  3058. App.PageContextData.currpage - 1,
  3059. pressure
  3060. );
  3061. #region 设置滚动条位置
  3062. //点在显示页面上方
  3063. if (tempY < ScroMain.VerticalOffset)
  3064. {
  3065. //滚动条当前位置
  3066. double rollCurrentLocation = ScroMain.VerticalOffset;
  3067. //向上滚动至以点为中心需要滚动的距离
  3068. double upRoll = (rollCurrentLocation - tempY) + (ScroMain.ActualHeight / 2);
  3069. //如果小于0则等于0
  3070. double rollLocation = rollCurrentLocation - upRoll;
  3071. if (rollLocation < 0)
  3072. {
  3073. rollLocation = 0;
  3074. }
  3075. ////滚动条实际偏移量
  3076. //double RollOffset = RollCurrentLocation - RollLocation;
  3077. ScroMain.ScrollToVerticalOffset(rollLocation);
  3078. }
  3079. //点在显示页面下方
  3080. if (tempY > ScroMain.VerticalOffset + ScroMain.ActualHeight)
  3081. {
  3082. //滚动条当前位置
  3083. double rollCurrentLocation = ScroMain.VerticalOffset;
  3084. //向下滚动至以点为中心需要滚动的距离
  3085. double downRoll = (tempY - rollCurrentLocation) - (ScroMain.ActualHeight / 2);
  3086. //如果小于0则等于0
  3087. double rollLocation = rollCurrentLocation + downRoll;
  3088. //滚动条最大滚动值
  3089. double scrollbarMaxNum = GridM.ActualHeight - ScroMain.ActualHeight;
  3090. if (rollLocation > scrollbarMaxNum)
  3091. {
  3092. rollLocation = scrollbarMaxNum;
  3093. }
  3094. ////滚动条实际偏移量
  3095. //double RollOffset = RollLocation-RollCurrentLocation;
  3096. ScroMain.ScrollToVerticalOffset(rollLocation);
  3097. }
  3098. #endregion 设置滚动条位置
  3099. if (tempX > 0 && tempY > 0)
  3100. {
  3101. System.Windows.Point getP = ScroMain.PointToScreen(new System.Windows.Point(tempX, tempY - ScroMain.VerticalOffset));
  3102. SetCursorPos((int)getP.X, (int)getP.Y);
  3103. }
  3104. }
  3105. );
  3106. }
  3107. }
  3108. /// <summary>
  3109. /// 笔抬起
  3110. /// </summary>
  3111. public void TqlUp()
  3112. {
  3113. _isTqlPenDown = false;
  3114. //stroke.Clear();
  3115. if (App.PageContextData.currpage > 0)
  3116. {
  3117. Dispatcher.Invoke
  3118. (
  3119. () =>
  3120. {
  3121. myblackboard.changepages
  3122. (
  3123. 0,
  3124. 0,
  3125. true,
  3126. _color,
  3127. _penSize,
  3128. App.PageContextData.currpage - 1,
  3129. 0
  3130. );
  3131. }
  3132. );
  3133. }
  3134. }
  3135. #endregion 腾千里手写笔
  3136. #region 图片拉伸移动
  3137. /// <summary>
  3138. /// 隐藏图片四个点和线
  3139. /// </summary>
  3140. private void HideAngleBorder()
  3141. {
  3142. _imageOperationUtil.HideAngleBorder();
  3143. }
  3144. private void imgCanvas_MouseMove(object sender, MouseEventArgs e)
  3145. {
  3146. _imageOperationUtil.imgCanvas_MouseMove(sender, e);
  3147. }
  3148. private void imgCanvas_MouseUp(object sender, MouseButtonEventArgs e)
  3149. {
  3150. _imageOperationUtil.imgCanvas_MouseUp();
  3151. }
  3152. private void PicEMap_MouseDown(object sender, MouseButtonEventArgs e)
  3153. {
  3154. _imageOperationUtil.PicEMap_MouseDown(sender, e);
  3155. }
  3156. private void RectRightUp_DragCompleted(object sender, System.Windows.Controls.Primitives.DragCompletedEventArgs e)
  3157. {
  3158. _imageOperationUtil.RectRightUp_DragCompleted();
  3159. }
  3160. private void RectRightUp_DragDelta(object sender, System.Windows.Controls.Primitives.DragDeltaEventArgs e)
  3161. {
  3162. _imageOperationUtil.RectRightUp_DragDelta(sender, e);
  3163. }
  3164. private void RectRightUp_DragStarted(object sender, System.Windows.Controls.Primitives.DragStartedEventArgs e)
  3165. {
  3166. _imageOperationUtil.RectRightUp_DragStarted(sender, e);
  3167. }
  3168. /// <summary>
  3169. /// 鼠标左键点击事件
  3170. /// </summary>
  3171. /// <param name="sender">
  3172. /// </param>
  3173. /// <param name="e">
  3174. /// </param>
  3175. private void Window_MouseLeftButtonDown_1(object sender, MouseButtonEventArgs e)
  3176. {
  3177. _imageOperationUtil.Window_MouseLeftButtonDown_1();
  3178. }
  3179. #endregion 图片拉伸移动
  3180. #region 录屏 录制 截图 导入文档 增加 主页面显示
  3181. /// <summary>
  3182. /// 录屏 录制 截图 导入文档 增加 主页面显示
  3183. /// </summary>
  3184. private void PrepareRecord()
  3185. {
  3186. PageHide();
  3187. GridMain.Visibility = Visibility.Visible;
  3188. GridRecordingTitle.Visibility = Visibility.Visible;
  3189. if (App.PageContextData.pagenum > 0)
  3190. {
  3191. GridPage.Visibility = Visibility.Visible;
  3192. }
  3193. DataContext = App.PageContextData;
  3194. }
  3195. #endregion 录屏 录制 截图 导入文档 增加 主页面显示
  3196. #region 页码跳转
  3197. #endregion 页码跳转
  3198. #region TQL打印
  3199. public static string gPrintFileName;
  3200. private iTextSharp.text.Document _document;
  3201. private bool _gbInitDone;
  3202. /// <summary>
  3203. /// 授权码
  3204. /// </summary>
  3205. private string _gKeyStr;
  3206. private readonly TmatrixClass _tmc = new TmatrixClass();
  3207. /// <summary>
  3208. /// 授权文件位置
  3209. /// </summary>
  3210. private string _tqlAuthorizationPath;
  3211. /// <summary>
  3212. /// 铺码
  3213. /// </summary>
  3214. private bool GenerateCode(string pdfPath)
  3215. {
  3216. try
  3217. {
  3218. if (_gbInitDone == false)
  3219. {
  3220. MessageWindow.Show("打印功能无法使用,无效授权。");
  3221. return false;
  3222. }
  3223. try
  3224. {
  3225. string directoryPath = FileToolsCommon.GetDirectoryName(pdfPath);
  3226. FileToolsCommon.DeleteDirectory(directoryPath + "Bg with Images/");
  3227. FileToolsCommon.DeleteDirectory(directoryPath + "Bg with Vector Images/");
  3228. FileToolsCommon.DeleteDirectory(directoryPath + "Bg without Vector Images/");
  3229. FileToolsCommon.DeleteDirectory(directoryPath + "Vector Images/");
  3230. }
  3231. catch (Exception)
  3232. {
  3233. // ignored
  3234. }
  3235. pdfPath = pdfPath.Replace("/", "\\");
  3236. //初始页
  3237. bool[] bPublishImageType = new bool[4];
  3238. bPublishImageType[0] = false;
  3239. bPublishImageType[1] = false;
  3240. bPublishImageType[2] = false;
  3241. bPublishImageType[3] = true;
  3242. int[] gPointType =
  3243. {
  3244. 0,
  3245. 0,
  3246. 0,
  3247. 0,
  3248. 1
  3249. };
  3250. int[] gPointDpi =
  3251. {
  3252. 0,
  3253. 0,
  3254. 0,
  3255. 0,
  3256. 1
  3257. };
  3258. string sGenerateResult = _tmc.GenerateTmatrixCode_OID4
  3259. (
  3260. _gKeyStr,
  3261. pdfPath,
  3262. 0,
  3263. gPointType,
  3264. bPublishImageType,
  3265. gPointDpi
  3266. );
  3267. if (sGenerateResult.Substring(0, 1) == "1")
  3268. {
  3269. Dispatcher.Invoke
  3270. (
  3271. () =>
  3272. {
  3273. MessageWindow.Show("打印功能无法使用,无效授权。");
  3274. }
  3275. );
  3276. return false;
  3277. }
  3278. return true;
  3279. }
  3280. catch (Exception ex)
  3281. {
  3282. Dispatcher.Invoke
  3283. (
  3284. () =>
  3285. {
  3286. MessageWindow.Show("打印失败:" + ex.Message);
  3287. }
  3288. );
  3289. return false;
  3290. }
  3291. }
  3292. /// <summary>
  3293. /// TQL初始化打印
  3294. /// </summary>
  3295. private void TqlPrintInit()
  3296. {
  3297. //初始化
  3298. if (_tmc.TmatrixInitialize() == false)
  3299. {
  3300. }
  3301. else
  3302. {
  3303. _gbInitDone = true;
  3304. }
  3305. _document = new iTextSharp.text.Document
  3306. (
  3307. iTextSharp.text.PageSize.A4,
  3308. 0,
  3309. 0,
  3310. 0,
  3311. 0
  3312. );
  3313. try
  3314. {
  3315. _tqlAuthorizationPath = FileToolsCommon.GetFileAbsolutePath("/LatticeXML/S0_O000_B0000_P000-255.tmx");
  3316. StreamReader gsr = new StreamReader(_tqlAuthorizationPath);
  3317. _gKeyStr = gsr.ReadLine();
  3318. gsr.Close();
  3319. string keyCheckResult = _tmc.TmatrixKeyCheck_OID4(_gKeyStr);
  3320. if (keyCheckResult.Substring(0, 1) == "1")
  3321. {
  3322. MessageWindow.Show("打印服务授权过期,请联系厂家更换授权!");
  3323. LogHelper.WriteErrLog("打印服务授权过期:" + keyCheckResult, null);
  3324. _gbInitDone = false;
  3325. }
  3326. else if (keyCheckResult.Substring(0, 1) == "0")
  3327. {
  3328. }
  3329. }
  3330. catch (Exception ex)
  3331. {
  3332. LogHelper.WriteErrLog("打印服务授权失败:" + ex.Message, ex);
  3333. MessageWindow.Show("打印服务授权失败,请联系厂家!");
  3334. _gbInitDone = false;
  3335. }
  3336. }
  3337. #endregion TQL打印
  3338. #region 打印界面
  3339. private double _hei;
  3340. private int _msgnum;
  3341. private int _num;
  3342. /// <summary>
  3343. /// 打印状态消息
  3344. /// </summary>
  3345. private string _printMsg = "打印中";
  3346. /// <summary>
  3347. /// 打印进度
  3348. /// </summary>
  3349. private System.Timers.Timer _timesPrint;
  3350. /// <summary>
  3351. /// 打印消息
  3352. /// </summary>
  3353. private System.Timers.Timer _timesPrintMsg;
  3354. private double _wit;
  3355. /// <summary>
  3356. /// 初始化页面
  3357. /// </summary>
  3358. /// <param name="imgPath">
  3359. /// </param>
  3360. /// <param name="wit">
  3361. /// </param>
  3362. /// <param name="hei">
  3363. /// </param>
  3364. public void InitializePrint
  3365. (
  3366. string imgPath,
  3367. double wit,
  3368. double hei
  3369. )
  3370. {
  3371. this._wit = wit;
  3372. this._hei = hei;
  3373. if (!string.IsNullOrWhiteSpace(imgPath))
  3374. {
  3375. ImgPri.Source = new BitmapImage(new Uri(imgPath));
  3376. }
  3377. else
  3378. {
  3379. ImgPri.Source = null;
  3380. }
  3381. GridPrintMask.Visibility = Visibility.Collapsed;
  3382. }
  3383. /// <summary>
  3384. /// 打印初始化
  3385. /// </summary>
  3386. public void InitPrint()
  3387. {
  3388. ResizeMode = ResizeMode.NoResize;
  3389. TqlPrintInit();
  3390. }
  3391. /// <summary>
  3392. /// 生成图片
  3393. /// </summary>
  3394. /// <param name="path">
  3395. /// 图片地址
  3396. /// </param>
  3397. /// <param name="saveimg">
  3398. /// 保存位置
  3399. /// </param>
  3400. /// <param name="rectangle">
  3401. /// 图片位置
  3402. /// </param>
  3403. /// <returns>
  3404. /// </returns>
  3405. private bool MergerPrintImg
  3406. (
  3407. string path,
  3408. string saveimg,
  3409. RectangleF rectangle
  3410. )
  3411. {
  3412. try
  3413. {
  3414. Bitmap bitmap = null;
  3415. //创建要显示的图片对象,根据参数的个数设置宽度
  3416. Bitmap backgroudImg = new Bitmap((int) /*GridM.ActualWidth*/_wit, (int) /*GridM.ActualHeight*/_hei);
  3417. Graphics g = Graphics.FromImage(backgroudImg);
  3418. //清除画布,背景设置为白色
  3419. g.Clear(System.Drawing.Color.White);
  3420. if (!string.IsNullOrWhiteSpace(path))
  3421. {
  3422. bitmap = ImageHelper.ReadBitmapFile(path);
  3423. g.DrawImage(bitmap, rectangle);
  3424. }
  3425. #region 添加箭头
  3426. string str = "↑";
  3427. SolidBrush mybrush = new SolidBrush(System.Drawing.Color.Black); //设置默认画刷颜色
  3428. Font myfont = new Font("黑体", 14); //设置默认字体格式
  3429. g.DrawString
  3430. (
  3431. str,
  3432. myfont,
  3433. mybrush,
  3434. new Rectangle
  3435. (
  3436. (int)_wit - 50,
  3437. 20,
  3438. 50,
  3439. 50
  3440. )
  3441. );
  3442. #endregion 添加箭头
  3443. backgroudImg.Save(saveimg);
  3444. g.Dispose();
  3445. backgroudImg.Dispose();
  3446. if (bitmap != null)
  3447. {
  3448. bitmap.Dispose();
  3449. }
  3450. GC.Collect();
  3451. return true;
  3452. }
  3453. catch (Exception ex)
  3454. {
  3455. LogHelper.WriteErrLog("【截图合成】(MergerImg)图片合成失败:" + ex.Message, ex);
  3456. return false;
  3457. }
  3458. }
  3459. /// <summary>
  3460. /// 开始打印
  3461. /// </summary>
  3462. private void StartPrint(PrintModel printModel)
  3463. {
  3464. try
  3465. {
  3466. _document = new iTextSharp.text.Document
  3467. (
  3468. iTextSharp.text.PageSize.A4,
  3469. 0f,
  3470. 0f,
  3471. 0f,
  3472. 0f
  3473. );
  3474. _printMsg = "生成文件";
  3475. _msgnum = 0;
  3476. string sourcePath1 = printModel.filepath;
  3477. try
  3478. {
  3479. sourcePath1 = sourcePath1.Replace("/", "\\");
  3480. FileStream fs = new FileStream
  3481. (
  3482. sourcePath1,
  3483. FileMode.Create,
  3484. FileAccess.ReadWrite
  3485. );
  3486. _document.AddAuthor("星火微课"); //作者
  3487. _document.AddCreationDate(); //创建时候
  3488. _document.AddCreator("星火微课"); //创建者
  3489. _document.AddSubject("点阵文件"); //主题
  3490. _document.AddTitle("PrintTmatrixCode"); //标题
  3491. _document.AddKeywords("Print");
  3492. _document.AddHeader("TmatrixCode", "0");
  3493. iTextSharp.text.pdf.PdfWriter.GetInstance(_document, fs);
  3494. }
  3495. catch (Exception)
  3496. {
  3497. // ignored
  3498. }
  3499. _document.Open();
  3500. iTextSharp.text.Image image;
  3501. for (int i = 0; i < App.PageDrawList.Count; i++)
  3502. {
  3503. long ii = Timestamp();
  3504. string directoryPath = AppDomain.CurrentDomain.BaseDirectory + "Temp\\";
  3505. string filePathOutPut = Path.Combine
  3506. (
  3507. directoryPath,
  3508. string.Format
  3509. (
  3510. "print{0}{1}.jpg",
  3511. ii,
  3512. i
  3513. )
  3514. );
  3515. RectangleF rectangleFs = new RectangleF();
  3516. MergerPrintImg
  3517. (
  3518. "",
  3519. filePathOutPut,
  3520. rectangleFs
  3521. );
  3522. image = iTextSharp.text.Image.GetInstance(filePathOutPut);
  3523. if (string.IsNullOrEmpty(App.PageDrawList[i].PageImagePath)) //没有图片
  3524. {
  3525. }
  3526. else if (App.PageDrawList[i].ImgDocumentation && !App.PageDrawList[i].Type.Equals("ppt"))
  3527. {
  3528. image = iTextSharp.text.Image.GetInstance(App.PageDrawList[i].PageImagePath);
  3529. }
  3530. else
  3531. {
  3532. RectangleF rectangleF = new RectangleF
  3533. (
  3534. 0,
  3535. 0,
  3536. 0,
  3537. 0
  3538. );
  3539. var i1 = i;
  3540. Dispatcher.Invoke
  3541. (
  3542. () =>
  3543. {
  3544. rectangleF = new RectangleF
  3545. {
  3546. Width = (float)App.PageDrawList[i1].ImageSizes.CenterX,
  3547. Height = (float)App.PageDrawList[i1].ImageSizes.CenterY,
  3548. X = (float)App.PageDrawList[i1].ImageLocation.X,
  3549. Y = (float)App.PageDrawList[i1].ImageLocation.Y
  3550. };
  3551. }
  3552. );
  3553. bool isImg = MergerPrintImg
  3554. (
  3555. App.PageDrawList[i].PageImagePath,
  3556. filePathOutPut,
  3557. rectangleF
  3558. );
  3559. if (isImg)
  3560. {
  3561. image = iTextSharp.text.Image.GetInstance(filePathOutPut);
  3562. }
  3563. else
  3564. {
  3565. image = iTextSharp.text.Image.GetInstance(App.PageDrawList[i].PageImagePath);
  3566. }
  3567. }
  3568. if (image.Height > iTextSharp.text.PageSize.A4.Height)
  3569. {
  3570. image.ScaleToFit(iTextSharp.text.PageSize.A4.Width, iTextSharp.text.PageSize.A4.Height);
  3571. }
  3572. else if (image.Width > iTextSharp.text.PageSize.A4.Width)
  3573. {
  3574. image.ScaleToFit(iTextSharp.text.PageSize.A4.Width, iTextSharp.text.PageSize.A4.Height);
  3575. }
  3576. image.Alignment = iTextSharp.text.Element.ALIGN_MIDDLE;
  3577. _document.NewPage();
  3578. _document.Add(image);
  3579. }
  3580. _document.Close();
  3581. }
  3582. catch (Exception ex)
  3583. {
  3584. Dispatcher.Invoke
  3585. (
  3586. () =>
  3587. {
  3588. BtnPrint.IsEnabled = true;
  3589. _timesPrint.Stop();
  3590. _timesPrintMsg.Stop();
  3591. GridPrintMask.Visibility = Visibility.Collapsed;
  3592. MessageWindow.Show(ex.Message);
  3593. }
  3594. );
  3595. LogHelper.WriteErrLog("打印转换PDF失败,原因:" + ex.Message, ex);
  3596. }
  3597. //PDF位置
  3598. string sourcePath = printModel.filepath;
  3599. if (_isHasCode)
  3600. {
  3601. _printMsg = "铺码中";
  3602. _msgnum = 0;
  3603. Thread.Sleep(500);
  3604. //腾千里生成点阵文件
  3605. if (GenerateCode(sourcePath))
  3606. {
  3607. //打印机名称
  3608. string directoryPath = FileToolsCommon.GetDirectoryName(sourcePath) + "Bg with Images/";
  3609. string[] strs = FileToolsCommon.GetFileNames(directoryPath);
  3610. try
  3611. {
  3612. // 腾千里会根据原PDF的页数生成多个PDF文件
  3613. for (int i = 0; i < strs.Count(); i++)
  3614. {
  3615. _timesPrint.Stop();
  3616. _printMsg = "正在打印第" + (i + 1) + "/" + strs.Count() + "页中";
  3617. _msgnum = 0;
  3618. _num = 0;
  3619. _timesPrint.Interval = 100;
  3620. _timesPrint.Start();
  3621. string fileName = strs[i];
  3622. //打印文件
  3623. ZPrintUtils.Print2(fileName);
  3624. }
  3625. Dispatcher.Invoke
  3626. (
  3627. () =>
  3628. {
  3629. BtnPrint.IsEnabled = true;
  3630. _num = 99;
  3631. _timesPrint.Stop();
  3632. PgbProcess.Value = 100;
  3633. LbProcess.Content = "100%";
  3634. GridPrintMask.Visibility = Visibility.Collapsed;
  3635. //MessageWindow.Show("已加入打印机队列,打印中。");
  3636. }
  3637. );
  3638. }
  3639. catch (Exception ex)
  3640. {
  3641. Dispatcher.Invoke
  3642. (
  3643. () =>
  3644. {
  3645. MessageWindow.Show("打印失败:" + ex.Message);
  3646. BtnPrint.IsEnabled = true;
  3647. _timesPrint.Stop();
  3648. GridPrintMask.Visibility = Visibility.Collapsed;
  3649. }
  3650. );
  3651. }
  3652. }
  3653. else
  3654. {
  3655. Dispatcher.Invoke
  3656. (
  3657. () =>
  3658. {
  3659. BtnPrint.IsEnabled = true;
  3660. _timesPrint.Stop();
  3661. _timesPrintMsg.Stop();
  3662. GridPrintMask.Visibility = Visibility.Collapsed;
  3663. }
  3664. );
  3665. }
  3666. }
  3667. else
  3668. {
  3669. //打印文件
  3670. ZPrintUtils.Print2(sourcePath);
  3671. Dispatcher.Invoke
  3672. (
  3673. () =>
  3674. {
  3675. BtnPrint.IsEnabled = true;
  3676. _num = 99;
  3677. _timesPrint.Stop();
  3678. PgbProcess.Value = 100;
  3679. LbProcess.Content = "100%";
  3680. GridPrintMask.Visibility = Visibility.Collapsed;
  3681. //MessageWindow.Show("已加入打印机队列,打印中。");
  3682. }
  3683. );
  3684. }
  3685. }
  3686. /// <summary>
  3687. /// 计时器
  3688. /// </summary>
  3689. /// <param name="sender">
  3690. /// </param>
  3691. /// <param name="e">
  3692. /// </param>
  3693. private void Times_ElapsedClick(object sender, System.Timers.ElapsedEventArgs e)
  3694. {
  3695. Dispatcher.Invoke
  3696. (
  3697. () =>
  3698. {
  3699. PgbProcess.Value = _num;
  3700. LbProcess.Content = _num + "%";
  3701. if (_num < 99)
  3702. {
  3703. _num++;
  3704. _timesPrint.Interval += 1.0 * _num / 2;
  3705. }
  3706. else
  3707. {
  3708. _timesPrint.Stop();
  3709. }
  3710. }
  3711. );
  3712. }
  3713. /// <summary>
  3714. /// 消息
  3715. /// </summary>
  3716. /// <param name="sender">
  3717. /// </param>
  3718. /// <param name="e">
  3719. /// </param>
  3720. private void TimesPrintMsg_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
  3721. {
  3722. if (_msgnum > 5)
  3723. _msgnum = 0;
  3724. else
  3725. _msgnum++;
  3726. string point = "";
  3727. point = point.PadRight(_msgnum, '.');
  3728. Dispatcher.Invoke
  3729. (
  3730. () =>
  3731. {
  3732. LabPrintMessage.Content = _printMsg + point;
  3733. }
  3734. );
  3735. }
  3736. #endregion 打印界面
  3737. #region 笔事件回调
  3738. public void penPointEvent
  3739. (
  3740. byte bIndex,
  3741. byte bPenStatus,
  3742. short bx,
  3743. short by,
  3744. short bPress,
  3745. int mNDeviceW,
  3746. int mNDeviceH
  3747. )
  3748. {
  3749. //17是按下,16是抬起
  3750. if (bPenStatus == 16 || bPenStatus == 0)
  3751. {
  3752. //stroke.Clear();
  3753. if (App.PageContextData.currpage > 0)
  3754. {
  3755. Dispatcher.Invoke
  3756. (
  3757. () =>
  3758. {
  3759. myblackboard.changepages
  3760. (
  3761. 0,
  3762. 0,
  3763. true,
  3764. _color,
  3765. _penSize,
  3766. App.PageContextData.currpage - 1,
  3767. 0
  3768. );
  3769. }
  3770. );
  3771. }
  3772. }
  3773. double propW = BlackboardCanvas.ActualWidth / mNDeviceH;
  3774. double propH = BlackboardCanvas.ActualHeight / mNDeviceW;
  3775. //点
  3776. double tempY = (mNDeviceW - bx) * propH;
  3777. double tempX = by * propW;
  3778. //pageSerial //点阵IP地址 与打印的页面关联
  3779. if (App.PageContextData.currpage > 0)
  3780. {
  3781. Dispatcher.Invoke
  3782. (
  3783. () =>
  3784. {
  3785. float pressure = bPress / 100f;
  3786. if (bPress > 0)
  3787. {
  3788. myblackboard.changepages
  3789. (
  3790. tempX,
  3791. tempY,
  3792. false,
  3793. _color,
  3794. _penSize,
  3795. App.PageContextData.currpage - 1,
  3796. pressure
  3797. );
  3798. }
  3799. #region 设置滚动条位置
  3800. //点在显示页面上方
  3801. if (tempY < ScroMain.VerticalOffset)
  3802. {
  3803. //滚动条当前位置
  3804. double rollCurrentLocation = ScroMain.VerticalOffset;
  3805. //向上滚动至以点为中心需要滚动的距离
  3806. double upRoll = (rollCurrentLocation - tempY) + (ScroMain.ActualHeight / 2);
  3807. //如果小于0则等于0
  3808. double rollLocation = rollCurrentLocation - upRoll;
  3809. if (rollLocation < 0)
  3810. {
  3811. rollLocation = 0;
  3812. }
  3813. ////滚动条实际偏移量
  3814. //double RollOffset = RollCurrentLocation - RollLocation;
  3815. ScroMain.ScrollToVerticalOffset(rollLocation);
  3816. }
  3817. //点在显示页面下方
  3818. if (tempY > ScroMain.VerticalOffset + ScroMain.ActualHeight)
  3819. {
  3820. //滚动条当前位置
  3821. double rollCurrentLocation = ScroMain.VerticalOffset;
  3822. //向下滚动至以点为中心需要滚动的距离
  3823. double downRoll = (tempY - rollCurrentLocation) - (ScroMain.ActualHeight / 2);
  3824. //如果小于0则等于0
  3825. double rollLocation = rollCurrentLocation + downRoll;
  3826. //滚动条最大滚动值
  3827. double scrollbarMaxNum = GridM.ActualHeight - ScroMain.ActualHeight;
  3828. if (rollLocation > scrollbarMaxNum)
  3829. {
  3830. rollLocation = scrollbarMaxNum;
  3831. }
  3832. ////滚动条实际偏移量
  3833. //double RollOffset = RollLocation-RollCurrentLocation;
  3834. ScroMain.ScrollToVerticalOffset(rollLocation);
  3835. }
  3836. #endregion 设置滚动条位置
  3837. if (tempX > 0 && tempY > 0)
  3838. {
  3839. //System.Windows.Point getP = blackboard_canvas.PointToScreen(new System.Windows.Point(testX, testY));
  3840. System.Windows.Point getP = ScroMain.PointToScreen(new System.Windows.Point(tempX, tempY - ScroMain.VerticalOffset));
  3841. SetCursorPos((int)getP.X, (int)getP.Y);
  3842. }
  3843. }
  3844. );
  3845. }
  3846. }
  3847. public void penStatusEvent()
  3848. {
  3849. UpdateDevStatus();
  3850. }
  3851. #endregion 笔事件回调
  3852. private void Window_Closed(object sender, EventArgs e)
  3853. {
  3854. Environment.Exit(0);
  3855. }
  3856. }
  3857. }