星火微课系统客户端
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

XHMicroLessonSystemWindow.xaml.cs 295KB

4 anos atrás
4 anos atrás
4 anos atrás
3 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
4 anos atrás
3 anos atrás
4 anos atrás
3 anos atrás
4 anos atrás
3 anos atrás
3 anos atrás
4 anos atrás
4 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
4 anos atrás
3 anos atrás
4 anos atrás
3 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
3 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
3 anos atrás
4 anos atrás
3 anos atrás
4 anos atrás
4 anos atrás
3 anos atrás
3 anos atrás
4 anos atrás
4 anos atrás
3 anos atrás
4 anos atrás
3 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
3 anos atrás
4 anos atrás
3 anos atrás
4 anos atrás
3 anos atrás
4 anos atrás
3 anos atrás
3 anos atrás
4 anos atrás
4 anos atrás
3 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
3 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
3 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
3 anos atrás
4 anos atrás
4 anos atrás
3 anos atrás
4 anos atrás
4 anos atrás
3 anos atrás
4 anos atrás
3 anos atrás
4 anos atrás
4 anos atrás
3 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
4 anos atrás
4 anos atrás
3 anos atrás
4 anos atrás
3 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
4 anos atrás
3 anos atrás
4 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
4 anos atrás
4 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
4 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
4 anos atrás
3 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
3 anos atrás
3 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
3 anos atrás
4 anos atrás
3 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
3 anos atrás
3 anos atrás
4 anos atrás
4 anos atrás
3 anos atrás
4 anos atrás
4 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
3 anos atrás
4 anos atrás
3 anos atrás
4 anos atrás
4 anos atrás
3 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
3 anos atrás
4 anos atrás
3 anos atrás
4 anos atrás
4 anos atrás
3 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
3 anos atrás
4 anos atrás
3 anos atrás
4 anos atrás
3 anos atrás
4 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
4 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
4 anos atrás
4 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
4 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
4 anos atrás
3 anos atrás
4 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
4 anos atrás
3 anos atrás
4 anos atrás
4 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
4 anos atrás
3 anos atrás
4 anos atrás
3 anos atrás
3 anos atrás
4 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
4 anos atrás
4 anos atrás
3 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
3 anos atrás
4 anos atrás
4 anos atrás
3 anos atrás
4 anos atrás
3 anos atrás
4 anos atrás
3 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
3 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
3 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
3 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
3 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
3 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
4 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
4 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
4 anos atrás
4 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
4 anos atrás
4 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
4 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
4 anos atrás
3 anos atrás
4 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
4 anos atrás
3 anos atrás
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224
  1. using Aspose.Slides;
  2. using Aspose.Words.Saving;
  3. using ComeCapture;
  4. using Common.system;
  5. using RobotpenGateway;
  6. using Spire.Pdf;
  7. using System;
  8. using System.Collections.Generic;
  9. using System.Data;
  10. using System.Diagnostics;
  11. using System.Drawing;
  12. using System.Drawing.Imaging;
  13. using System.Drawing.Printing;
  14. using System.IO;
  15. using System.Linq;
  16. using System.Text;
  17. using System.Text.RegularExpressions;
  18. using System.Threading;
  19. using System.Windows;
  20. using System.Windows.Controls;
  21. using System.Windows.Controls.Primitives;
  22. //using System.Windows.Forms;
  23. using System.Windows.Ink;
  24. using System.Windows.Input;
  25. using System.Windows.Media;
  26. using System.Windows.Media.Imaging;
  27. using System.Windows.Threading;
  28. using TmatrixLibrary;
  29. using TStudyDigitalPen.HID;
  30. using XHWK.Model;
  31. using XHWK.WKTool.DAL;
  32. using XHWK.WKTool.Skin;
  33. using XHWK.WKTool.UControl;
  34. namespace XHWK.WKTool
  35. {
  36. /// <summary>
  37. /// 主页面
  38. /// </summary>
  39. public partial class XHMicroLessonSystemWindow : Window
  40. {
  41. #region 字段
  42. /// <summary>
  43. /// 页码下拉列表
  44. /// </summary>
  45. private List<PageData> PageData = null;
  46. private System.Windows.Forms.FolderBrowserDialog Ofd;
  47. private System.Windows.Forms.DialogResult Result;
  48. public BlackboardNew myblackboard;
  49. private System.Windows.Forms.DialogResult result;
  50. private System.Windows.Forms.OpenFileDialog ofd;
  51. //声明一个 DrawingAttributes 类型的变量
  52. private DrawingAttributes drawingAttributes;
  53. private Model_Video VideoInfo = null;
  54. ////定义事件
  55. //public event ChangeTextHandler ChangeTextEvent;
  56. //定义委托
  57. public delegate void ChangeTextHandler(string text);
  58. //定义委托
  59. public delegate void ChangeTextHandlers(string text, int i);
  60. /// <summary>
  61. /// 图片
  62. /// </summary>
  63. private string[] ImgPDFPath = new string[300];
  64. /// <summary>
  65. /// 当前颜色
  66. /// </summary>
  67. private System.Windows.Media.Color Color = System.Windows.Media.Colors.Red;
  68. /// <summary>
  69. /// 笔迹粗细
  70. /// </summary>
  71. private int PenSize = 2;
  72. //private DispatcherTimer t = null;
  73. /// <summary>
  74. /// 计时器状态
  75. /// </summary>
  76. private enum State
  77. {
  78. Start,
  79. Pause,
  80. End
  81. }
  82. ///// <summary>
  83. ///// 状态
  84. ///// </summary>
  85. //private State _state = State.End;
  86. ///// <summary>
  87. ///// 计时用
  88. ///// </summary>
  89. //private TimeSpan _timeSpan = new TimeSpan(0, 0, 0, 0, 0);
  90. #region 上传
  91. /// <summary>
  92. /// 视频模型
  93. /// </summary>
  94. private List<Model_Video> model_VideoList = null;
  95. /// <summary>
  96. /// 数据列表
  97. /// </summary>
  98. internal FileDirectoryData pageData = new FileDirectoryData();
  99. /// <summary>
  100. /// 下标
  101. /// </summary>
  102. private int Subscript = 0;
  103. /// <summary>
  104. /// 是否是修改状态
  105. /// </summary>
  106. private bool IsModify = false;
  107. #endregion 上传
  108. //private double screeHeight = SystemParameters.FullPrimaryScreenHeight;
  109. //private double screeWidth = SystemParameters.FullPrimaryScreenWidth;
  110. /// <summary>
  111. /// 键盘钩子
  112. /// </summary>
  113. private KeyboardHookCommon k_hook;
  114. #endregion 字段
  115. #region 初始化
  116. /// <summary>
  117. /// 主页面
  118. /// </summary>
  119. public XHMicroLessonSystemWindow()
  120. {
  121. new Aspose.Words.License().SetLicense(new MemoryStream(Convert.FromBase64String("PExpY2Vuc2U+CiAgPERhdGE+CiAgICA8TGljZW5zZWRUbz5TdXpob3UgQXVuYm94IFNvZnR3YXJlIENvLiwgTHRkLjwvTGljZW5zZWRUbz4KICAgIDxFbWFpbFRvPnNhbGVzQGF1bnRlYy5jb208L0VtYWlsVG8+CiAgICA8TGljZW5zZVR5cGU+RGV2ZWxvcGVyIE9FTTwvTGljZW5zZVR5cGU+CiAgICA8TGljZW5zZU5vdGU+TGltaXRlZCB0byAxIGRldmVsb3BlciwgdW5saW1pdGVkIHBoeXNpY2FsIGxvY2F0aW9uczwvTGljZW5zZU5vdGU+CiAgICA8T3JkZXJJRD4xOTA4MjYwODA3NTM8L09yZGVySUQ+CiAgICA8VXNlcklEPjEzNDk3NjAwNjwvVXNlcklEPgogICAgPE9FTT5UaGlzIGlzIGEgcmVkaXN0cmlidXRhYmxlIGxpY2Vuc2U8L09FTT4KICAgIDxQcm9kdWN0cz4KICAgICAgPFByb2R1Y3Q+QXNwb3NlLlRvdGFsIGZvciAuTkVUPC9Qcm9kdWN0PgogICAgPC9Qcm9kdWN0cz4KICAgIDxFZGl0aW9uVHlwZT5FbnRlcnByaXNlPC9FZGl0aW9uVHlwZT4KICAgIDxTZXJpYWxOdW1iZXI+M2U0NGRlMzAtZmNkMi00MTA2LWIzNWQtNDZjNmEzNzE1ZmMyPC9TZXJpYWxOdW1iZXI+CiAgICA8U3Vic2NyaXB0aW9uRXhwaXJ5PjIwMjAwODI3PC9TdWJzY3JpcHRpb25FeHBpcnk+CiAgICA8TGljZW5zZVZlcnNpb24+My4wPC9MaWNlbnNlVmVyc2lvbj4KICAgIDxMaWNlbnNlSW5zdHJ1Y3Rpb25zPmh0dHBzOi8vcHVyY2hhc2UuYXNwb3NlLmNvbS9wb2xpY2llcy91c2UtbGljZW5zZTwvTGljZW5zZUluc3RydWN0aW9ucz4KICA8L0RhdGE+CiAgPFNpZ25hdHVyZT53UGJtNUt3ZTYvRFZXWFNIY1o4d2FiVEFQQXlSR0pEOGI3L00zVkV4YWZpQnd5U2h3YWtrNGI5N2c2eGtnTjhtbUFGY3J0c0cwd1ZDcnp6MytVYk9iQjRYUndTZWxsTFdXeXNDL0haTDNpN01SMC9jZUFxaVZFOU0rWndOQkR4RnlRbE9uYTFQajhQMzhzR1grQ3ZsemJLZFZPZXk1S3A2dDN5c0dqYWtaL1E9PC9TaWduYXR1cmU+CjwvTGljZW5zZT4=")));
  122. new Aspose.Pdf.License().SetLicense(new MemoryStream(Convert.FromBase64String("PExpY2Vuc2U+CiAgPERhdGE+CiAgICA8TGljZW5zZWRUbz5TdXpob3UgQXVuYm94IFNvZnR3YXJlIENvLiwgTHRkLjwvTGljZW5zZWRUbz4KICAgIDxFbWFpbFRvPnNhbGVzQGF1bnRlYy5jb208L0VtYWlsVG8+CiAgICA8TGljZW5zZVR5cGU+RGV2ZWxvcGVyIE9FTTwvTGljZW5zZVR5cGU+CiAgICA8TGljZW5zZU5vdGU+TGltaXRlZCB0byAxIGRldmVsb3BlciwgdW5saW1pdGVkIHBoeXNpY2FsIGxvY2F0aW9uczwvTGljZW5zZU5vdGU+CiAgICA8T3JkZXJJRD4xOTA4MjYwODA3NTM8L09yZGVySUQ+CiAgICA8VXNlcklEPjEzNDk3NjAwNjwvVXNlcklEPgogICAgPE9FTT5UaGlzIGlzIGEgcmVkaXN0cmlidXRhYmxlIGxpY2Vuc2U8L09FTT4KICAgIDxQcm9kdWN0cz4KICAgICAgPFByb2R1Y3Q+QXNwb3NlLlRvdGFsIGZvciAuTkVUPC9Qcm9kdWN0PgogICAgPC9Qcm9kdWN0cz4KICAgIDxFZGl0aW9uVHlwZT5FbnRlcnByaXNlPC9FZGl0aW9uVHlwZT4KICAgIDxTZXJpYWxOdW1iZXI+M2U0NGRlMzAtZmNkMi00MTA2LWIzNWQtNDZjNmEzNzE1ZmMyPC9TZXJpYWxOdW1iZXI+CiAgICA8U3Vic2NyaXB0aW9uRXhwaXJ5PjIwMjAwODI3PC9TdWJzY3JpcHRpb25FeHBpcnk+CiAgICA8TGljZW5zZVZlcnNpb24+My4wPC9MaWNlbnNlVmVyc2lvbj4KICAgIDxMaWNlbnNlSW5zdHJ1Y3Rpb25zPmh0dHBzOi8vcHVyY2hhc2UuYXNwb3NlLmNvbS9wb2xpY2llcy91c2UtbGljZW5zZTwvTGljZW5zZUluc3RydWN0aW9ucz4KICA8L0RhdGE+CiAgPFNpZ25hdHVyZT53UGJtNUt3ZTYvRFZXWFNIY1o4d2FiVEFQQXlSR0pEOGI3L00zVkV4YWZpQnd5U2h3YWtrNGI5N2c2eGtnTjhtbUFGY3J0c0cwd1ZDcnp6MytVYk9iQjRYUndTZWxsTFdXeXNDL0haTDNpN01SMC9jZUFxaVZFOU0rWndOQkR4RnlRbE9uYTFQajhQMzhzR1grQ3ZsemJLZFZPZXk1S3A2dDN5c0dqYWtaL1E9PC9TaWduYXR1cmU+CjwvTGljZW5zZT4=")));
  123. new Aspose.Slides.License().SetLicense(new MemoryStream(Convert.FromBase64String("PExpY2Vuc2U+CiAgPERhdGE+CiAgICA8TGljZW5zZWRUbz5TdXpob3UgQXVuYm94IFNvZnR3YXJlIENvLiwgTHRkLjwvTGljZW5zZWRUbz4KICAgIDxFbWFpbFRvPnNhbGVzQGF1bnRlYy5jb208L0VtYWlsVG8+CiAgICA8TGljZW5zZVR5cGU+RGV2ZWxvcGVyIE9FTTwvTGljZW5zZVR5cGU+CiAgICA8TGljZW5zZU5vdGU+TGltaXRlZCB0byAxIGRldmVsb3BlciwgdW5saW1pdGVkIHBoeXNpY2FsIGxvY2F0aW9uczwvTGljZW5zZU5vdGU+CiAgICA8T3JkZXJJRD4xOTA4MjYwODA3NTM8L09yZGVySUQ+CiAgICA8VXNlcklEPjEzNDk3NjAwNjwvVXNlcklEPgogICAgPE9FTT5UaGlzIGlzIGEgcmVkaXN0cmlidXRhYmxlIGxpY2Vuc2U8L09FTT4KICAgIDxQcm9kdWN0cz4KICAgICAgPFByb2R1Y3Q+QXNwb3NlLlRvdGFsIGZvciAuTkVUPC9Qcm9kdWN0PgogICAgPC9Qcm9kdWN0cz4KICAgIDxFZGl0aW9uVHlwZT5FbnRlcnByaXNlPC9FZGl0aW9uVHlwZT4KICAgIDxTZXJpYWxOdW1iZXI+M2U0NGRlMzAtZmNkMi00MTA2LWIzNWQtNDZjNmEzNzE1ZmMyPC9TZXJpYWxOdW1iZXI+CiAgICA8U3Vic2NyaXB0aW9uRXhwaXJ5PjIwMjAwODI3PC9TdWJzY3JpcHRpb25FeHBpcnk+CiAgICA8TGljZW5zZVZlcnNpb24+My4wPC9MaWNlbnNlVmVyc2lvbj4KICAgIDxMaWNlbnNlSW5zdHJ1Y3Rpb25zPmh0dHBzOi8vcHVyY2hhc2UuYXNwb3NlLmNvbS9wb2xpY2llcy91c2UtbGljZW5zZTwvTGljZW5zZUluc3RydWN0aW9ucz4KICA8L0RhdGE+CiAgPFNpZ25hdHVyZT53UGJtNUt3ZTYvRFZXWFNIY1o4d2FiVEFQQXlSR0pEOGI3L00zVkV4YWZpQnd5U2h3YWtrNGI5N2c2eGtnTjhtbUFGY3J0c0cwd1ZDcnp6MytVYk9iQjRYUndTZWxsTFdXeXNDL0haTDNpN01SMC9jZUFxaVZFOU0rWndOQkR4RnlRbE9uYTFQajhQMzhzR1grQ3ZsemJLZFZPZXk1S3A2dDN5c0dqYWtaL1E9PC9TaWduYXR1cmU+CjwvTGljZW5zZT4=")));
  124. InitializeComponent();
  125. float WorkW = PrimaryScreen.ScaleWorkingAreaSize.Width;
  126. float WorkH = PrimaryScreen.ScaleWorkingAreaSize.Height;
  127. double proportion = 1036.0 / 1290.0;
  128. //限制大小 确保大屏幕下录制不会卡死 暂时
  129. if (WorkW > 1920.0)
  130. {
  131. Width = 1290;
  132. Height = 1036;
  133. }
  134. else
  135. {
  136. Width = (PrimaryScreen.ScaleWorkingAreaSize.Height) / proportion - (BorderThickness.Left + BorderThickness.Right);
  137. Height = PrimaryScreen.ScaleWorkingAreaSize.Height - (BorderThickness.Top + BorderThickness.Bottom);
  138. }
  139. GridContent.Width = Width - 14;
  140. GridContent.Height = Height;
  141. #region 调整文字大小
  142. APP.PageContextData.WordSize20 = 20.00;
  143. APP.PageContextData.WordSize18 = 18.00;
  144. APP.PageContextData.WordSize16 = 16.00;
  145. double WordFontPro = GridContent.Height / 1030.00;
  146. //txbNotConnected.FontSize = 16.00 * WordFontPro;//连接状态文字
  147. //TxbTime.FontSize = 20.00 * WordFontPro;//录屏时间
  148. //TxbType.FontSize = 20.00 * WordFontPro;//录屏消息
  149. APP.PageContextData.WordSize20 = 20.00 * WordFontPro;
  150. APP.PageContextData.WordSize18 = 18.00 * WordFontPro;
  151. APP.PageContextData.WordSize16 = 16.00 * WordFontPro;
  152. APP.PageContextData.WordSize14 = 14.00 * WordFontPro;
  153. APP.PageContextData.WordSize12 = 12.00 * WordFontPro;
  154. #endregion 调整文字大小
  155. #region 读取本地配置 废弃 2021年7月9日赵耀
  156. //if (File.Exists(APP.DataPath + "interfaceAddress.txt")) //若不为空
  157. //{
  158. // APP.apiUrl = System.IO.File.ReadAllText(APP.DataPath + "interfaceAddress.txt", Encoding.Default);
  159. //}
  160. //if (File.Exists(APP.DataPath + "imageUploadAddress.txt")) //若不为空
  161. //{
  162. // APP.uploadUrl = System.IO.File.ReadAllText(APP.DataPath + "imageUploadAddress.txt", Encoding.Default);
  163. //}
  164. //if (File.Exists(APP.DataPath + "pictureShowsAddress.txt")) //若不为空
  165. //{
  166. // APP.showImageUrl = System.IO.File.ReadAllText(APP.DataPath + "pictureShowsAddress.txt", Encoding.Default);
  167. //}
  168. #endregion 读取本地配置 废弃 2021年7月9日赵耀
  169. //GridMain.Height= PrimaryScreen.ScaleScreenSize().Height - 40;
  170. //this.Top = (screeHeight - this.Height) / 2;
  171. //this.Left = (screeWidth - this.Width) / 2;
  172. ResizeMode = System.Windows.ResizeMode.CanMinimize;
  173. BtnPrint.IsEnabled = false;
  174. myblackboard = new BlackboardNew(blackboard_canvas);
  175. APP.PageContextData.pagenum = 0;
  176. APP.PageContextData.currpage = 0;
  177. DataContext = APP.PageContextData;
  178. //APP.SaveDraw();//画板模型第一页初始化
  179. APP.PageDrawList = new List<Model_DrawData>();
  180. Model_DrawData model_DrawData = new Model_DrawData
  181. {
  182. PageNum = APP.PageContextData.currpage
  183. };
  184. APP.PageDrawList.Add(model_DrawData);
  185. txbv.Text = "v" + FileToolsCommon.GetConfigValue("VersionName");
  186. txbStoragePath.Content = FileToolsCommon.GetConfigValue("VideoType");
  187. //if (FileToolsCommon.GetConfigValue("IsSound").Equals("true"))
  188. //{
  189. // rbnY.IsChecked = true;
  190. //}
  191. //else
  192. //{
  193. // rbnN.IsChecked = true;
  194. //}
  195. txbStoragePath.Content = FileToolsCommon.GetConfigValue("VideoSavePath");
  196. Initialize();
  197. InitPen();
  198. InitlbPen();
  199. InitTQLPPen();
  200. InitPrint();
  201. }
  202. /// <summary>
  203. /// 初始化
  204. /// </summary>
  205. public void Initialize()
  206. {
  207. if (APP.isDebug)
  208. {
  209. txbVersion.Text = "测试版:";
  210. }
  211. else
  212. {
  213. txbVersion.Text = "正式版:";
  214. }
  215. #region 数据初始化
  216. string pathTemp = AppDomain.CurrentDomain.BaseDirectory + "Temp\\";
  217. FileToolsCommon.CreateDirectory(pathTemp);
  218. APP.PageContextData.pagenum = 0;
  219. APP.PageContextData.currpage = APP.PageContextData.pagenum;
  220. BtnStop.IsEnabled = false;//停止录制按钮不可点击
  221. #endregion 数据初始化
  222. k_hook = new KeyboardHookCommon();
  223. k_hook.KeyDownEvent += K_hook_KeyDownEvent;
  224. k_hook.Start();//安装键盘钩子
  225. APP.CameraPosition = FileToolsCommon.GetConfigValue("CameraPosition");
  226. //创建 DrawingAttributes 类的一个实例
  227. drawingAttributes = new DrawingAttributes();
  228. //将 InkCanvas 的 DefaultDrawingAttributes 属性的值赋成创建的 DrawingAttributes 类的对象的引用
  229. //InkCanvas 通过 DefaultDrawingAttributes 属性来获取墨迹的各种设置,该属性的类型为 DrawingAttributes 型
  230. blackboard_canvas.DefaultDrawingAttributes = drawingAttributes;
  231. blackboard_canvas.UseCustomCursor = true;
  232. drawingAttributes.FitToCurve = true;
  233. drawingAttributes.IgnorePressure = false;
  234. drawingAttributes.Width = PenSize;
  235. drawingAttributes.Height = PenSize;
  236. drawingAttributes.Color = Color;
  237. blackboard_canvas.Cursor = System.Windows.Input.Cursors.Pen;
  238. //wfhCamera.Visibility = Visibility.Hidden;
  239. ImgPDFPath = null;
  240. ImgPDFPath = new string[300];
  241. //GridM.Height = GridM.ActualWidth / proportion;
  242. //GridM.Height = GridM.Width / proportion;
  243. }
  244. /// <summary>
  245. /// 初始化快捷键
  246. /// </summary>
  247. public void InitializeKeyDownEvent()
  248. {
  249. k_hook.Start();//安装键盘钩子
  250. }
  251. /// <summary>
  252. /// 快捷键
  253. /// </summary>
  254. /// <param name="sender"></param>
  255. /// <param name="e"></param>
  256. private void K_hook_KeyDownEvent(object sender, System.Windows.Forms.KeyEventArgs e)
  257. {
  258. if (e.KeyValue == (int)System.Windows.Forms.Keys.Left)
  259. {
  260. if (APP.PageContextData.currpage > 1)
  261. {
  262. //上一页
  263. last_button_Click(null, null);
  264. }
  265. }
  266. if (e.KeyValue == (int)System.Windows.Forms.Keys.Right)
  267. {
  268. if (APP.PageContextData.currpage < APP.PageContextData.pagenum)
  269. {
  270. //下一页
  271. next_btn_Click(null, null);
  272. }
  273. }
  274. if (e.KeyValue == (int)System.Windows.Forms.Keys.Delete)
  275. {
  276. if (RectImgBorder.Visibility != Visibility.Hidden)
  277. {
  278. HideAngleBorder();
  279. imgCanvas.Source = null;
  280. APP.PageDrawList[APP.PageContextData.currpage - 1].PdfImagePath = null;
  281. APP.PageDrawList[APP.PageContextData.currpage - 1].PageImagePath = null;
  282. }
  283. }
  284. }
  285. /// <summary>
  286. /// 加载完成后调整录制区域大小
  287. /// </summary>
  288. /// <param name="sender"></param>
  289. /// <param name="e"></param>
  290. private void Window_Loaded(object sender, RoutedEventArgs e)
  291. {
  292. //调整录制区域宽高
  293. double proportion = 210.0 / 297.0;
  294. GridM.Height = GridM.ActualWidth / proportion;
  295. }
  296. #endregion 初始化
  297. #region 事件
  298. /// <summary>
  299. /// 窗体移动
  300. /// </summary>
  301. /// <param name="sender"></param>
  302. /// <param name="e"></param>
  303. private void Window_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
  304. {
  305. DragMove();
  306. }
  307. private void PageHide()
  308. {
  309. //设置
  310. gridSetUp.Visibility = Visibility.Collapsed;
  311. //上传-无用
  312. gridUpload.Visibility = Visibility.Collapsed;
  313. ////页码
  314. //GridPage.Visibility = Visibility.Collapsed;
  315. //我的
  316. GridMyVideo.Visibility = Visibility.Collapsed;
  317. //首页
  318. GridMain.Visibility = Visibility.Collapsed;
  319. GridM.IsEnabled = true;
  320. //打印
  321. GridPrintContent.Visibility = Visibility.Collapsed;
  322. //标题 录制
  323. GridRecordingTitle.Visibility = Visibility.Collapsed;
  324. //标题 打印
  325. GridPrintingTitle.Visibility = Visibility.Collapsed;
  326. }
  327. #region 摄像头
  328. private System.Timers.Timer times;
  329. private List<string> RbnOpen;
  330. private bool IsRbnOpen = false;
  331. /// <summary>
  332. /// 摄像头打开事件
  333. /// </summary>
  334. /// <param name="sender"></param>
  335. /// <param name="e"></param>
  336. private void RbnOpen_Click(object sender, RoutedEventArgs e)
  337. {
  338. if (!IsRbnOpen)
  339. {
  340. #region 防止连击
  341. if (IsPressButton)
  342. {
  343. return;
  344. }
  345. else
  346. {
  347. IsPressButton = true;
  348. new Thread(new ThreadStart(new Action(() =>
  349. {
  350. //Dispatcher.Invoke(new Action(() => { rbnTurnOff.IsEnabled = false; }));
  351. Thread.Sleep(500);
  352. //Dispatcher.Invoke(new Action(() => { rbnTurnOff.IsEnabled = true; }));
  353. IsPressButton = false;
  354. }))).Start();
  355. }
  356. #endregion 防止连击
  357. CameraHelper.UpdateCameraDevices();
  358. if (CameraHelper.CameraDevices.Count > 0)
  359. {
  360. int CameraIndex = 0;
  361. for (int i = 0; i < CameraHelper.CameraDevices.Count; i++)
  362. {
  363. if (CameraHelper.CameraDevices[i].MonikerString == APP.CameraName)
  364. {
  365. CameraIndex = i;
  366. }
  367. }
  368. CameraHelper.SetCameraDevice(CameraIndex);
  369. RbnOpen = new List<string>();
  370. times = new System.Timers.Timer(200)//初始值为300
  371. {
  372. AutoReset = true//设置是否执行System.Timers.Timer.Elapsed事件
  373. };//设置执行一次(false)还是一直执行(true)
  374. times.Elapsed += new System.Timers.ElapsedEventHandler(Times_Elapsed);
  375. times.Enabled = true; //启动计时器
  376. IsRbnOpen = true;
  377. string imgPath = FileToolsCommon.GetFileAbsolutePath("Temp/imgplayer");
  378. FileToolsCommon.CreateDirectory(imgPath);
  379. }
  380. }
  381. }
  382. private int I = 9999;
  383. private void Times_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
  384. {
  385. if (IsRbnOpen)
  386. {
  387. try
  388. {
  389. Dispatcher.Invoke(() =>
  390. {
  391. if (I > 10010)
  392. {
  393. long time = Timestamp();
  394. string imgPath = FileToolsCommon.GetFileAbsolutePath("Temp/imgplayer");
  395. //string FilePathName = ImgPath + RsImgName.Count + ".png";
  396. string path = CameraHelper.CaptureImage(imgPath, time.ToString());
  397. if (!string.IsNullOrWhiteSpace(path))
  398. {
  399. RbnOpen.Add(path);
  400. imgPlayerRight.Visibility = Visibility.Visible;
  401. /// < !--摄像头位置 1.右上 2.左上 3.右下 4.左下-- >
  402. if ("1".Equals(APP.CameraPosition))
  403. {
  404. imgPlayerRight.Visibility = Visibility.Visible;
  405. imgPlayerLeft.Visibility = Visibility.Collapsed;
  406. imgPlayerRightUnder.Visibility = Visibility.Collapsed;
  407. imgPlayerLeftUnder.Visibility = Visibility.Collapsed;
  408. imgPlayerRight.Source = new BitmapImage(new Uri(path));
  409. }
  410. else if ("2".Equals(APP.CameraPosition))
  411. {
  412. imgPlayerRight.Visibility = Visibility.Collapsed;
  413. imgPlayerLeft.Visibility = Visibility.Visible;
  414. imgPlayerRightUnder.Visibility = Visibility.Collapsed;
  415. imgPlayerLeftUnder.Visibility = Visibility.Collapsed;
  416. imgPlayerLeft.Source = new BitmapImage(new Uri(path));
  417. }
  418. else if ("3".Equals(APP.CameraPosition))
  419. {
  420. imgPlayerRight.Visibility = Visibility.Collapsed;
  421. imgPlayerLeft.Visibility = Visibility.Collapsed;
  422. imgPlayerRightUnder.Visibility = Visibility.Visible;
  423. imgPlayerLeftUnder.Visibility = Visibility.Collapsed;
  424. imgPlayerRightUnder.Source = new BitmapImage(new Uri(path));
  425. }
  426. else if ("4".Equals(APP.CameraPosition))
  427. {
  428. imgPlayerRight.Visibility = Visibility.Collapsed;
  429. imgPlayerLeft.Visibility = Visibility.Collapsed;
  430. imgPlayerRightUnder.Visibility = Visibility.Collapsed;
  431. imgPlayerLeftUnder.Visibility = Visibility.Visible;
  432. imgPlayerLeftUnder.Source = new BitmapImage(new Uri(path));
  433. }
  434. else
  435. {
  436. imgPlayerLeft.Visibility = Visibility.Collapsed;
  437. imgPlayerRightUnder.Visibility = Visibility.Collapsed;
  438. imgPlayerLeftUnder.Visibility = Visibility.Collapsed;
  439. imgPlayerRight.Source = new BitmapImage(new Uri(path));
  440. }
  441. }
  442. }
  443. I++;
  444. });
  445. }
  446. catch (Exception ex)
  447. {
  448. LogHelper.WriteErrLog("【摄像】(Times_Elapsed)生成图片错误:" + ex.Message, ex);
  449. }
  450. }
  451. }
  452. /// <summary>
  453. /// 摄像头关闭事件
  454. /// </summary>
  455. /// <param name="sender"></param>
  456. /// <param name="e"></param>
  457. private void RbnTurnOff_Click(object sender, RoutedEventArgs e)
  458. {
  459. if (IsRbnOpen)
  460. {
  461. #region 防止连击
  462. if (IsPressButton)
  463. {
  464. return;
  465. }
  466. else
  467. {
  468. IsPressButton = true;
  469. new Thread(new ThreadStart(new Action(() =>
  470. {
  471. //Dispatcher.Invoke(new Action(() => { rbnOpen.IsEnabled = false; }));
  472. Thread.Sleep(500);
  473. //Dispatcher.Invoke(new Action(() => { rbnOpen.IsEnabled = true; }));
  474. IsPressButton = false;
  475. }))).Start();
  476. }
  477. #endregion 防止连击
  478. IsRbnOpen = false;
  479. imgPlayerRight.Visibility = Visibility.Collapsed;
  480. imgPlayerLeft.Visibility = Visibility.Collapsed;
  481. imgPlayerRightUnder.Visibility = Visibility.Collapsed;
  482. imgPlayerLeftUnder.Visibility = Visibility.Collapsed;
  483. CameraHelper.CloseDevice();
  484. I = 9999;
  485. }
  486. }
  487. #endregion 摄像头
  488. /// <summary>
  489. /// 关闭事件
  490. /// </summary>
  491. /// <param name="sender"></param>
  492. /// <param name="e"></param>
  493. private void BtnClose_Click(object sender, RoutedEventArgs e)
  494. {
  495. if (IsFirstR)
  496. {
  497. try
  498. {
  499. MessageBoxResult br = MessageWindow.Show("确定退出系统?", "退出", MessageBoxButton.OKCancel);
  500. if (br == MessageBoxResult.OK)
  501. {
  502. try
  503. {
  504. APP.Killffmpeg();
  505. }
  506. catch (Exception ex)
  507. {
  508. LogHelper.WriteErrLog("获取进程失败," + ex.Message, ex);
  509. }
  510. APP.SaveWkData();
  511. APP.SaveDraw();
  512. //Thread.Sleep(100);
  513. //Close();
  514. //System.Windows.
  515. //Application.Current.Shutdown();
  516. TMC.TmatrixUninitialize();
  517. Environment.Exit(0);
  518. }
  519. }
  520. catch (Exception ex)
  521. {
  522. LogHelper.WriteErrLog("关闭微课失败," + ex.Message, ex);
  523. Close();
  524. Application.Current.Shutdown();
  525. TMC.TmatrixUninitialize();
  526. Environment.Exit(0);
  527. }
  528. }
  529. else
  530. {
  531. MessageWindow.Show("当前正在录制,请先停止录制。");
  532. return;
  533. //MessageBoxResult dr = MessageWindow.Show("当前正在录制,是否停止录制?", "提示", MessageBoxButton.OKCancel);
  534. //if (dr == MessageBoxResult.OK)
  535. //{
  536. // APP.SaveWkData();
  537. // APP.SaveDraw();
  538. // BtnStop_Click(null, null);
  539. // while (!IsFirstR)
  540. // {
  541. // Thread.Sleep(100);
  542. // }
  543. // System.Environment.Exit(0);
  544. //}
  545. //else
  546. //{
  547. // return;
  548. //}
  549. }
  550. }
  551. /// <summary>
  552. /// 增加事件
  553. /// </summary>
  554. /// <param name="sender"></param>
  555. /// <param name="e"></param>
  556. private void BtnAdd_Click(object sender, RoutedEventArgs e)
  557. {
  558. Record();
  559. if (APP.PageContextData.currpage > 0)
  560. {
  561. APP.PageDrawList[APP.PageContextData.currpage - 1].IsImageLocation = true;
  562. }
  563. if (IsStartCount && blackboard_canvas.Visibility == Visibility.Collapsed)
  564. {
  565. blackboard_canvas.Visibility = Visibility.Visible;
  566. }
  567. APP.PageContextData.pagenum += 1;
  568. HideAngleBorder();
  569. GridPage.Visibility = Visibility.Visible;//页码大于0 显示
  570. APP.PageContextData.currpage = APP.PageContextData.pagenum;
  571. myblackboard.changepage(APP.PageContextData.currpage - 1);
  572. ScroMain.ScrollToVerticalOffset(0);
  573. ///清空页面图片UI
  574. imgCanvas.Source = null;
  575. imgDocumentation.Source = null;
  576. imgPPT.Source = null;
  577. if (APP.PageContextData.pagenum == 1)
  578. {
  579. APP.PageDrawList = new List<Model_DrawData>();
  580. }
  581. ///画板模型增加一页
  582. Model_DrawData model_DrawData = new Model_DrawData
  583. {
  584. PageNum = APP.PageContextData.currpage
  585. };
  586. APP.PageDrawList.Add(model_DrawData);
  587. if (RecordType == 0)
  588. {
  589. BtnPrint.IsEnabled = true;
  590. }
  591. //APP.SaveDraw();
  592. if (BtnImport.IsEnabled)
  593. {
  594. ///截图可用
  595. BtnScreenshot.IsEnabled = true;
  596. }
  597. #region 插入页码
  598. PageData = new List<PageData>();
  599. for (int i = 1; i <= APP.PageContextData.pagenum; i++)
  600. {
  601. PageData pd = new PageData();
  602. pd.PageName = i.ToString();// + "页";
  603. pd.PageCode = i;
  604. PageData.Add(pd);
  605. }
  606. CbxPageList.ItemsSource = PageData;
  607. CbxPageList.SelectedIndex = APP.PageContextData.currpage - 1;
  608. #endregion 插入页码
  609. }
  610. /// <summary>
  611. /// 打印事件
  612. /// </summary>
  613. /// <param name="sender"></param>
  614. /// <param name="e"></param>
  615. private void BtnPrint_Click(object sender, RoutedEventArgs e)
  616. {
  617. try
  618. {
  619. //3种情况 1.文档图片 2.截图图片 3.没有图片
  620. if (APP.PageDrawList.Count == 0)
  621. {
  622. MessageWindow.Show("没有可打印的页,您可以通过加页、截图或导入来增加页!");
  623. return;
  624. }
  625. }
  626. catch (Exception ex)
  627. {
  628. MessageWindow.Show(ex.Message);
  629. Console.WriteLine("转换失败,原因:" + ex.Message);
  630. }
  631. if (GridPrintingTitle.Visibility == Visibility.Visible)
  632. {
  633. //GridPrintContent.Visibility = Visibility.Collapsed;
  634. GridMain.Visibility = Visibility.Visible;
  635. GridM.IsEnabled = true;
  636. GridRecordingTitle.Visibility = Visibility.Visible;
  637. GridPrintingTitle.Visibility = Visibility.Collapsed;
  638. //if (APP.pageData.pagenum > 0)
  639. //{
  640. // GridPage.Visibility = Visibility.Visible;
  641. //}
  642. //DataContext = APP.pageData;
  643. }
  644. else
  645. {
  646. PageHide();
  647. GridMain.Visibility = Visibility.Visible;
  648. GridM.IsEnabled = false;
  649. //GridPrintContent.Visibility = Visibility.Visible;
  650. GridPrintingTitle.Visibility = Visibility.Visible;
  651. if (APP.PageDrawList.Count > 0 && !string.IsNullOrWhiteSpace(APP.PageDrawList[0].PageImagePath))
  652. {
  653. InitializePrint(APP.PageDrawList[0].PageImagePath, GridM.ActualWidth, GridM.ActualHeight);
  654. }
  655. else
  656. {
  657. InitializePrint("", GridM.ActualWidth, gridActHeight);
  658. }
  659. }
  660. //if (APP.W_PrintWindow == null)
  661. //{
  662. // APP.W_PrintWindow = new PrintWindow
  663. // {
  664. // Owner = this
  665. // };
  666. //}
  667. //if (APP.PageDrawList.Count > 0 && !string.IsNullOrWhiteSpace(APP.PageDrawList[0].PageImagePath))
  668. //{
  669. // APP.W_PrintWindow.Initialize(APP.PageDrawList[0].PageImagePath, GridM.ActualWidth, GridM.ActualHeight);
  670. //}
  671. //else
  672. //{
  673. // APP.W_PrintWindow.Initialize("", GridM.ActualWidth, gridActHeight);
  674. //}
  675. //APP.W_PrintWindow.ShowDialog();
  676. }
  677. /// <summary>
  678. /// 最小化
  679. /// </summary>
  680. /// <param name="sender"></param>
  681. /// <param name="e"></param>
  682. private void BtnShrink_Click(object sender, RoutedEventArgs e)
  683. {
  684. if (WindowState == WindowState.Minimized)
  685. {
  686. WindowState = WindowState.Normal;
  687. }
  688. else
  689. {
  690. WindowState = WindowState.Minimized;
  691. }
  692. }
  693. #endregion 事件
  694. #region 设置
  695. /// <summary>
  696. /// 设置事件
  697. /// </summary>
  698. /// <param name="sender"></param>
  699. /// <param name="e"></param>
  700. private void BtnSetUp_Click(object sender, RoutedEventArgs e)
  701. {
  702. if (gridSetUp.Visibility == Visibility.Collapsed)
  703. {
  704. PageHide();
  705. gridSetUp.Visibility = Visibility.Visible;
  706. txbStoragePath.Content = APP.WKData.WkPath;
  707. #region 读取用户配置
  708. #region 请求地址 废弃 --2021年7月9日赵耀
  709. ////接口地址
  710. //if (!File.Exists(APP.DataPath + "interfaceAddress.txt")) //若为空
  711. //{
  712. // txbInterfaceAddress.Text = APP.apiUrl.Replace("http://", "").Trim();
  713. //}
  714. //else
  715. //{
  716. // txbInterfaceAddress.Text = System.IO.File.ReadAllText(APP.DataPath + "interfaceAddress.txt", Encoding.Default).Replace("http://", "").Trim();
  717. //}
  718. ////上传地址
  719. //if (!File.Exists(APP.DataPath + "imageUploadAddress.txt")) //若为空
  720. //{
  721. // txbImageUploadAddress.Text = APP.uploadUrl.Replace("http://", "").Replace("/", "").Trim();
  722. //}
  723. //else
  724. //{
  725. // txbImageUploadAddress.Text = System.IO.File.ReadAllText(APP.DataPath + "imageUploadAddress.txt", Encoding.Default).Replace("http://", "").Replace("/", "").Trim();
  726. //}
  727. ////下载地址
  728. //if (!File.Exists(APP.DataPath + "pictureShowsAddress.txt")) //若为空
  729. //{
  730. // txbPictureShowsAddress.Text = APP.showImageUrl.Replace("http://", "").Replace("/static", "").Replace("/", "").Trim();
  731. //}
  732. //else
  733. //{
  734. // txbPictureShowsAddress.Text = System.IO.File.ReadAllText(APP.DataPath + "pictureShowsAddress.txt", Encoding.Default).Replace("http://", "").Replace("/static", "").Replace("/", "").Trim();
  735. //}
  736. #endregion 请求地址 废弃 --2021年7月9日赵耀
  737. /// < !--摄像头位置 1.右上 2.左上 3.右下 4.左下-- >
  738. if ("1".Equals(APP.CameraPosition))
  739. {
  740. rbnRight.IsChecked = true;
  741. }
  742. else if ("2".Equals(APP.CameraPosition))
  743. {
  744. rbnLeft.IsChecked = true;
  745. }
  746. else if ("3".Equals(APP.CameraPosition))
  747. {
  748. rbnRightUnder.IsChecked = true;
  749. }
  750. else if ("4".Equals(APP.CameraPosition))
  751. {
  752. rbnLeftUnder.IsChecked = true;
  753. }
  754. string type = FileToolsCommon.GetConfigValue("VideoType");//<!--视频格式 1、MP4 2、FlV 3、AVI-->
  755. if ("1".Equals(type))
  756. {
  757. rbnMP4.IsChecked = true;
  758. }
  759. else if ("2".Equals(type))
  760. {
  761. rbnFLV.IsChecked = true;
  762. }
  763. else if ("3".Equals(type))
  764. {
  765. rbnAVI.IsChecked = true;
  766. }
  767. string isHide = FileToolsCommon.GetConfigValue("IsHideSRTool"); //工具栏是否隐藏
  768. if (isHide.Equals("1"))
  769. {
  770. rbnHide.IsChecked = true;
  771. }
  772. else
  773. {
  774. rbnvisi.IsChecked = true;
  775. }
  776. //string isSound = FileToolsCommon.GetConfigValue("IsSound");//<!--声音 true 有 false 无-->
  777. //if (isSound == "true")
  778. //{
  779. // rbnY.IsChecked = true;
  780. //}
  781. //else
  782. //{
  783. // rbnN.IsChecked = true;
  784. //}
  785. //加载皮肤按钮
  786. SkinSelectInit();
  787. #endregion 读取用户配置
  788. }
  789. else
  790. {
  791. GridMain.Visibility = Visibility.Visible;
  792. GridM.IsEnabled = true;
  793. GridRecordingTitle.Visibility = Visibility.Visible;
  794. gridSetUp.Visibility = Visibility.Collapsed;
  795. //if (APP.pageData.pagenum > 0)
  796. //{
  797. // GridPage.Visibility = Visibility.Visible;
  798. //}
  799. //DataContext = APP.pageData;
  800. }
  801. }
  802. /// <summary>
  803. /// 设置 保存事件
  804. /// </summary>
  805. /// <param name="sender"></param>
  806. /// <param name="e"></param>
  807. private void BtnSave_Click(object sender, RoutedEventArgs e)
  808. {
  809. try
  810. {
  811. BtnRecord.IsEnabled = true;//设置结束时可录制
  812. if (rbnMP4.IsChecked == true)
  813. {
  814. //存储文件
  815. FileToolsCommon.SetConfigValue("VideoType", "1");
  816. }
  817. else if (rbnFLV.IsChecked == true)
  818. {
  819. FileToolsCommon.SetConfigValue("VideoType", "2");
  820. }
  821. else
  822. {
  823. FileToolsCommon.SetConfigValue("VideoType", "3");
  824. }
  825. //if (rbnY.IsChecked == true)
  826. //{
  827. // FileToolsCommon.SetConfigValue("IsSound", "true");
  828. //}
  829. //else
  830. //{
  831. // FileToolsCommon.SetConfigValue("IsSound", "false");
  832. //}
  833. UpdateHideSRToolConfig();
  834. /// < !--摄像头位置 1.右上 2.左上 3.右下 4.左下-- >
  835. if (rbnRight.IsChecked == true)
  836. {
  837. FileToolsCommon.SetConfigValue("CameraPosition", "1");
  838. }
  839. else if (rbnLeft.IsChecked == true)
  840. {
  841. FileToolsCommon.SetConfigValue("CameraPosition", "2");
  842. }
  843. else if (rbnRightUnder.IsChecked == true)
  844. {
  845. FileToolsCommon.SetConfigValue("CameraPosition", "3");
  846. }
  847. else if (rbnLeftUnder.IsChecked == true)
  848. {
  849. FileToolsCommon.SetConfigValue("CameraPosition", "4");
  850. }
  851. //格式
  852. if (rbnMP4.IsChecked == true)
  853. {
  854. FileToolsCommon.SetConfigValue("VideoType", "1");
  855. }
  856. else if (rbnFLV.IsChecked == true)
  857. {
  858. FileToolsCommon.SetConfigValue("VideoType", "2");
  859. }
  860. else if (rbnAVI.IsChecked == true)
  861. {
  862. FileToolsCommon.SetConfigValue("VideoType", "3");
  863. }
  864. APP.CameraPosition = FileToolsCommon.GetConfigValue("CameraPosition");
  865. GridMain.Visibility = Visibility.Visible;
  866. GridM.IsEnabled = true;
  867. GridRecordingTitle.Visibility = Visibility.Visible;
  868. gridSetUp.Visibility = Visibility.Collapsed;
  869. imgPlayerRight.Visibility = Visibility.Collapsed;
  870. imgPlayerLeft.Visibility = Visibility.Collapsed;
  871. imgPlayerRightUnder.Visibility = Visibility.Collapsed;
  872. imgPlayerLeftUnder.Visibility = Visibility.Collapsed;
  873. if (!txbStoragePath.Content.ToString().Equals(APP.WKData.WkPath))
  874. {
  875. //存储文件
  876. FileToolsCommon.SetConfigValue("VideoSavePath", txbStoragePath.Content.ToString());
  877. MessageWindow.Show("路径已变更,下次创建微课时自动生效。");
  878. }
  879. }
  880. catch (Exception ex)
  881. {
  882. LogHelper.WriteErrLog("XHMicroLessonSystemWindow(设置保存事件报错:)" + ex.Message, ex);
  883. }
  884. }
  885. /// <summary>
  886. /// 设置 浏览事件
  887. /// </summary>
  888. /// <param name="sender"></param>
  889. /// <param name="e"></param>
  890. private void BtnBrowse_Click(object sender, RoutedEventArgs e)
  891. {
  892. //System.Diagnostics.Process.Start(APP.WKData.WkPath);
  893. //string desktopPath = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
  894. Ofd = new System.Windows.Forms.FolderBrowserDialog();
  895. Result = Ofd.ShowDialog();
  896. if (Result == System.Windows.Forms.DialogResult.OK)
  897. {
  898. if (Ofd.SelectedPath != "")
  899. {
  900. txbStoragePath.Content = Ofd.SelectedPath;
  901. //string ApplicationData = ZConfig.dataPath + "fileStorageAddress.txt";
  902. //string temp = ofd.SelectedPath;
  903. //System.IO.File.WriteAllText(ApplicationData, temp, Encoding.Default);
  904. }
  905. }
  906. }
  907. /// <summary>
  908. /// 打开文件所在位置
  909. /// </summary>
  910. /// <param name="sender"></param>
  911. /// <param name="e"></param>
  912. private void btnOpen_Click(object sender, RoutedEventArgs e)
  913. {
  914. System.Diagnostics.Process.Start(APP.WKData.WkPath);
  915. }
  916. /// <summary>
  917. /// 更新隐藏录屏工具栏隐藏状态
  918. /// </summary>
  919. private void UpdateHideSRToolConfig()
  920. {
  921. if (rbnHide.IsChecked == true)
  922. {
  923. //隐藏
  924. FileToolsCommon.SetConfigValue("IsHideSRTool", "1");
  925. APP.IsHideSRTool = true;
  926. }
  927. else
  928. {
  929. //显示
  930. FileToolsCommon.SetConfigValue("IsHideSRTool", "0");
  931. APP.IsHideSRTool = false;
  932. }
  933. }
  934. #region 切换皮肤
  935. /// <summary>
  936. /// 加载皮肤选项
  937. /// </summary>
  938. private void SkinSelectInit()
  939. {
  940. if (APP.SkinStyle == "0")
  941. {
  942. HideSkinSelect();
  943. SkinSelectWhite.Visibility = Visibility.Visible;
  944. }
  945. else if (APP.SkinStyle == "1")
  946. {
  947. HideSkinSelect();
  948. SkinSelectTechnologyBlue.Visibility = Visibility.Visible;
  949. }
  950. else
  951. {
  952. HideSkinSelect();
  953. SkinSelectWhite.Visibility = Visibility.Visible;
  954. }
  955. }
  956. /// <summary>
  957. /// 白色
  958. /// </summary>
  959. /// <param name="sender"></param>
  960. /// <param name="e"></param>
  961. private void BtnSkinWhite_Click(object sender, RoutedEventArgs e)
  962. {
  963. if (APP.SkinStyle != "0")
  964. {
  965. HideSkinSelect();
  966. SkinSelectWhite.Visibility = Visibility.Visible;
  967. APP.SkinStyle = "0";
  968. FileToolsCommon.SetConfigValue("SkinStyle", "0");
  969. SkinConfig.SwitchSkin(0);
  970. }
  971. }
  972. /// <summary>
  973. /// 科技蓝
  974. /// </summary>
  975. /// <param name="sender"></param>
  976. /// <param name="e"></param>
  977. private void BtnSkinTechnologyBlue_Click(object sender, RoutedEventArgs e)
  978. {
  979. if (APP.SkinStyle != "1")
  980. {
  981. HideSkinSelect();
  982. SkinSelectTechnologyBlue.Visibility = Visibility.Visible;
  983. APP.SkinStyle = "1";
  984. FileToolsCommon.SetConfigValue("SkinStyle", "1");
  985. SkinConfig.SwitchSkin(1);
  986. }
  987. }
  988. /// <summary>
  989. /// 隐藏皮肤选择键
  990. /// </summary>
  991. private void HideSkinSelect()
  992. {
  993. SkinSelectWhite.Visibility = Visibility.Hidden;
  994. SkinSelectTechnologyBlue.Visibility = Visibility.Hidden;
  995. }
  996. #endregion 切换皮肤
  997. #endregion 设置
  998. #region 画笔
  999. /// <summary>
  1000. /// 画笔颜色事件 白色
  1001. /// </summary>
  1002. /// <param name="sender"></param>
  1003. /// <param name="e"></param>
  1004. private void BtnWhite_Click(object sender, RoutedEventArgs e)
  1005. {
  1006. ////创建 DrawingAttributes 类的一个实例
  1007. //drawingAttributes = new DrawingAttributes();
  1008. ////将 InkCanvas 的 DefaultDrawingAttributes 属性的值赋成创建的 DrawingAttributes 类的对象的引用
  1009. ////InkCanvas 通过 DefaultDrawingAttributes 属性来获取墨迹的各种设置,该属性的类型为 DrawingAttributes 型
  1010. //blackboard_canvas.DefaultDrawingAttributes = drawingAttributes;
  1011. ////设置 DrawingAttributes 的 Color 属性设置颜色
  1012. drawingAttributes.Color = Colors.White;
  1013. Color = Colors.White;
  1014. }
  1015. /// <summary>
  1016. /// 画笔颜色事件 红色
  1017. /// </summary>
  1018. /// <param name="sender"></param>
  1019. /// <param name="e"></param>
  1020. private void BtnRed_Click(object sender, RoutedEventArgs e)
  1021. {
  1022. //设置 DrawingAttributes 的 Color 属性设置颜色
  1023. drawingAttributes.Color = Colors.Red;
  1024. Color = Colors.Red;
  1025. imgRed.Visibility = Visibility.Visible;
  1026. imgGray.Visibility = Visibility.Collapsed;
  1027. imgCyanBlue.Visibility = Visibility.Collapsed;
  1028. imgYellow.Visibility = Visibility.Collapsed;
  1029. imgBlue.Visibility = Visibility.Collapsed;
  1030. }
  1031. /// <summary>
  1032. /// 画笔颜色事件 黑色
  1033. /// </summary>
  1034. /// <param name="sender"></param>
  1035. /// <param name="e"></param>
  1036. private void BtnGray_Click(object sender, RoutedEventArgs e)
  1037. {
  1038. drawingAttributes.Color = Colors.Black;
  1039. Color = Colors.Black;
  1040. imgRed.Visibility = Visibility.Collapsed;
  1041. imgGray.Visibility = Visibility.Visible;
  1042. imgCyanBlue.Visibility = Visibility.Collapsed;
  1043. imgYellow.Visibility = Visibility.Collapsed;
  1044. imgBlue.Visibility = Visibility.Collapsed;
  1045. }
  1046. /// <summary>
  1047. /// 画笔颜色事件 青色
  1048. /// </summary>
  1049. /// <param name="sender"></param>
  1050. /// <param name="e"></param>
  1051. private void BtnCyanBlue_Click(object sender, RoutedEventArgs e)
  1052. {
  1053. drawingAttributes.Color = Colors.LimeGreen;
  1054. Color = Colors.LimeGreen;
  1055. imgRed.Visibility = Visibility.Collapsed;
  1056. imgGray.Visibility = Visibility.Collapsed;
  1057. imgCyanBlue.Visibility = Visibility.Visible;
  1058. imgYellow.Visibility = Visibility.Collapsed;
  1059. imgBlue.Visibility = Visibility.Collapsed;
  1060. }
  1061. /// <summary>
  1062. /// 画笔颜色事件 黄色
  1063. /// </summary>
  1064. /// <param name="sender"></param>
  1065. /// <param name="e"></param>
  1066. private void BtnYellow_Click(object sender, RoutedEventArgs e)
  1067. {
  1068. drawingAttributes.Color = Colors.Gold;
  1069. Color = Colors.Gold;
  1070. imgRed.Visibility = Visibility.Collapsed;
  1071. imgGray.Visibility = Visibility.Collapsed;
  1072. imgCyanBlue.Visibility = Visibility.Collapsed;
  1073. imgYellow.Visibility = Visibility.Visible;
  1074. imgBlue.Visibility = Visibility.Collapsed;
  1075. }
  1076. /// <summary>
  1077. /// 画笔颜色事件 蓝色
  1078. /// </summary>
  1079. /// <param name="sender"></param>
  1080. /// <param name="e"></param>
  1081. private void BtnBlue_Click(object sender, RoutedEventArgs e)
  1082. {
  1083. drawingAttributes.Color = Colors.DeepSkyBlue;
  1084. Color = Colors.DeepSkyBlue;
  1085. imgRed.Visibility = Visibility.Collapsed;
  1086. imgGray.Visibility = Visibility.Collapsed;
  1087. imgCyanBlue.Visibility = Visibility.Collapsed;
  1088. imgYellow.Visibility = Visibility.Collapsed;
  1089. imgBlue.Visibility = Visibility.Visible;
  1090. }
  1091. /// <summary>
  1092. /// 画笔粗细事件 细
  1093. /// </summary>
  1094. /// <param name="sender"></param>
  1095. /// <param name="e"></param>
  1096. private void RbnFine_Click(object sender, RoutedEventArgs e)
  1097. {
  1098. drawingAttributes.Width = 1;
  1099. drawingAttributes.Height = 1;
  1100. PenSize = 1;
  1101. }
  1102. /// <summary>
  1103. /// 画笔粗细事件 中
  1104. /// </summary>
  1105. /// <param name="sender"></param>
  1106. /// <param name="e"></param>
  1107. private void RbnIn_Click(object sender, RoutedEventArgs e)
  1108. {
  1109. drawingAttributes.Width = 3;
  1110. drawingAttributes.Height = 3;
  1111. PenSize = 3;
  1112. }
  1113. /// <summary>
  1114. /// 画笔粗细事件 粗
  1115. /// </summary>
  1116. /// <param name="sender"></param>
  1117. /// <param name="e"></param>
  1118. private void RbnCrude_Click(object sender, RoutedEventArgs e)
  1119. {
  1120. drawingAttributes.Width = 5;
  1121. drawingAttributes.Height = 5;
  1122. PenSize = 5;
  1123. }
  1124. private void imgCanvas_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
  1125. {
  1126. mouseDown = true;
  1127. }
  1128. #endregion 画笔
  1129. #region 导入截图
  1130. /// <summary>
  1131. /// 截图事件
  1132. /// </summary>
  1133. /// <param name="sender"></param>
  1134. /// <param name="e"></param>
  1135. private void BtnScreenshot_Click(object sender, RoutedEventArgs e)
  1136. {
  1137. double do1 = GridContent.ActualHeight;
  1138. double dou = GridMain.ActualHeight;
  1139. Record();
  1140. HideAngleBorder();
  1141. imgCanvas.Margin = new Thickness(0, 0, 0, 0);
  1142. APP.ImgPath = string.Empty;
  1143. string time = GetTimeStamp();
  1144. string desktopPath = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory) + time + ".jpg";
  1145. APP.ImgPath = desktopPath;
  1146. ImageHelper.GetScreenshot(new System.Drawing.Rectangle(0, 0, 0, 0), desktopPath, false, out BitmapImage bitmap);
  1147. k_hook.Stop();
  1148. if (WindowState == WindowState.Normal)//截图隐藏窗口
  1149. {
  1150. WindowState = WindowState.Minimized;
  1151. }
  1152. if (APP.W_JieTuWindow != null)
  1153. {
  1154. APP.W_JieTuWindow.initialization();
  1155. APP.W_JieTuWindow.Screenshot();
  1156. APP.W_JieTuWindow.InitializeKeyDownEvent();
  1157. APP.W_JieTuWindow.WindowState = WindowState.Maximized;
  1158. APP.W_JieTuWindow.Visibility = Visibility.Visible;
  1159. }
  1160. else
  1161. {
  1162. APP.W_JieTuWindow = new JieTuWindow();
  1163. APP.W_JieTuWindow.InitializeKeyDownEvent();
  1164. // 订阅事件
  1165. APP.W_JieTuWindow.ChangeTextEvent += new ChangeTextHandler(frm_ChangeTextEvent);
  1166. APP.W_JieTuWindow.click_closeJietuWindowClick += JietuWindow_click_closeJietuWindowClick;
  1167. APP.W_JieTuWindow.Show();
  1168. }
  1169. //imgCanvas.Source = new BitmapImage(new Uri(desktopPath));
  1170. }
  1171. /// <summary>
  1172. /// 获取时间戳
  1173. /// </summary>
  1174. /// <returns></returns>
  1175. public string GetTimeStamp()
  1176. {
  1177. TimeSpan ts = DateTime.Now - new DateTime(1970, 1, 1, 0, 0, 0, 0);
  1178. return Convert.ToInt64(ts.TotalSeconds).ToString();
  1179. }
  1180. /// <summary>
  1181. /// 返回一个时间戳到毫秒
  1182. /// </summary>
  1183. /// <returns></returns>
  1184. public static long Timestamp()
  1185. {
  1186. TimeSpan ts = DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0);
  1187. long timestr = Convert.ToInt64(ts.TotalMilliseconds);
  1188. return timestr;
  1189. }
  1190. public void WindowType()
  1191. {
  1192. if (WindowState == WindowState.Minimized)//截图完恢复窗口
  1193. {
  1194. Topmost = true;
  1195. WindowState = WindowState.Normal;
  1196. }
  1197. }
  1198. /// <summary>
  1199. /// 截图关闭窗口
  1200. /// </summary>
  1201. /// <param name="text"></param>
  1202. private void frm_ChangeTextEvent(string text)
  1203. {
  1204. if ("关闭窗口".Equals(text))
  1205. {
  1206. if (WindowState == WindowState.Minimized)//截图完恢复窗口
  1207. {
  1208. Topmost = true;
  1209. WindowState = WindowState.Normal;
  1210. }
  1211. InitializeKeyDownEvent();
  1212. if (!string.IsNullOrWhiteSpace(APP.ImgPath) && File.Exists(APP.ImgPath))
  1213. {
  1214. if (APP.PageContextData.currpage == 0)
  1215. {
  1216. APP.PageContextData.pagenum += 1;
  1217. APP.PageContextData.currpage = APP.PageContextData.pagenum;
  1218. myblackboard.changepage(APP.PageContextData.currpage - 1);
  1219. GridPage.Visibility = Visibility.Visible;//页码大于0 显示
  1220. #region 插入页码
  1221. PageData = new List<PageData>();
  1222. for (int i = 1; i <= APP.PageContextData.pagenum; i++)
  1223. {
  1224. PageData pd = new PageData();
  1225. pd.PageName = i.ToString();// + "页";
  1226. pd.PageCode = i;
  1227. PageData.Add(pd);
  1228. }
  1229. CbxPageList.ItemsSource = PageData;
  1230. CbxPageList.SelectedIndex = APP.PageContextData.currpage - 1;
  1231. #endregion 插入页码
  1232. }
  1233. if (APP.PageDrawList.Count >= APP.PageContextData.currpage)
  1234. {
  1235. APP.PageDrawList[APP.PageContextData.currpage - 1].PageImagePath = APP.ImgPath;//zxycs
  1236. APP.PageDrawList[APP.PageContextData.currpage - 1].PdfImagePath = APP.ImgPath;
  1237. }
  1238. else
  1239. {
  1240. Model_DrawData model_DrawData = new Model_DrawData
  1241. {
  1242. PageImagePath = APP.ImgPath,
  1243. PdfImagePath = APP.ImgPath
  1244. };
  1245. APP.PageDrawList.Add(model_DrawData);
  1246. }
  1247. if (APP.PageDrawList.Count >= APP.PageContextData.currpage && !string.IsNullOrWhiteSpace(APP.PageDrawList[APP.PageContextData.currpage - 1].PageImagePath))
  1248. {
  1249. imgDocumentation.Source = null;
  1250. BitmapImage bitImg = new BitmapImage(new Uri(APP.PageDrawList[APP.PageContextData.currpage - 1].PageImagePath));
  1251. mouseDown = false;
  1252. APP.PageDrawList[APP.PageContextData.currpage - 1].ImageLocation = new TranslateTransform
  1253. {
  1254. X = 0.1,
  1255. Y = 0.1
  1256. };
  1257. APP.PageDrawList[APP.PageContextData.currpage - 1].Type = "截图";
  1258. APP.PageDrawList[APP.PageContextData.currpage - 1].IsImageLocation = false;
  1259. imgCanvas.Source = bitImg;
  1260. imgCanvas.Width = bitImg.Width;
  1261. imgCanvas.Height = bitImg.Height;
  1262. ScroMain.ScrollToVerticalOffset(0);
  1263. APP.PageDrawList[APP.PageContextData.currpage - 1].ImageSizes = new ScaleTransform
  1264. {
  1265. CenterX = imgCanvas.Width,
  1266. CenterY = imgCanvas.Height
  1267. };
  1268. BtnPrint.IsEnabled = true;
  1269. }
  1270. }
  1271. Topmost = false;
  1272. }
  1273. else if ("取消".Equals(text))
  1274. {
  1275. if (WindowState == WindowState.Minimized)//截图完恢复窗口
  1276. {
  1277. Topmost = true;
  1278. WindowState = WindowState.Normal;
  1279. }
  1280. }
  1281. }
  1282. /// <summary>
  1283. /// 截图关闭 非正常关闭截图时,截图清空
  1284. /// </summary>
  1285. private void JietuWindow_click_closeJietuWindowClick()
  1286. {
  1287. if (WindowState == WindowState.Minimized)//截图完恢复窗口
  1288. {
  1289. WindowState = WindowState.Normal;
  1290. }
  1291. APP.W_JieTuWindow = null;
  1292. }
  1293. /// 截图的图片鼠标右键事件 </summary> <param name="sender"></param> <param name="e"></param>
  1294. private void imgCanvas_MouseRightButtonDown(object sender, MouseButtonEventArgs e)
  1295. {
  1296. imgCanvas.Source = null;
  1297. APP.PageDrawList[APP.PageContextData.currpage - 1].PdfImagePath = null;
  1298. APP.PageDrawList[APP.PageContextData.currpage - 1].PageImagePath = null;
  1299. }
  1300. /// <summary>
  1301. /// 导入事件
  1302. /// </summary>
  1303. /// <param name="sender"></param>
  1304. /// <param name="e"></param>
  1305. private void BtnImport_Click(object sender, RoutedEventArgs e)
  1306. {
  1307. try
  1308. {
  1309. Record();
  1310. HideAngleBorder();
  1311. string desktopPath = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
  1312. ofd = new System.Windows.Forms.OpenFileDialog
  1313. {
  1314. //Filter = "文档|*.docx;*.doc;*.ppt;*.pptx",
  1315. //增加导入图片
  1316. Filter = "文档|*.docx;*.doc;*.ppt;*.pptx;*.pdf|图片|*.jpg;*.jpeg;*.png;*.bmp",
  1317. InitialDirectory = desktopPath,
  1318. Multiselect = false,
  1319. AddExtension = true,
  1320. DereferenceLinks = true
  1321. };
  1322. //APP.myloading.Show();
  1323. APP.BackgroundWorkerHelper.RunWorkerAsync(InvokeServering, InvokeServerCompate);
  1324. //new Thread(
  1325. // o =>
  1326. // {
  1327. // Thread.Sleep(400);
  1328. // Dispatcher.Invoke(new Action(() =>
  1329. // {
  1330. // OpenDialog();
  1331. // }
  1332. // ));
  1333. // })
  1334. //{
  1335. // IsBackground = true
  1336. //}.Start();
  1337. }
  1338. catch (Exception ex)
  1339. {
  1340. LogHelper.WriteErrLog("【导入(BtnImport_Click)" + ex.Message, ex);
  1341. }
  1342. }
  1343. /// <summary>
  1344. /// 导入-开始
  1345. /// </summary>
  1346. /// <returns></returns>
  1347. private object InvokeServering()
  1348. {
  1349. Dispatcher.Invoke(new Action(() =>
  1350. {
  1351. result = ofd.ShowDialog();
  1352. }));
  1353. if (result == System.Windows.Forms.DialogResult.OK)
  1354. {
  1355. if (ofd.FileName != "")
  1356. {
  1357. List<string> imagelist = new List<string>() { "jpg", "jpeg", "png", "bmp" };
  1358. Dispatcher.Invoke(new Action(() =>
  1359. {
  1360. APP.myloading.Show();
  1361. myblackboard.changepage(APP.PageContextData.pagenum);
  1362. }));
  1363. string filepath = ofd.FileName;
  1364. string filesuff = filepath.Substring(filepath.LastIndexOf(".") + 1).ToLower();
  1365. string path = ofd.SafeFileName.Replace(".ppt", "").Replace(".pptx", "").Trim();
  1366. string type = ofd.SafeFileName.Replace(".ppt", "typezsygppt").Replace(".pptx", "typezsygppt").Replace(".pdf", "typepdf").Trim();
  1367. if (type.Contains("typezsygppt"))//ppt
  1368. {
  1369. try
  1370. {
  1371. #region PPT转PDF
  1372. string pathTemp = AppDomain.CurrentDomain.BaseDirectory + "Temp\\";
  1373. path = pathTemp + path + ".pdf";
  1374. FileToolsCommon.CreateDirectory(pathTemp);
  1375. //PPT转PDF
  1376. Presentation ppt = new Presentation(filepath);
  1377. ppt.Save(path, Aspose.Slides.Export.SaveFormat.Pdf);
  1378. #endregion PPT转PDF
  1379. #region PDF转图片
  1380. // 图片绝对路径集合
  1381. List<string> images = new List<string>();
  1382. string directoryPath = pathTemp;
  1383. //aspose许可证
  1384. //Aspose.Pdf.License l = new Aspose.Pdf.License();
  1385. //string licenseName = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Aspose.Total.Product.Family.lic");
  1386. //l.SetLicense(licenseName);
  1387. //定义Jpeg转换设备
  1388. Aspose.Pdf.Document document = new Aspose.Pdf.Document(path);
  1389. Aspose.Pdf.Devices.JpegDevice device = new Aspose.Pdf.Devices.JpegDevice();
  1390. //int quality = int.Parse(this.comboBox1.SelectedItem.ToString());
  1391. //directoryPath += quality;
  1392. Directory.CreateDirectory(directoryPath);
  1393. //默认质量为100,设置质量的好坏与处理速度不成正比,甚至是设置的质量越低反而花的时间越长,怀疑处理过程是先生成高质量的再压缩
  1394. device = new Aspose.Pdf.Devices.JpegDevice(100);
  1395. //遍历每一页转为jpg
  1396. for (int i = 1; i <= document.Pages.Count; i++)
  1397. {
  1398. long ii = Timestamp();
  1399. string filePathOutPut = Path.Combine(directoryPath, string.Format("{0}{1}.jpg", ii, i));
  1400. images.Add(filePathOutPut);
  1401. FileStream fs = new FileStream(filePathOutPut, FileMode.OpenOrCreate);
  1402. try
  1403. {
  1404. device.Process(document.Pages[i], fs);
  1405. fs.Close();
  1406. }
  1407. catch (Exception)
  1408. {
  1409. fs.Close();
  1410. File.Delete(filePathOutPut);
  1411. }
  1412. }
  1413. #endregion PDF转图片
  1414. Dispatcher.Invoke(new Action(() =>
  1415. {
  1416. string[] page = images.ToArray();
  1417. int num = 0;
  1418. int iStart = APP.PageContextData.pagenum;//导入文档的开始下标
  1419. int iEnd = page.Length + APP.PageContextData.pagenum;//导入文档的结束下标
  1420. for (int i = 0 + APP.PageContextData.pagenum; i < page.Length + APP.PageContextData.pagenum; i++)//给画板模型加图片路径
  1421. {
  1422. if (APP.PageDrawList != null && APP.PageDrawList.Count > i)
  1423. {
  1424. APP.PageDrawList[i].PageImagePath = page[i - APP.PageContextData.pagenum]; //zxycs
  1425. APP.PageDrawList[i].PdfImagePath = page[i - APP.PageContextData.pagenum];
  1426. APP.PageDrawList[i].PageNum = i + 1;
  1427. APP.PageDrawList[i].ImgDocumentation = true;
  1428. APP.PageDrawList[i].Type = "ppt";
  1429. }
  1430. else
  1431. {
  1432. Model_DrawData model_DrawData = new Model_DrawData
  1433. {
  1434. PageImagePath = page[i - APP.PageContextData.pagenum],
  1435. PdfImagePath = page[i - APP.PageContextData.pagenum],
  1436. PageNum = i + 1,
  1437. ImgDocumentation = true,
  1438. Type = "ppt"
  1439. };
  1440. APP.PageDrawList.Add(model_DrawData);
  1441. }
  1442. BtnPrint.IsEnabled = true;
  1443. APP.SaveDraw();
  1444. num++;
  1445. }
  1446. if (num > 0)
  1447. {
  1448. APP.PageContextData.currpage = APP.PageContextData.pagenum + 1;
  1449. APP.PageContextData.pagenum += num;
  1450. GridPage.Visibility = Visibility.Visible;//页码大于0 显示
  1451. }
  1452. if (APP.PageContextData.currpage > 0 && APP.PageContextData.currpage <= APP.PageDrawList.Count)
  1453. {
  1454. imgCanvas.Source = null;
  1455. BtnScreenshot.IsEnabled = false;
  1456. imgDocumentation.Source = null;
  1457. imgPPT.Source = new BitmapImage(new Uri(APP.PageDrawList[APP.PageContextData.currpage - 1].PageImagePath));
  1458. ScroMain.ScrollToVerticalOffset(0);
  1459. for (int i = iStart; i < iEnd; i++)
  1460. {
  1461. APP.PageDrawList[i].ImageLocation = new TranslateTransform
  1462. {
  1463. X = 0.1,
  1464. Y = 0.1
  1465. };
  1466. APP.PageDrawList[i].IsImageLocation = true;
  1467. APP.PageDrawList[i].ImageSizes = new ScaleTransform
  1468. {
  1469. CenterX = imgCanvas.Width,
  1470. CenterY = imgCanvas.Height
  1471. };
  1472. }
  1473. }
  1474. else
  1475. {
  1476. imgDocumentation.Source = null;
  1477. imgCanvas.Source = null;
  1478. imgPPT.Source = null;
  1479. ///截图可用
  1480. BtnScreenshot.IsEnabled = true;
  1481. }
  1482. }));
  1483. }
  1484. catch (Exception ex)
  1485. {
  1486. Dispatcher.Invoke(new Action(() =>
  1487. {
  1488. MessageWindow.Show("无法访问文件,请检查文件是否有效或解除文件占用!");
  1489. }));
  1490. LogHelper.WriteErrLog("【打开ppt】(OpenDialog PPT)" + ex.Message, ex);
  1491. }
  1492. }
  1493. else if (type.Contains("typepdf"))
  1494. {
  1495. try
  1496. {
  1497. string pathTemp = AppDomain.CurrentDomain.BaseDirectory + "Temp\\";
  1498. #region PDF转图片
  1499. // 图片绝对路径集合
  1500. List<string> images = new List<string>();
  1501. string directoryPath = pathTemp;
  1502. //aspose许可证
  1503. //Aspose.Pdf.License l = new Aspose.Pdf.License();
  1504. //string licenseName = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Aspose.Total.Product.Family.lic");
  1505. //l.SetLicense(licenseName);
  1506. //定义Jpeg转换设备
  1507. Aspose.Pdf.Document document = new Aspose.Pdf.Document(filepath);
  1508. Aspose.Pdf.Devices.JpegDevice device = new Aspose.Pdf.Devices.JpegDevice();
  1509. //int quality = int.Parse(this.comboBox1.SelectedItem.ToString());
  1510. //directoryPath += quality;
  1511. Directory.CreateDirectory(directoryPath);
  1512. //默认质量为100,设置质量的好坏与处理速度不成正比,甚至是设置的质量越低反而花的时间越长,怀疑处理过程是先生成高质量的再压缩
  1513. device = new Aspose.Pdf.Devices.JpegDevice(100);
  1514. //遍历每一页转为jpg
  1515. for (int i = 1; i <= document.Pages.Count; i++)
  1516. {
  1517. long ii = Timestamp();
  1518. string filePathOutPut = Path.Combine(directoryPath, string.Format("{0}{1}.jpg", ii, i));
  1519. images.Add(filePathOutPut);
  1520. FileStream fs = new FileStream(filePathOutPut, FileMode.OpenOrCreate);
  1521. try
  1522. {
  1523. device.Process(document.Pages[i], fs);
  1524. fs.Close();
  1525. }
  1526. catch (Exception)
  1527. {
  1528. fs.Close();
  1529. File.Delete(filePathOutPut);
  1530. }
  1531. }
  1532. #endregion PDF转图片
  1533. string[] page = images.ToArray();
  1534. int num = 0;
  1535. int iStart = APP.PageContextData.pagenum;//导入文档的开始下标
  1536. int iEnd = page.Length + APP.PageContextData.pagenum;//导入文档的结束下标
  1537. Dispatcher.Invoke(new Action(() =>
  1538. {
  1539. for (int i = APP.PageContextData.pagenum; i < page.Length + APP.PageContextData.pagenum; i++)//给画板模型加图片路径
  1540. {
  1541. if (APP.PageDrawList != null && APP.PageDrawList.Count > i)
  1542. {
  1543. APP.PageDrawList[i].PageImagePath = page[i - APP.PageContextData.pagenum]; //zxycs
  1544. APP.PageDrawList[i].PdfImagePath = page[i - APP.PageContextData.pagenum];
  1545. APP.PageDrawList[i].PageNum = i + 1;
  1546. APP.PageDrawList[i].ImgDocumentation = true;
  1547. APP.PageDrawList[i].Type = "word";
  1548. }
  1549. else
  1550. {
  1551. Model_DrawData model_DrawData = new Model_DrawData
  1552. {
  1553. PageImagePath = page[i - APP.PageContextData.pagenum],
  1554. PdfImagePath = page[i - APP.PageContextData.pagenum],
  1555. PageNum = i + 1,
  1556. ImgDocumentation = true,
  1557. Type = "word"
  1558. };
  1559. APP.PageDrawList.Add(model_DrawData);
  1560. }
  1561. BtnPrint.IsEnabled = true;
  1562. APP.SaveDraw();
  1563. num++;
  1564. }
  1565. if (num > 0)
  1566. {
  1567. APP.PageContextData.currpage = APP.PageContextData.pagenum + 1;
  1568. APP.PageContextData.pagenum += num;
  1569. GridPage.Visibility = Visibility.Visible;//页码大于0 显示
  1570. }
  1571. if (APP.PageContextData.currpage > 0 && APP.PageContextData.currpage <= APP.PageDrawList.Count)
  1572. {
  1573. imgCanvas.Source = null;
  1574. imgPPT.Source = null;
  1575. BtnScreenshot.IsEnabled = false;
  1576. imgDocumentation.Visibility = Visibility.Visible;
  1577. imgDocumentation.Source = new BitmapImage(new Uri(APP.PageDrawList[APP.PageContextData.currpage - 1].PageImagePath));//给当前页面展示图片
  1578. ScroMain.ScrollToVerticalOffset(0);
  1579. }
  1580. else
  1581. {
  1582. imgDocumentation.Source = null;
  1583. imgCanvas.Source = null;
  1584. imgPPT.Source = null;
  1585. ///截图可用
  1586. BtnScreenshot.IsEnabled = true;
  1587. }
  1588. }));
  1589. }
  1590. catch (Exception ex)
  1591. {
  1592. Dispatcher.Invoke(new Action(() =>
  1593. {
  1594. MessageWindow.Show(ex.Message);
  1595. }));
  1596. LogHelper.WriteErrLog("【打开pdf】(OpenDialog pdf)" + ex.Message, ex);
  1597. }
  1598. }
  1599. else if (imagelist.Contains(filesuff))///导入图片
  1600. {
  1601. string imagepath = AppDomain.CurrentDomain.BaseDirectory + "temp";
  1602. if (!Directory.Exists(imagepath))
  1603. {
  1604. Directory.CreateDirectory(imagepath);
  1605. }
  1606. TimeSpan ts = DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0);
  1607. string timestr = Convert.ToInt64(ts.TotalMilliseconds).ToString();
  1608. string filepathCopy = Path.Combine(imagepath, timestr + ofd.SafeFileName);
  1609. System.IO.File.Copy(filepath, filepathCopy);
  1610. filepath = filepathCopy;
  1611. APP.ImgPath = filepath;
  1612. Dispatcher.Invoke(new Action(() =>
  1613. {
  1614. if (APP.PageContextData.currpage == 0)
  1615. {
  1616. APP.PageContextData.pagenum += 1;
  1617. APP.PageContextData.currpage = APP.PageContextData.pagenum;
  1618. myblackboard.changepage(APP.PageContextData.currpage - 1);
  1619. GridPage.Visibility = Visibility.Visible;//页码大于0 显示
  1620. #region 插入页码
  1621. PageData = new List<PageData>();
  1622. for (int i = 1; i <= APP.PageContextData.pagenum; i++)
  1623. {
  1624. PageData pd = new PageData();
  1625. pd.PageName = i.ToString();// + "页";
  1626. pd.PageCode = i;
  1627. PageData.Add(pd);
  1628. }
  1629. CbxPageList.ItemsSource = PageData;
  1630. CbxPageList.SelectedIndex = APP.PageContextData.currpage - 1;
  1631. #endregion 插入页码
  1632. }
  1633. else
  1634. {
  1635. APP.PageContextData.pagenum += 1;
  1636. APP.PageContextData.currpage = APP.PageContextData.pagenum;
  1637. myblackboard.changepage(APP.PageContextData.currpage - 1);
  1638. }
  1639. if (APP.PageDrawList.Count >= APP.PageContextData.currpage)
  1640. {
  1641. APP.PageDrawList[APP.PageContextData.currpage - 1].PageImagePath = APP.ImgPath;//zxycs
  1642. APP.PageDrawList[APP.PageContextData.currpage - 1].PdfImagePath = APP.ImgPath;
  1643. }
  1644. else
  1645. {
  1646. Model_DrawData model_DrawData = new Model_DrawData
  1647. {
  1648. PageImagePath = APP.ImgPath,
  1649. PdfImagePath = APP.ImgPath
  1650. };
  1651. APP.PageDrawList.Add(model_DrawData);
  1652. }
  1653. if (APP.PageDrawList.Count >= APP.PageContextData.currpage && !string.IsNullOrWhiteSpace(APP.PageDrawList[APP.PageContextData.currpage - 1].PageImagePath))
  1654. {
  1655. imgDocumentation.Source = null;
  1656. BitmapImage bitImg = new BitmapImage(new Uri(APP.PageDrawList[APP.PageContextData.currpage - 1].PageImagePath));
  1657. mouseDown = false;
  1658. APP.PageDrawList[APP.PageContextData.currpage - 1].ImageLocation = new TranslateTransform
  1659. {
  1660. X = 0.1,
  1661. Y = 0.1
  1662. };
  1663. APP.PageDrawList[APP.PageContextData.currpage - 1].Type = "截图";
  1664. APP.PageDrawList[APP.PageContextData.currpage - 1].IsImageLocation = false;
  1665. imgCanvas.Source = bitImg;
  1666. imgCanvas.Width = bitImg.Width;
  1667. imgCanvas.Height = bitImg.Height;
  1668. ScroMain.ScrollToVerticalOffset(0);
  1669. imgCanvas.Margin = new Thickness(APP.PageDrawList[APP.PageContextData.currpage - 1].ImageLocation.X, APP.PageDrawList[APP.PageContextData.currpage - 1].ImageLocation.Y, 0, 0);
  1670. APP.PageDrawList[APP.PageContextData.currpage - 1].ImageSizes = new ScaleTransform
  1671. {
  1672. CenterX = imgCanvas.Width,
  1673. CenterY = imgCanvas.Height
  1674. };
  1675. BtnPrint.IsEnabled = true;
  1676. }
  1677. }));
  1678. }
  1679. else//word
  1680. {
  1681. try
  1682. {
  1683. string paths = AppDomain.CurrentDomain.BaseDirectory + "Temp\\";
  1684. string[] page = ConvertWordToImage(filepath, paths, "", 0, 0, null, 0).ToArray();
  1685. int num = 0;
  1686. Dispatcher.Invoke(new Action(() =>
  1687. {
  1688. for (int i = 0 + APP.PageContextData.pagenum; i < page.Length + APP.PageContextData.pagenum; i++)//给画板模型加图片路径
  1689. {
  1690. if (APP.PageDrawList != null && APP.PageDrawList.Count > i)
  1691. {
  1692. APP.PageDrawList[i].PageImagePath = page[i - APP.PageContextData.pagenum]; //zxycs
  1693. APP.PageDrawList[i].PdfImagePath = page[i - APP.PageContextData.pagenum];
  1694. APP.PageDrawList[i].PageNum = i + 1;
  1695. APP.PageDrawList[i].ImgDocumentation = true;
  1696. APP.PageDrawList[i].Type = "word";
  1697. }
  1698. else
  1699. {
  1700. Model_DrawData model_DrawData = new Model_DrawData
  1701. {
  1702. PageImagePath = page[i - APP.PageContextData.pagenum],
  1703. PdfImagePath = page[i - APP.PageContextData.pagenum],
  1704. PageNum = i + 1,
  1705. ImgDocumentation = true,
  1706. Type = "word"
  1707. };
  1708. APP.PageDrawList.Add(model_DrawData);
  1709. }
  1710. BtnPrint.IsEnabled = true;
  1711. APP.SaveDraw();
  1712. num++;
  1713. }
  1714. if (num > 0)
  1715. {
  1716. APP.PageContextData.currpage = APP.PageContextData.pagenum + 1;
  1717. APP.PageContextData.pagenum += num;
  1718. GridPage.Visibility = Visibility.Visible;//页码大于0 显示
  1719. }
  1720. if (APP.PageContextData.currpage > 0 && APP.PageContextData.currpage <= APP.PageDrawList.Count)
  1721. {
  1722. imgCanvas.Source = null;
  1723. imgPPT.Source = null;
  1724. BtnScreenshot.IsEnabled = false;
  1725. imgDocumentation.Visibility = Visibility.Visible;
  1726. imgDocumentation.Source = new BitmapImage(new Uri(APP.PageDrawList[APP.PageContextData.currpage - 1].PageImagePath));//给当前页面展示图片
  1727. ScroMain.ScrollToVerticalOffset(0);
  1728. }
  1729. else
  1730. {
  1731. imgDocumentation.Source = null;
  1732. imgCanvas.Source = null;
  1733. imgPPT.Source = null;
  1734. ///截图可用
  1735. BtnScreenshot.IsEnabled = true;
  1736. }
  1737. }));
  1738. }
  1739. catch (Exception ex)
  1740. {
  1741. Dispatcher.Invoke(new Action(() =>
  1742. {
  1743. MessageWindow.Show("无法访问文件,请检查文件是否有效或解除文件占用!");
  1744. }));
  1745. LogHelper.WriteErrLog("【XHMicroLessonSystemWindow】(OpenDialog 导入文档)" + ex.Message, ex);
  1746. }
  1747. }
  1748. #region 插入页码
  1749. Dispatcher.Invoke(new Action(() =>
  1750. {
  1751. PageData = new List<PageData>();
  1752. for (int i = 1; i <= APP.PageContextData.pagenum; i++)
  1753. {
  1754. PageData pd = new PageData();
  1755. pd.PageName = i.ToString();//+ "页";
  1756. pd.PageCode = i;
  1757. PageData.Add(pd);
  1758. }
  1759. CbxPageList.ItemsSource = PageData;
  1760. CbxPageList.SelectedIndex = APP.PageContextData.currpage - 1;
  1761. }));
  1762. #endregion 插入页码
  1763. }
  1764. }
  1765. //OpenDialog();
  1766. return "";
  1767. }
  1768. /// <summary>
  1769. /// 导入-结束
  1770. /// </summary>
  1771. /// <returns></returns>
  1772. public void InvokeServerCompate(object obj)
  1773. {
  1774. //APP.myloading.Hide();
  1775. APP.myloading.Hide();
  1776. }
  1777. /// <summary>
  1778. /// 导入文档
  1779. /// </summary>
  1780. private void OpenDialog()
  1781. {
  1782. Dispatcher.Invoke(new Action(() =>
  1783. {
  1784. result = ofd.ShowDialog();
  1785. if (result == System.Windows.Forms.DialogResult.OK)
  1786. {
  1787. if (ofd.FileName != "")
  1788. {
  1789. APP.myloading.Show();
  1790. myblackboard.changepage(APP.PageContextData.pagenum);
  1791. #region PPT转PDF
  1792. string filepath = ofd.FileName;
  1793. string path = ofd.SafeFileName.Replace(".ppt", "").Replace(".pptx", "").Trim();
  1794. string type = ofd.SafeFileName.Replace(".ppt", "typezsygppt").Replace(".pptx", "typezsygppt").Replace(".pdf", "typepdf").Trim();
  1795. if (type.Contains("typezsygppt"))//ppt
  1796. {
  1797. try
  1798. {
  1799. string pathTemp = AppDomain.CurrentDomain.BaseDirectory + "Temp\\";
  1800. path = pathTemp + path + ".pdf";
  1801. FileToolsCommon.CreateDirectory(pathTemp);
  1802. //PPT转PDF
  1803. Presentation ppt = new Presentation(filepath);
  1804. ppt.Save(path, Aspose.Slides.Export.SaveFormat.Pdf);
  1805. #endregion PPT转PDF
  1806. #region PDF转图片
  1807. // 图片绝对路径集合
  1808. List<string> images = new List<string>();
  1809. string directoryPath = pathTemp;
  1810. //aspose许可证
  1811. //Aspose.Pdf.License l = new Aspose.Pdf.License();
  1812. //string licenseName = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Aspose.Total.Product.Family.lic");
  1813. //l.SetLicense(licenseName);
  1814. //定义Jpeg转换设备
  1815. Aspose.Pdf.Document document = new Aspose.Pdf.Document(path);
  1816. Aspose.Pdf.Devices.JpegDevice device = new Aspose.Pdf.Devices.JpegDevice();
  1817. //int quality = int.Parse(this.comboBox1.SelectedItem.ToString());
  1818. //directoryPath += quality;
  1819. Directory.CreateDirectory(directoryPath);
  1820. //默认质量为100,设置质量的好坏与处理速度不成正比,甚至是设置的质量越低反而花的时间越长,怀疑处理过程是先生成高质量的再压缩
  1821. device = new Aspose.Pdf.Devices.JpegDevice(100);
  1822. //遍历每一页转为jpg
  1823. for (int i = 1; i <= document.Pages.Count; i++)
  1824. {
  1825. long ii = Timestamp();
  1826. string filePathOutPut = Path.Combine(directoryPath, string.Format("{0}{1}.jpg", ii, i));
  1827. images.Add(filePathOutPut);
  1828. FileStream fs = new FileStream(filePathOutPut, FileMode.OpenOrCreate);
  1829. try
  1830. {
  1831. device.Process(document.Pages[i], fs);
  1832. fs.Close();
  1833. }
  1834. catch (Exception)
  1835. {
  1836. fs.Close();
  1837. File.Delete(filePathOutPut);
  1838. }
  1839. }
  1840. #endregion PDF转图片
  1841. string[] page = images.ToArray();
  1842. int num = 0;
  1843. for (int i = 0 + APP.PageContextData.pagenum; i < page.Length + APP.PageContextData.pagenum; i++)//给画板模型加图片路径
  1844. {
  1845. if (APP.PageDrawList != null && APP.PageDrawList.Count > i)
  1846. {
  1847. APP.PageDrawList[i].PageImagePath = page[i - APP.PageContextData.pagenum]; //zxycs
  1848. APP.PageDrawList[i].PdfImagePath = page[i - APP.PageContextData.pagenum];
  1849. APP.PageDrawList[i].PageNum = i + 1;
  1850. APP.PageDrawList[i].ImgDocumentation = true;
  1851. }
  1852. else
  1853. {
  1854. Model_DrawData model_DrawData = new Model_DrawData
  1855. {
  1856. PageImagePath = page[i - APP.PageContextData.pagenum],
  1857. PdfImagePath = page[i - APP.PageContextData.pagenum],
  1858. PageNum = i + 1,
  1859. ImgDocumentation = true
  1860. };
  1861. APP.PageDrawList.Add(model_DrawData);
  1862. }
  1863. BtnPrint.IsEnabled = true;
  1864. APP.SaveDraw();
  1865. num++;
  1866. }
  1867. if (num > 0)
  1868. {
  1869. APP.PageContextData.currpage = APP.PageContextData.pagenum + 1;
  1870. APP.PageContextData.pagenum += num;
  1871. GridPage.Visibility = Visibility.Visible;//页码大于0 显示
  1872. }
  1873. if (APP.PageContextData.currpage > 0 && APP.PageContextData.currpage < APP.PageDrawList.Count)
  1874. {
  1875. imgCanvas.Source = null;
  1876. BtnScreenshot.IsEnabled = false;
  1877. imgDocumentation.Source = new BitmapImage(new Uri(APP.PageDrawList[APP.PageContextData.currpage - 1].PageImagePath));//给当前页面展示图片
  1878. }
  1879. else
  1880. {
  1881. imgDocumentation.Source = null;
  1882. imgCanvas.Source = null;
  1883. ///截图可用
  1884. BtnScreenshot.IsEnabled = true;
  1885. }
  1886. APP.myloading.Hide();
  1887. }
  1888. catch (Exception ex)
  1889. {
  1890. APP.myloading.Hide();
  1891. MessageWindow.Show("无法访问文件,请检查文件是否有效或解除文件占用!");
  1892. LogHelper.WriteErrLog("【打开ppt】(OpenDialog PPT)" + ex.Message, ex);
  1893. }
  1894. }
  1895. else if (type.Contains("typepdf"))
  1896. {
  1897. string pathTemp = AppDomain.CurrentDomain.BaseDirectory + "Temp\\";
  1898. #region PDF转图片
  1899. // 图片绝对路径集合
  1900. List<string> images = new List<string>();
  1901. string directoryPath = pathTemp;
  1902. //aspose许可证
  1903. //Aspose.Pdf.License l = new Aspose.Pdf.License();
  1904. //string licenseName = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Aspose.Total.Product.Family.lic");
  1905. //l.SetLicense(licenseName);
  1906. //定义Jpeg转换设备
  1907. Aspose.Pdf.Document document = new Aspose.Pdf.Document(filepath);
  1908. Aspose.Pdf.Devices.JpegDevice device = new Aspose.Pdf.Devices.JpegDevice();
  1909. //int quality = int.Parse(this.comboBox1.SelectedItem.ToString());
  1910. //directoryPath += quality;
  1911. Directory.CreateDirectory(directoryPath);
  1912. //默认质量为100,设置质量的好坏与处理速度不成正比,甚至是设置的质量越低反而花的时间越长,怀疑处理过程是先生成高质量的再压缩
  1913. device = new Aspose.Pdf.Devices.JpegDevice(100);
  1914. //遍历每一页转为jpg
  1915. for (int i = 1; i <= document.Pages.Count; i++)
  1916. {
  1917. long ii = Timestamp();
  1918. string filePathOutPut = Path.Combine(directoryPath, string.Format("{0}{1}.jpg", ii, i));
  1919. images.Add(filePathOutPut);
  1920. FileStream fs = new FileStream(filePathOutPut, FileMode.OpenOrCreate);
  1921. try
  1922. {
  1923. device.Process(document.Pages[i], fs);
  1924. fs.Close();
  1925. }
  1926. catch (Exception)
  1927. {
  1928. fs.Close();
  1929. File.Delete(filePathOutPut);
  1930. }
  1931. }
  1932. #endregion PDF转图片
  1933. string[] page = images.ToArray();
  1934. int num = 0;
  1935. for (int i = 0 + APP.PageContextData.pagenum; i < page.Length + APP.PageContextData.pagenum; i++)//给画板模型加图片路径
  1936. {
  1937. if (APP.PageDrawList != null && APP.PageDrawList.Count > i)
  1938. {
  1939. APP.PageDrawList[i].PageImagePath = page[i - APP.PageContextData.pagenum]; //zxycs
  1940. APP.PageDrawList[i].PdfImagePath = page[i - APP.PageContextData.pagenum];
  1941. APP.PageDrawList[i].PageNum = i + 1;
  1942. APP.PageDrawList[i].ImgDocumentation = true;
  1943. }
  1944. else
  1945. {
  1946. Model_DrawData model_DrawData = new Model_DrawData
  1947. {
  1948. PageImagePath = page[i - APP.PageContextData.pagenum],
  1949. PdfImagePath = page[i - APP.PageContextData.pagenum],
  1950. PageNum = i + 1,
  1951. ImgDocumentation = true
  1952. };
  1953. APP.PageDrawList.Add(model_DrawData);
  1954. }
  1955. BtnPrint.IsEnabled = true;
  1956. APP.SaveDraw();
  1957. num++;
  1958. }
  1959. if (num > 0)
  1960. {
  1961. APP.PageContextData.currpage = APP.PageContextData.pagenum + 1;
  1962. APP.PageContextData.pagenum += num;
  1963. GridPage.Visibility = Visibility.Visible;//页码大于0 显示
  1964. }
  1965. if (APP.PageContextData.currpage > 0 && APP.PageContextData.currpage < APP.PageDrawList.Count)
  1966. {
  1967. imgCanvas.Source = null;
  1968. BtnScreenshot.IsEnabled = false;
  1969. imgDocumentation.Source = new BitmapImage(new Uri(APP.PageDrawList[APP.PageContextData.currpage - 1].PageImagePath));//给当前页面展示图片
  1970. }
  1971. else
  1972. {
  1973. imgDocumentation.Source = null;
  1974. imgCanvas.Source = null;
  1975. ///截图可用
  1976. BtnScreenshot.IsEnabled = true;
  1977. }
  1978. APP.myloading.Hide();
  1979. }
  1980. else//word
  1981. {
  1982. try
  1983. {
  1984. string paths = AppDomain.CurrentDomain.BaseDirectory + "Temp\\";
  1985. string[] page = ConvertWordToImage(filepath, paths, "", 0, 0, null, 0).ToArray();
  1986. int num = 0;
  1987. for (int i = 0 + APP.PageContextData.pagenum; i < page.Length + APP.PageContextData.pagenum; i++)//给画板模型加图片路径
  1988. {
  1989. if (APP.PageDrawList != null && APP.PageDrawList.Count > i)
  1990. {
  1991. APP.PageDrawList[i].PageImagePath = page[i - APP.PageContextData.pagenum]; //zxycs
  1992. APP.PageDrawList[i].PdfImagePath = page[i - APP.PageContextData.pagenum];
  1993. APP.PageDrawList[i].PageNum = i + 1;
  1994. APP.PageDrawList[i].ImgDocumentation = true;
  1995. }
  1996. else
  1997. {
  1998. Model_DrawData model_DrawData = new Model_DrawData
  1999. {
  2000. PageImagePath = page[i - APP.PageContextData.pagenum],
  2001. PdfImagePath = page[i - APP.PageContextData.pagenum],
  2002. PageNum = i + 1,
  2003. ImgDocumentation = true
  2004. };
  2005. APP.PageDrawList.Add(model_DrawData);
  2006. }
  2007. BtnPrint.IsEnabled = true;
  2008. APP.SaveDraw();
  2009. num++;
  2010. }
  2011. if (num > 0)
  2012. {
  2013. APP.PageContextData.currpage = APP.PageContextData.pagenum + 1;
  2014. APP.PageContextData.pagenum += num;
  2015. GridPage.Visibility = Visibility.Visible;//页码大于0 显示
  2016. }
  2017. if (APP.PageContextData.currpage > 0 && APP.PageContextData.currpage < APP.PageDrawList.Count)
  2018. {
  2019. imgCanvas.Source = null;
  2020. BtnScreenshot.IsEnabled = false;
  2021. imgDocumentation.Visibility = Visibility.Visible;
  2022. imgDocumentation.Source = new BitmapImage(new Uri(APP.PageDrawList[APP.PageContextData.currpage - 1].PageImagePath));//给当前页面展示图片
  2023. }
  2024. else
  2025. {
  2026. imgDocumentation.Source = null;
  2027. imgCanvas.Source = null;
  2028. ///截图可用
  2029. BtnScreenshot.IsEnabled = true;
  2030. }
  2031. APP.myloading.Hide();
  2032. }
  2033. catch (Exception ex)
  2034. {
  2035. APP.myloading.Hide();
  2036. LogHelper.WriteErrLog("【XHMicroLessonSystemWindow】(OpenDialog 导入文档)" + ex.Message, ex);
  2037. }
  2038. }
  2039. }
  2040. }
  2041. }
  2042. ));
  2043. }
  2044. #region 导入转换图片
  2045. /// <summary>
  2046. /// 生成图片
  2047. /// </summary>
  2048. /// <param name="_path">图片地址</param>
  2049. /// <param name="_saveimg">保存位置</param>
  2050. /// <param name="_rectangle">图片位置</param>
  2051. /// <param name="errmsg">错误消息</param>
  2052. /// <returns></returns>
  2053. private bool MergerImg(string _path, string _saveimg, RectangleF _rectangle, out string errmsg)
  2054. {
  2055. errmsg = null;
  2056. try
  2057. {
  2058. Bitmap bitmap = null;
  2059. //创建要显示的图片对象,根据参数的个数设置宽度
  2060. Bitmap backgroudImg = new Bitmap((int)GridM.ActualWidth, (int)GridM.ActualHeight);
  2061. Graphics g = Graphics.FromImage(backgroudImg);
  2062. //清除画布,背景设置为白色
  2063. g.Clear(System.Drawing.Color.White);
  2064. if (!string.IsNullOrWhiteSpace(_path))
  2065. {
  2066. bitmap = ImageHelper.ReadBitmapFile(_path);
  2067. g.DrawImage(bitmap, _rectangle);
  2068. }
  2069. backgroudImg.Save(_saveimg);
  2070. g.Dispose();
  2071. backgroudImg.Dispose();
  2072. if (bitmap != null)
  2073. {
  2074. bitmap.Dispose();
  2075. }
  2076. GC.Collect();
  2077. return true;
  2078. }
  2079. catch (Exception ex)
  2080. {
  2081. errmsg = ex.Message;
  2082. LogHelper.WriteErrLog("【截图合成】(MergerImg)图片合成失败:" + ex.Message, ex);
  2083. return false;
  2084. }
  2085. }
  2086. /// <summary>
  2087. /// 防止图片地址重复
  2088. /// </summary>
  2089. private long WordImgNum = 9999;
  2090. /// <summary>
  2091. /// 将Word文档转换为图片的方法(该方法基于第三方DLL),你可以像这样调用该方法: ConvertPDF2Image("F:\\PdfFile.doc", "F:\\",
  2092. /// "ImageFile", 1, 20, ImageFormat.Png, 256);
  2093. /// </summary>
  2094. /// <param name="pdfInputPath">Word文件路径</param>
  2095. /// <param name="imageOutputPath">图片输出路径,如果为空,默认值为Word所在路径</param>
  2096. /// <param name="imageName">图片的名字,不需要带扩展名,如果为空,默认值为Word的名称</param>
  2097. /// <param name="startPageNum">从PDF文档的第几页开始转换,如果为0,默认值为1</param>
  2098. /// <param name="endPageNum">从PDF文档的第几页开始停止转换,如果为0,默认值为Word总页数</param>
  2099. /// <param name="imageFormat">设置所需图片格式,如果为null,默认格式为PNG</param>
  2100. /// <param name="resolution">设置图片的像素,数字越大越清晰,如果为0,默认值为128,建议最大值不要超过1024</param>
  2101. public List<string> ConvertWordToImage(string wordInputPath, string imageOutputPath,
  2102. string imageName, int startPageNum, int endPageNum, ImageFormat imageFormat, float resolution)
  2103. {
  2104. // 返回的图片绝对路径集合
  2105. List<string> images = new List<string>();
  2106. try
  2107. {
  2108. // open word file
  2109. Aspose.Words.Document doc = new Aspose.Words.Document(wordInputPath);
  2110. // validate parameter
  2111. if (doc == null) { throw new Exception("Word文件无效或者Word文件被加密!"); }
  2112. if (imageOutputPath.Trim().Length == 0) { imageOutputPath = System.IO.Path.GetDirectoryName(wordInputPath); }
  2113. if (!Directory.Exists(imageOutputPath)) { Directory.CreateDirectory(imageOutputPath); }
  2114. if (imageName.Trim().Length == 0) { imageName = System.IO.Path.GetFileNameWithoutExtension(wordInputPath); }
  2115. if (startPageNum <= 0) { startPageNum = 1; }
  2116. if (endPageNum > doc.PageCount || endPageNum <= 0) { endPageNum = doc.PageCount; }
  2117. if (startPageNum > endPageNum) { int tempPageNum = startPageNum; startPageNum = endPageNum; endPageNum = startPageNum; }
  2118. if (imageFormat == null) { imageFormat = ImageFormat.Png; }
  2119. if (resolution <= 0) { resolution = 128; }
  2120. ImageSaveOptions imageSaveOptions = new ImageSaveOptions(GetSaveFormat(imageFormat))
  2121. {
  2122. Resolution = resolution
  2123. };
  2124. // start to convert each page
  2125. for (int i = startPageNum; i <= endPageNum; i++)
  2126. {
  2127. imageSaveOptions.PageIndex = i - 1;
  2128. doc.Save(System.IO.Path.Combine(imageOutputPath, imageName) + "_" + WordImgNum.ToString() + "." + imageFormat.ToString(), imageSaveOptions);
  2129. images.Add(System.IO.Path.Combine(imageOutputPath, imageName) + "_" + WordImgNum.ToString() + "." + imageFormat.ToString());
  2130. WordImgNum++;
  2131. }
  2132. imageSaveOptions = null;
  2133. doc = null;
  2134. }
  2135. catch (Exception ex)
  2136. {
  2137. //if(ex.Message.ToString().Equals("{\"The document appears to be corrupted and cannot be loaded.\"}"))
  2138. //{
  2139. // MessageWindow.Show("Word文件无效或者Word文件被加密!");
  2140. //}
  2141. //else
  2142. //{
  2143. MessageWindow.Show("该文件无法使用!");
  2144. //}
  2145. LogHelper.WriteErrLog("【导入方法(ConvertWordToImage)】错误日志:" + ex.Message, ex);
  2146. }
  2147. return images;
  2148. }
  2149. private static Aspose.Words.SaveFormat GetSaveFormat(ImageFormat imageFormat)
  2150. {
  2151. Aspose.Words.SaveFormat sf;// = SaveFormat.Unknown;
  2152. if (imageFormat.Equals(ImageFormat.Png))
  2153. {
  2154. sf = Aspose.Words.SaveFormat.Png;
  2155. }
  2156. else if (imageFormat.Equals(ImageFormat.Jpeg))
  2157. {
  2158. sf = Aspose.Words.SaveFormat.Jpeg;
  2159. }
  2160. else if (imageFormat.Equals(ImageFormat.Tiff))
  2161. {
  2162. sf = Aspose.Words.SaveFormat.Tiff;
  2163. }
  2164. else if (imageFormat.Equals(ImageFormat.Bmp))
  2165. {
  2166. sf = Aspose.Words.SaveFormat.Bmp;
  2167. }
  2168. else
  2169. {
  2170. sf = Aspose.Words.SaveFormat.Unknown;
  2171. }
  2172. return sf;
  2173. }
  2174. #endregion 导入转换图片
  2175. #endregion 导入截图
  2176. #region 上传 列表
  2177. /// <summary>
  2178. /// 上传事件
  2179. /// </summary>
  2180. /// <param name="sender"></param>
  2181. /// <param name="e"></param>
  2182. private void BtnUpload_Click(object sender, RoutedEventArgs e)
  2183. {
  2184. //if (gridUpload.Visibility == Visibility.Visible)
  2185. //{
  2186. // gridUpload.Visibility = Visibility.Collapsed;
  2187. // GridMain.Visibility = Visibility.Visible;
  2188. // //ImgRecord.Visibility = Visibility.Visible;//上传结束时可录制
  2189. // //ImgRecordTwo.Visibility = Visibility.Collapsed;//上传结束时可录制
  2190. // //BtnRecord.IsEnabled = true;//设置结束时可录制
  2191. // if (APP.pageData.pagenum > 0)
  2192. // {
  2193. // gridPage.Visibility = Visibility.Visible;
  2194. // }
  2195. // DataContext = APP.pageData;
  2196. //}
  2197. //else
  2198. //{
  2199. // gridPage.Visibility = Visibility.Collapsed;
  2200. // gridUpload.Visibility = Visibility.Visible;
  2201. // GridMain.Visibility = Visibility.Collapsed;
  2202. // //ImgRecord.Visibility = Visibility.Collapsed;//上传时不可录制
  2203. // //ImgRecordTwo.Visibility = Visibility.Visible;//上传时不可录制
  2204. // //BtnRecord.IsEnabled = false;//上传时不可录制
  2205. // InitializeUpload();
  2206. //}
  2207. if (GridMyVideo.Visibility == Visibility.Visible)
  2208. {
  2209. GridMyVideo.Visibility = Visibility.Collapsed;
  2210. GridMain.Visibility = Visibility.Visible;
  2211. GridM.IsEnabled = true;
  2212. GridRecordingTitle.Visibility = Visibility.Visible;
  2213. //if (APP.pageData.pagenum > 0)
  2214. //{
  2215. // GridPage.Visibility = Visibility.Visible;
  2216. //}
  2217. //DataContext = APP.pageData;
  2218. }
  2219. else
  2220. {
  2221. PageHide();
  2222. GridMyVideo.Visibility = Visibility.Visible;
  2223. LoadUploadInitData();
  2224. }
  2225. //btnStop.IsEnabled = true;//停止录制按钮可点击
  2226. }
  2227. /// <summary>
  2228. /// 初始化上传
  2229. /// </summary>
  2230. public void InitializeUpload()
  2231. {
  2232. APP.myloading.Show();
  2233. //MouseNumber = 0;
  2234. IsModify = false;
  2235. //加载视频列表
  2236. LoadingVideoList();
  2237. int i = 1;
  2238. bool isColour = true;
  2239. pageData.menuList.Clear();
  2240. //显示视频
  2241. foreach (Model_Video videoinfo in model_VideoList)
  2242. {
  2243. //是否已上传
  2244. //videoinfo.IsUpload;
  2245. //录制时间
  2246. //videoinfo.RSTime;
  2247. //文件大小
  2248. //videoinfo.VideoSize;
  2249. //文件缩略图路径
  2250. //videoinfo.ThumbnailPath;
  2251. //文件唯一标示 上传事件筛选需要上传的视频
  2252. //videoinfo.FileGuid;
  2253. //文件存储路径
  2254. //videoinfo.VidePath;
  2255. string colour = "#FFFFFF";
  2256. if (isColour == true)
  2257. {
  2258. colour = "#FFFFFF";
  2259. isColour = false;
  2260. }
  2261. else
  2262. {
  2263. colour = "#E6F1FF";
  2264. isColour = true;
  2265. }
  2266. string vis = "Visible";
  2267. string cos = "Collapsed";
  2268. if (!videoinfo.IsUpload)
  2269. {
  2270. vis = "Collapsed";
  2271. cos = "Visible";
  2272. }
  2273. //if(i==1)//ceshi
  2274. //{
  2275. // vis = "Visible";
  2276. // cos = "Collapsed";
  2277. //}
  2278. if (i <= 16)
  2279. {
  2280. pageData.menuList.Add(new FileDirectoryModel()
  2281. {
  2282. SerialNumber = i,
  2283. VideoName = Common.system.FileToolsCommon.GetIOFileName(videoinfo.VideoPath).Replace(".MP4", "").Replace(".FLV", "").Replace(".AVI", "").Trim(),
  2284. Name = Common.system.FileToolsCommon.GetIOFileName(videoinfo.VideoPath).Replace(".MP4", "").Replace(".FLV", "").Replace(".AVI", "").Trim(),
  2285. FilePath = videoinfo.VideoPath.Replace(FileToolsCommon.GetIOFileName(videoinfo.VideoPath), "").Trim(),
  2286. VideoDuration = 0,
  2287. VideoSize = videoinfo.VideoSize,
  2288. VideoTime = videoinfo.RSTime,
  2289. IsEnabled = false,
  2290. Path = videoinfo.VideoPath,
  2291. Colour = colour,
  2292. Visi = vis,
  2293. Coll = cos,
  2294. FileGuid = videoinfo.FileGuid,
  2295. VideoType = videoinfo.VideoType.ToString(),
  2296. VideoSizes = videoinfo.VideoSizebyte
  2297. }); ;
  2298. }
  2299. i++;
  2300. }
  2301. Currpage = 0;
  2302. PageNum = 0;
  2303. if (pageData.menuList.Count > 0)
  2304. {
  2305. Currpage = 1;
  2306. txbCurrpageTwo.Text = Currpage.ToString();
  2307. stpUp.Visibility = Visibility.Visible;
  2308. }
  2309. else
  2310. {
  2311. stpUp.Visibility = Visibility.Hidden;
  2312. }
  2313. PageNum = model_VideoList.Count;
  2314. if (PageNum > 0)
  2315. {
  2316. int t = 1;
  2317. while (PageNum > 16 * t)
  2318. {
  2319. t++;
  2320. }
  2321. PageNum = t;
  2322. }
  2323. else
  2324. {
  2325. PageNum = 0;
  2326. }
  2327. txbPageNumTwo.Text = PageNum.ToString();
  2328. APP.myloading.Hide();
  2329. DataContext = pageData;
  2330. }
  2331. /// <summary>
  2332. /// 当前页
  2333. /// </summary>
  2334. private int Currpage = 0;
  2335. /// <summary>
  2336. /// 总页码
  2337. /// </summary>
  2338. private int PageNum = 0;
  2339. /// <summary>
  2340. /// 加载视频列表
  2341. /// </summary>
  2342. public void LoadingVideoList()
  2343. {
  2344. try
  2345. {
  2346. model_VideoList = new List<Model_Video>();
  2347. foreach (Model_WKData Vdata in APP.WKDataList)
  2348. {
  2349. #region 计时器初始化
  2350. if (Vdata.VideoList == null)
  2351. {
  2352. continue;
  2353. }
  2354. foreach (Model_Video videoinfo in Vdata.VideoList)
  2355. {
  2356. try
  2357. {
  2358. if (string.IsNullOrWhiteSpace(videoinfo.VideoPath))
  2359. {
  2360. continue;
  2361. }
  2362. if (string.IsNullOrWhiteSpace(videoinfo.VideoSize) || videoinfo.VideoSize == "0 MB")
  2363. {
  2364. videoinfo.VideoSize = FileToolsCommon.GetFileSizeByMB(videoinfo.VideoPath).ToString() + " MB";
  2365. videoinfo.VideoSizebyte = FileToolsCommon.GetFileSize(videoinfo.VideoPath);
  2366. }
  2367. model_VideoList.Add(videoinfo);
  2368. }
  2369. catch (Exception ex)
  2370. {
  2371. LogHelper.WriteErrLog("【加载视频列表】(LoadingVideoList)" + ex.Message, ex);
  2372. }
  2373. }
  2374. #endregion 计时器初始化
  2375. }
  2376. //翻转
  2377. if (model_VideoList.Count > 1)
  2378. {
  2379. model_VideoList.Reverse();
  2380. }
  2381. }
  2382. catch (Exception ex)
  2383. {
  2384. LogHelper.WriteErrLog("【加载视频列表】(LoadingVideoList)" + ex.Message, ex);
  2385. }
  2386. }
  2387. ////定义事件
  2388. //public event ChangeTextHandler ChangeTextEvents;
  2389. /// <summary>
  2390. /// 上传
  2391. /// </summary>
  2392. /// <param name="sender"></param>
  2393. /// <param name="e"></param>
  2394. private void BtnUploads_Click(object sender, RoutedEventArgs e)
  2395. {
  2396. if (APP.IsLoginType == false)
  2397. {
  2398. Login();
  2399. return;
  2400. }
  2401. pageData.menuList[Subscript].IsEnabled = false;
  2402. List<System.Windows.Controls.Button> buttons = FindChilds<System.Windows.Controls.Button>(listView1, "btnUpload");
  2403. for (int i = 0; i < buttons.Count; i++)
  2404. {
  2405. if (buttons[i] == sender)
  2406. {
  2407. DAL_Upload dAL_Upload = new DAL_Upload();
  2408. if (dAL_Upload.UploadVideo(pageData.menuList[i].FileGuid, out string ErrMessage))
  2409. {
  2410. //MessageWindow.Show("视频上传服务器成功!");
  2411. if (APP.W_UploadWindow == null)
  2412. {
  2413. APP.W_UploadWindow = new UploadWindow
  2414. {
  2415. Owner = this
  2416. };
  2417. APP.W_UploadWindow.ChangeTextEvents += new ChangeTextHandlers(frm_ChangeTextEvents);
  2418. }
  2419. //long size = Convert.ToInt64(FileToolsCommon.GetFileSizeByMB(pageData.menuList[i].FilePath));
  2420. APP.W_UploadWindow.Initialize(pageData.menuList[i].VideoName, pageData.menuList[i].VideoSizes, pageData.menuList[i].VideoType, pageData.menuList[i].FileGuid, i);
  2421. APP.W_UploadWindow.ShowDialog();
  2422. }
  2423. else
  2424. {
  2425. MessageWindow.Show(ErrMessage);
  2426. }
  2427. }
  2428. }
  2429. }
  2430. /// <summary>
  2431. /// 上传返回事件
  2432. /// </summary>
  2433. /// <param name="text"></param>
  2434. private void frm_ChangeTextEvents(string text, int i)
  2435. {
  2436. if ("上传成功".Equals(text))
  2437. {
  2438. pageData.menuList[i].Visi = "Visible";
  2439. pageData.menuList[i].Coll = "Collapsed";
  2440. DataContext = pageData;
  2441. }
  2442. }
  2443. /// <summary>
  2444. /// 删除
  2445. /// </summary>
  2446. /// <param name="sender"></param>
  2447. /// <param name="e"></param>
  2448. private void BtnDelete_Click(object sender, RoutedEventArgs e)
  2449. {
  2450. MessageBoxResult dr = MessageWindow.Show("确定删除该视频?", "提示", MessageBoxButton.OKCancel);
  2451. if (dr == MessageBoxResult.OK)
  2452. {
  2453. pageData.menuList[Subscript].IsEnabled = false;
  2454. List<System.Windows.Controls.Button> buttons = FindChilds<System.Windows.Controls.Button>(listView1, "btnDelete");
  2455. for (int i = 0; i < buttons.Count; i++)
  2456. {
  2457. if (buttons[i] == sender)
  2458. {
  2459. //if (APP.W_PromptWindow == null)
  2460. //{
  2461. // APP.W_PromptWindow = new PromptWindow();
  2462. // APP.W_PromptWindow.Owner = this;
  2463. //}
  2464. //APP.W_PromptWindow.Initialize(pageData.menuList[i].VideoName);
  2465. //APP.W_PromptWindow.ShowDialog();
  2466. foreach (Model_WKData wKData in APP.WKDataList)
  2467. {
  2468. if (wKData.VideoList == null)
  2469. {
  2470. continue;
  2471. }
  2472. if (wKData.VideoList.Exists(x => x.FileGuid == pageData.menuList[i].FileGuid))
  2473. {
  2474. try
  2475. {
  2476. FileToolsCommon.DeleteFile(wKData.VideoList.Find(x => x.FileGuid == pageData.menuList[i].FileGuid).VideoPath);
  2477. FileToolsCommon.DeleteFile(wKData.VideoList.Find(x => x.FileGuid == pageData.menuList[i].FileGuid).ThumbnailPath);
  2478. wKData.VideoList.Remove(wKData.VideoList.Find(x => x.FileGuid == pageData.menuList[i].FileGuid));
  2479. InitializeUpload();
  2480. return;
  2481. }
  2482. catch (Exception ex)
  2483. {
  2484. MessageWindow.Show("无法删除视频!" + ex.Message);
  2485. return;
  2486. }
  2487. }
  2488. }
  2489. }
  2490. }
  2491. }
  2492. }
  2493. /// <summary>
  2494. /// 播放
  2495. /// </summary>
  2496. /// <param name="sender"></param>
  2497. /// <param name="e"></param>
  2498. private void BtnPlay_Click(object sender, RoutedEventArgs e)
  2499. {
  2500. pageData.menuList[Subscript].IsEnabled = false;
  2501. List<System.Windows.Controls.Button> buttons = FindChilds<System.Windows.Controls.Button>(listView1, "btnPlay");
  2502. for (int i = 0; i < buttons.Count; i++)
  2503. {
  2504. if (buttons[i] == sender)
  2505. {
  2506. try
  2507. {
  2508. ProcessStartInfo psi = new ProcessStartInfo(pageData.menuList[i].Path);
  2509. Process pro = new Process
  2510. {
  2511. StartInfo = psi
  2512. };
  2513. pro.Start();
  2514. }
  2515. catch (Exception ex)
  2516. {
  2517. LogHelper.WriteErrLog("FileDirectoryWindow【BtnPlay_Click】" + ex.Message, ex);
  2518. System.Windows.MessageBox.Show(ex.Message);
  2519. return;
  2520. }
  2521. }
  2522. }
  2523. }
  2524. /// <summary>
  2525. /// 搜索集合匹配的索引
  2526. /// </summary>
  2527. /// <typeparam name="T"></typeparam>
  2528. /// <param name="parent"></param>
  2529. /// <param name="childName"></param>
  2530. /// <returns></returns>
  2531. public static List<T> FindChilds<T>(DependencyObject parent, string childName)
  2532. where T : DependencyObject
  2533. {
  2534. List<T> list = new List<T>();
  2535. if (parent == null)
  2536. {
  2537. return list;
  2538. }
  2539. int childrenCount = VisualTreeHelper.GetChildrenCount(parent);
  2540. for (int i = 0; i < childrenCount; i++)
  2541. {
  2542. DependencyObject child = VisualTreeHelper.GetChild(parent, i);
  2543. // 如果子控件不是需查找的控件类型
  2544. T childType = child as T;
  2545. if (childType == null)
  2546. {
  2547. // 在下一级控件中递归查找
  2548. List<T> findChildList = FindChilds<T>(child, childName);
  2549. for (int j = 0; j < findChildList.Count; j++)
  2550. {
  2551. }
  2552. list.AddRange(FindChilds<T>(child, childName));
  2553. }
  2554. else if (!string.IsNullOrEmpty(childName))
  2555. {
  2556. FrameworkElement frameworkElement = child as FrameworkElement;
  2557. // 如果控件名称符合参数条件
  2558. if (frameworkElement != null && frameworkElement.Name == childName)
  2559. {
  2560. list.Add((T)child);
  2561. }
  2562. }
  2563. else
  2564. {
  2565. // 查找到了控件
  2566. list.Add((T)child);
  2567. }
  2568. }
  2569. return list;
  2570. }
  2571. /// <summary>
  2572. /// 修改
  2573. /// </summary>
  2574. /// <param name="sender"></param>
  2575. /// <param name="e"></param>
  2576. private void BtnModify_Click(object sender, RoutedEventArgs e)
  2577. {
  2578. if (IsModify)
  2579. {
  2580. try
  2581. {
  2582. string newName = pageData.menuList[Subscript].VideoName + "." + pageData.menuList[Subscript].VideoType;
  2583. bool isName = ModifyPathName(pageData.menuList[Subscript].FileGuid, newName, out string Errmessage);
  2584. if (!isName)
  2585. {
  2586. MessageWindow.Show(Errmessage);
  2587. }
  2588. }
  2589. catch (Exception ex)
  2590. {
  2591. LogHelper.WriteErrLog("XHMicroLessonSystemWindow(BtnModify_Click)" + ex.Message, ex);
  2592. }
  2593. IsModify = false;
  2594. pageData.menuList[Subscript].IsEnabled = false;
  2595. listView1.DataContext = pageData;
  2596. }
  2597. else
  2598. {
  2599. List<System.Windows.Controls.Button> buttons = FindChilds<System.Windows.Controls.Button>(listView1, "btnModify");
  2600. for (int i = 0; i < buttons.Count; i++)
  2601. {
  2602. if (buttons[i] == sender)
  2603. {
  2604. pageData.menuList[i].IsEnabled = true;
  2605. Subscript = i;
  2606. IsModify = true;
  2607. }
  2608. }
  2609. }
  2610. }
  2611. //private int MouseNumber = 0;
  2612. /// <summary>
  2613. /// 上传 上页
  2614. /// </summary>
  2615. /// <param name="sender"></param>
  2616. /// <param name="e"></param>
  2617. private void BtnLastPage_Click(object sender, RoutedEventArgs e)
  2618. {
  2619. if (Currpage > 1)
  2620. {
  2621. Currpage -= 1;
  2622. txbCurrpageTwo.Text = Currpage.ToString();
  2623. int i = 1;
  2624. bool isColour = true;
  2625. pageData.menuList.Clear();
  2626. //显示视频
  2627. foreach (Model_Video videoinfo in model_VideoList)
  2628. {
  2629. //是否已上传
  2630. //videoinfo.IsUpload;
  2631. //录制时间
  2632. //videoinfo.RSTime;
  2633. //文件大小
  2634. //videoinfo.VideoSize;
  2635. //文件缩略图路径
  2636. //videoinfo.ThumbnailPath;
  2637. //文件唯一标示 上传事件筛选需要上传的视频
  2638. //videoinfo.FileGuid;
  2639. //文件存储路径
  2640. //videoinfo.VidePath;
  2641. string colour = "#FFFFFF";
  2642. if (isColour == true)
  2643. {
  2644. colour = "#FFFFFF";
  2645. isColour = false;
  2646. }
  2647. else
  2648. {
  2649. colour = "#E6F1FF";
  2650. isColour = true;
  2651. }
  2652. string vis = "Visible";
  2653. string cos = "Collapsed";
  2654. if (!videoinfo.IsUpload)
  2655. {
  2656. vis = "Collapsed";
  2657. cos = "Visible";
  2658. }
  2659. if (i <= Currpage * 16 && i >= (Currpage - 1) * 16)
  2660. {
  2661. pageData.menuList.Add(new FileDirectoryModel()
  2662. {
  2663. SerialNumber = i,
  2664. VideoName = Common.system.FileToolsCommon.GetIOFileName(videoinfo.VideoPath).Replace(".MP4", "").Replace(".FLV", "").Replace(".AVI", "").Trim(),
  2665. Name = Common.system.FileToolsCommon.GetIOFileName(videoinfo.VideoPath).Replace(".MP4", "").Replace(".FLV", "").Replace(".AVI", "").Trim(),
  2666. FilePath = videoinfo.VideoPath.Replace(FileToolsCommon.GetIOFileName(videoinfo.VideoPath), "").Trim(),
  2667. VideoDuration = 0,
  2668. VideoSize = videoinfo.VideoSize,
  2669. VideoTime = videoinfo.RSTime,
  2670. IsEnabled = false,
  2671. Path = videoinfo.VideoPath,
  2672. Colour = colour,
  2673. Visi = vis,
  2674. Coll = cos,
  2675. FileGuid = videoinfo.FileGuid,
  2676. VideoType = videoinfo.VideoType.ToString()
  2677. }); ;
  2678. }
  2679. i++;
  2680. }
  2681. APP.myloading.Hide();
  2682. }
  2683. }
  2684. /// <summary>
  2685. /// 上传 下页
  2686. /// </summary>
  2687. /// <param name="sender"></param>
  2688. /// <param name="e"></param>
  2689. private void BtnNextPage_Click(object sender, RoutedEventArgs e)
  2690. {
  2691. if (Currpage < PageNum)
  2692. {
  2693. Currpage += 1;
  2694. txbCurrpageTwo.Text = Currpage.ToString();
  2695. int i = 1;
  2696. bool isColour = true;
  2697. pageData.menuList.Clear();
  2698. //显示视频
  2699. foreach (Model_Video videoinfo in model_VideoList)
  2700. {
  2701. //是否已上传
  2702. //videoinfo.IsUpload;
  2703. //录制时间
  2704. //videoinfo.RSTime;
  2705. //文件大小
  2706. //videoinfo.VideoSize;
  2707. //文件缩略图路径
  2708. //videoinfo.ThumbnailPath;
  2709. //文件唯一标示 上传事件筛选需要上传的视频
  2710. //videoinfo.FileGuid;
  2711. //文件存储路径
  2712. //videoinfo.VidePath;
  2713. string colour = "#FFFFFF";
  2714. if (isColour == true)
  2715. {
  2716. colour = "#FFFFFF";
  2717. isColour = false;
  2718. }
  2719. else
  2720. {
  2721. colour = "#E6F1FF";
  2722. isColour = true;
  2723. }
  2724. string vis = "Visible";
  2725. string cos = "Collapsed";
  2726. if (!videoinfo.IsUpload)
  2727. {
  2728. vis = "Collapsed";
  2729. cos = "Visible";
  2730. }
  2731. if (i <= Currpage * 16 && i > (Currpage - 1) * 16)
  2732. {
  2733. pageData.menuList.Add(new FileDirectoryModel()
  2734. {
  2735. SerialNumber = i,
  2736. VideoName = Common.system.FileToolsCommon.GetIOFileName(videoinfo.VideoPath).Replace(".MP4", "").Replace(".FLV", "").Replace(".AVI", "").Trim(),
  2737. Name = Common.system.FileToolsCommon.GetIOFileName(videoinfo.VideoPath).Replace(".MP4", "").Replace(".FLV", "").Replace(".AVI", "").Trim(),
  2738. FilePath = videoinfo.VideoPath.Replace(FileToolsCommon.GetIOFileName(videoinfo.VideoPath), "").Trim(),
  2739. VideoDuration = 0,
  2740. VideoSize = videoinfo.VideoSize,
  2741. VideoTime = videoinfo.RSTime,
  2742. IsEnabled = false,
  2743. Path = videoinfo.VideoPath,
  2744. Colour = colour,
  2745. Visi = vis,
  2746. Coll = cos,
  2747. FileGuid = videoinfo.FileGuid,
  2748. VideoType = videoinfo.VideoType.ToString()
  2749. }); ;
  2750. }
  2751. i++;
  2752. }
  2753. APP.myloading.Hide();
  2754. }
  2755. }
  2756. /// <summary>
  2757. /// 修改文件名
  2758. /// </summary>
  2759. /// <param name="Guid">唯一编号</param>
  2760. /// <param name="NewName">新文件名带后缀 不带路径</param>
  2761. /// <param name="Errmessage">错误信息</param>
  2762. /// <returns></returns>
  2763. private bool ModifyPathName(string FileGuid, string NewName, out string Errmessage)
  2764. {
  2765. Errmessage = "";
  2766. foreach (Model_WKData WKData in APP.WKDataList)
  2767. {
  2768. if (WKData.VideoList.Exists(x => x.FileGuid == FileGuid))
  2769. {
  2770. Model_Video model_Video = WKData.VideoList.Find(x => x.FileGuid == FileGuid);
  2771. string filePathName = model_Video.VideoPath;
  2772. string filePath = FileToolsCommon.GetDirectoryName(filePathName);
  2773. string newFilePathName = filePath + NewName;
  2774. //缩略图
  2775. string ThumbnailPath = filePath + "ThumbnailPath/";
  2776. FileToolsCommon.CreateDirectory(ThumbnailPath);
  2777. //缩略图存储位置
  2778. string ThumbnailPathName = ThumbnailPath + NewName.Replace(".", "") + ".JPG";
  2779. if (FileToolsCommon.IsExistFile(newFilePathName))
  2780. {
  2781. Errmessage = "文件已存在,请重新修改文件名!";
  2782. return false;
  2783. }
  2784. else
  2785. {
  2786. //修改文件名
  2787. FileToolsCommon.Copy(filePathName, newFilePathName);
  2788. model_Video.VideoPath = newFilePathName;
  2789. //修改缩略图名
  2790. FileToolsCommon.DeleteFile(ThumbnailPathName);
  2791. FileToolsCommon.Copy(model_Video.ThumbnailPath, ThumbnailPathName);
  2792. model_Video.ThumbnailPath = ThumbnailPathName;
  2793. APP.SaveWkData();
  2794. return true;
  2795. }
  2796. }
  2797. else
  2798. {
  2799. continue;
  2800. }
  2801. }
  2802. Errmessage = "视频文件有改动,当前文件不存在,请关闭后重新打开“我的”";
  2803. return false;
  2804. }
  2805. #endregion 上传 列表
  2806. #region 新上传 显示缩略图
  2807. #region 初始值
  2808. /// <summary>
  2809. /// 总页数
  2810. /// </summary>
  2811. private int TotalPage = 0;
  2812. /// <summary>
  2813. /// 当前页
  2814. /// </summary>
  2815. private int CurrentPage = 1;
  2816. /// <summary>
  2817. /// 每页显示的视频数
  2818. /// </summary>
  2819. private int PageShowNum = 0;
  2820. /// <summary>
  2821. /// 视频信息列表
  2822. /// </summary>
  2823. private List<Uc_VideoItem> VideoControlList = new List<Uc_VideoItem>();
  2824. /// <summary>
  2825. /// 横向间隔
  2826. /// </summary>
  2827. private double IntervalX = 0;
  2828. /// <summary>
  2829. /// 纵向间隔
  2830. /// </summary>
  2831. private double IntervalY = 0;
  2832. /// <summary>
  2833. /// 页面宽
  2834. /// </summary>
  2835. private double pageW;
  2836. /// <summary>
  2837. /// 页面高
  2838. /// </summary>
  2839. private double pageH;
  2840. private double ControlWidth = 250;
  2841. private double ControlHeight = 260;
  2842. #endregion 初始值
  2843. /// <summary>
  2844. /// 初始化加载上传页面数据
  2845. /// </summary>
  2846. private void LoadUploadInitData()
  2847. {
  2848. APP.myloading.Show();
  2849. //加载视频列表
  2850. LoadingVideoList();
  2851. if (model_VideoList.Count > 0)
  2852. {
  2853. lblVideoMess.Visibility = Visibility.Hidden;
  2854. BtnVideoUpPage.Visibility = Visibility.Visible;
  2855. lblVideoPageNum.Visibility = Visibility.Visible;
  2856. BtnVideoDownPage.Visibility = Visibility.Visible;
  2857. if (GridMyVideo.ActualHeight > 0)
  2858. {
  2859. pageW = GridMyVideo.ActualWidth;
  2860. pageH = GridMyVideo.ActualHeight;
  2861. }
  2862. else
  2863. {
  2864. pageW = GridRecordingArea.ActualWidth;
  2865. pageH = GridRecordingArea.ActualHeight;
  2866. }
  2867. //获取设置控件大小 新增 页面原始1061 911
  2868. double PropWid = pageW / 1061.00;
  2869. double PropHei = pageH / 911.00;
  2870. ControlWidth = 250.00 * PropWid;
  2871. ControlHeight = 260.00 * PropHei;
  2872. //ControlWidth=
  2873. //ControlHeight=
  2874. //根据页面大小获取每页显示的数量 H260W250
  2875. int videoRow = (int)((pageH - 50) / ControlHeight);
  2876. int videColumn = (int)(pageW / ControlWidth);
  2877. //横向间隔
  2878. IntervalX = (pageW - (videColumn * ControlWidth)) / (videColumn + 1);
  2879. IntervalY = (pageH - 50 - (videoRow * ControlHeight)) / (videoRow + 1);
  2880. PageShowNum = (videoRow == 0 ? 1 : videoRow) * (videColumn == 0 ? 1 : videColumn);
  2881. //获取总页数
  2882. TotalPage = model_VideoList.Count / PageShowNum + (model_VideoList.Count % PageShowNum > 0 ? 1 : 0);
  2883. //如果当前页大于总页数 总页数为当前页
  2884. if (TotalPage < CurrentPage)
  2885. {
  2886. CurrentPage = TotalPage;
  2887. }
  2888. LoadCurrentPageData();
  2889. }
  2890. else
  2891. {
  2892. lblVideoMess.Visibility = Visibility.Visible;
  2893. BtnVideoUpPage.Visibility = Visibility.Hidden;
  2894. lblVideoPageNum.Visibility = Visibility.Hidden;
  2895. BtnVideoDownPage.Visibility = Visibility.Hidden;
  2896. //隐藏显示的控件
  2897. if (VideoControlList.Count > 0)
  2898. {
  2899. foreach (Uc_VideoItem item in VideoControlList)
  2900. {
  2901. if (item.Visibility != Visibility.Hidden)
  2902. {
  2903. item.Visibility = Visibility.Hidden;
  2904. }
  2905. }
  2906. }
  2907. }
  2908. APP.myloading.Hide();
  2909. }
  2910. /// <summary>
  2911. /// 加载当前页数据
  2912. /// </summary>
  2913. private void LoadCurrentPageData()
  2914. {
  2915. lblVideoPageNum.Content = CurrentPage + "/" + TotalPage;
  2916. //隐藏显示的控件
  2917. if (VideoControlList.Count > 0)
  2918. {
  2919. foreach (Uc_VideoItem item in VideoControlList)
  2920. {
  2921. if (item.Visibility != Visibility.Hidden)
  2922. {
  2923. item.Visibility = Visibility.Hidden;
  2924. }
  2925. }
  2926. }
  2927. double W = IntervalX;//每次增加250
  2928. double H = IntervalY;//每次增加260
  2929. //加载控件
  2930. for (int i = 0; i < PageShowNum; i++)
  2931. {
  2932. int DataIndex = (CurrentPage - 1) * PageShowNum + i;
  2933. if (DataIndex == model_VideoList.Count)
  2934. {
  2935. return;
  2936. }
  2937. Uc_VideoItem videoItem;
  2938. if (VideoControlList.Exists(x => x.Tag.ToString() == model_VideoList[DataIndex].FileGuid))
  2939. {
  2940. videoItem = VideoControlList.Find(x => x.Tag.ToString() == model_VideoList[DataIndex].FileGuid);
  2941. }
  2942. else
  2943. {
  2944. if (!FileToolsCommon.IsExistFile(model_VideoList[DataIndex].ThumbnailPath))
  2945. {
  2946. continue;
  2947. }
  2948. videoItem = new Uc_VideoItem(model_VideoList[DataIndex])
  2949. {
  2950. Tag = model_VideoList[DataIndex].FileGuid
  2951. };
  2952. videoItem.Click_refreshVideoList += LoadUploadInitData;
  2953. videoItem.Click_UploadLogin += Login;
  2954. videoItem.Width = ControlWidth;
  2955. videoItem.Height = ControlHeight;
  2956. videoItem.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
  2957. videoItem.VerticalAlignment = System.Windows.VerticalAlignment.Top;
  2958. GridMyVideo.Children.Add(videoItem);
  2959. VideoControlList.Add(videoItem);
  2960. }
  2961. videoItem.Margin = new Thickness(W, H, 0, 0);
  2962. videoItem.Visibility = Visibility.Visible;
  2963. if (W + ControlWidth + ControlWidth > pageW)
  2964. {
  2965. W = IntervalX;
  2966. H += ControlHeight + IntervalY;
  2967. }
  2968. else
  2969. {
  2970. W += ControlWidth + IntervalX;
  2971. }
  2972. //Uc_VideoItem videoItem = new Uc_VideoItem();
  2973. //return;
  2974. }
  2975. }
  2976. #region 分页
  2977. /// <summary>
  2978. /// 上一页
  2979. /// </summary>
  2980. /// <param name="sender"></param>
  2981. /// <param name="e"></param>
  2982. private void BtnVideoUpPage_Click(object sender, RoutedEventArgs e)
  2983. {
  2984. if (CurrentPage > 1)
  2985. {
  2986. CurrentPage--;
  2987. LoadCurrentPageData();
  2988. }
  2989. }
  2990. /// <summary>
  2991. /// 下一页
  2992. /// </summary>
  2993. /// <param name="sender"></param>
  2994. /// <param name="e"></param>
  2995. private void BtnVideoDownPage_Click(object sender, RoutedEventArgs e)
  2996. {
  2997. if (CurrentPage < TotalPage)
  2998. {
  2999. CurrentPage++;
  3000. LoadCurrentPageData();
  3001. }
  3002. }
  3003. #endregion 分页
  3004. #endregion 新上传 显示缩略图
  3005. #region 录制窗口
  3006. #region 变量
  3007. /// <summary>
  3008. /// 视频保存路径
  3009. /// </summary>
  3010. //string RecordingPath;
  3011. /// <summary>
  3012. /// 图片保存路径
  3013. /// </summary>
  3014. private string ImgPath;
  3015. /// <summary>
  3016. /// 音频保存路径名
  3017. /// </summary>
  3018. private string AudioPathName;
  3019. /// <summary>
  3020. /// 视频保存路径名
  3021. /// </summary>
  3022. private string VideoSavePathName;
  3023. /// <summary>
  3024. /// 视频合成路径名
  3025. /// </summary>
  3026. private string VideoSynthesisPathName;
  3027. ///// <summary>
  3028. ///// 暂停录制
  3029. ///// </summary>
  3030. //private bool IsSuspendR = true;
  3031. /// <summary>
  3032. /// 录制是否已停止
  3033. /// </summary>
  3034. private bool IsFirstR = true;
  3035. /// <summary>
  3036. /// 图片
  3037. /// </summary>
  3038. private List<string> RsImgName = null;
  3039. /// <summary>
  3040. /// 是否开始截图计数
  3041. /// </summary>
  3042. private bool IsStartCount = false;
  3043. /// <summary>
  3044. /// 是否录制了音频
  3045. /// </summary>
  3046. private bool IsRecordAudio = false;
  3047. /// <summary>
  3048. /// 截图定时器
  3049. /// </summary>
  3050. private System.Threading.Timer timer;
  3051. /// <summary>
  3052. /// 录制计时
  3053. /// </summary>
  3054. private DateTime SRTime = DateTime.Now;
  3055. /// <summary>
  3056. /// 录制大小
  3057. /// </summary>
  3058. private int gridActWidth = 1276;
  3059. /// <summary>
  3060. /// 录制大小
  3061. /// </summary>
  3062. private int gridActHeight = 898;
  3063. /// <summary>
  3064. /// 录制类型 0停止中,1录制中,2暂停中
  3065. /// </summary>
  3066. private int RecordType = 0;
  3067. #endregion 变量
  3068. #region 录屏
  3069. /// <summary>
  3070. /// 录屏事件
  3071. /// </summary>
  3072. /// <param name="sender"></param>
  3073. /// <param name="e"></param>
  3074. private void BtnScreenRecording_Click(object sender, RoutedEventArgs e)
  3075. {
  3076. Record();
  3077. if (!APP.CheckScreenCapturerRecorder())
  3078. {
  3079. MessageWindow.Show("使用此功能需安装环境,请在确定后依次点击“OK-Next>-Next>Install”完成安装!");
  3080. APP.InstallScreenCapturerRecorder();
  3081. return;
  3082. }
  3083. #region 限制只允许录制一个录屏 废弃
  3084. //string RecordScreenPathName = APP.WKData.WkPath + APP.WKData.WkName + "_录屏." + ((Enum_VideoType)int.Parse(FileToolsCommon.GetConfigValue("VideoType"))).ToString();
  3085. //if (FileToolsCommon.IsExistFile(RecordScreenPathName))
  3086. //{
  3087. // MessageBoxResult dr = MessageWindow.Show("已存在录屏,是否覆盖?", "提示", MessageBoxButton.OKCancel);
  3088. // if (dr == MessageBoxResult.OK)
  3089. // {
  3090. // try
  3091. // {
  3092. // FileToolsCommon.DeleteFile(RecordScreenPathName);
  3093. // APP.VideoList.RemoveAll(x => x.VideoPath == RecordScreenPathName);
  3094. // }
  3095. // catch (Exception ex)
  3096. // {
  3097. // LogHelper.WriteErrLog("【录屏】(BtnRecordingScreen_Click)无法移除视频," + ex.Message, ex);
  3098. // }
  3099. // }
  3100. // else
  3101. // {
  3102. // return;
  3103. // }
  3104. //}
  3105. #endregion 限制只允许录制一个录屏 废弃
  3106. k_hook.Stop();
  3107. if (APP.W_ScreenRecordingToolbarWindow == null)
  3108. {
  3109. APP.W_ScreenRecordingToolbarWindow = new ScreenRecordingToolbarWindow
  3110. {
  3111. Topmost = true
  3112. };
  3113. APP.W_ScreenRecordingToolbarWindow.Initialize();
  3114. }
  3115. else
  3116. {
  3117. APP.W_ScreenRecordingToolbarWindow.Initialize();
  3118. }
  3119. APP.W_ScreenRecordingToolbarWindow.Click_stopRecordingScreen += W_ScreenRecordingToolbarWindow_Click_stopRecordingScreen;
  3120. //显示在右下角
  3121. APP.W_ScreenRecordingToolbarWindow.WindowStartupLocation = WindowStartupLocation.Manual;
  3122. Graphics graphics = Graphics.FromHwnd(IntPtr.Zero);
  3123. float DIP = graphics.DpiX;
  3124. float DIPY = graphics.DpiY;
  3125. APP.W_ScreenRecordingToolbarWindow.Left = PrimaryScreen.WorkingArea.Width / (DIP / 96) - APP.W_ScreenRecordingToolbarWindow.Width;
  3126. APP.W_ScreenRecordingToolbarWindow.Top = PrimaryScreen.WorkingArea.Height / (DIP / 96) - APP.W_ScreenRecordingToolbarWindow.Height - 100;
  3127. APP.W_ScreenRecordingToolbarWindow.Topmost = true;
  3128. APP.W_ScreenRecordingToolbarWindow.Show();
  3129. Hide();
  3130. }
  3131. /// <summary>
  3132. /// 保存录屏中
  3133. /// </summary>
  3134. private void W_ScreenRecordingToolbarWindow_Click_stopRecordingScreen()
  3135. {
  3136. TxbTime.Text = "00:00";
  3137. //TxbTime.Visibility = Visibility.Hidden;
  3138. //ImgLZImg.Visibility = Visibility.Hidden;
  3139. //TxbType.Visibility = Visibility.Visible;
  3140. TxbType.Text = "保存中";
  3141. BtnScreenRecording.IsEnabled = false;
  3142. new Thread(new ThreadStart(new Action(() =>
  3143. {
  3144. while (FileToolsCommon.IsExistDirectory(APP.WKData.WkPath + "temprs/"))
  3145. {
  3146. Thread.Sleep(100);
  3147. }
  3148. Thread.Sleep(100);
  3149. Dispatcher.Invoke(() =>
  3150. {
  3151. BtnScreenRecording.IsEnabled = true;
  3152. TxbType.Text = "准备就绪";
  3153. //TxbType.Visibility = Visibility.Hidden;
  3154. //TxbRecordScreenWord.Text = "录屏";
  3155. });
  3156. }))).Start();
  3157. }
  3158. #endregion 录屏
  3159. private bool IsPressButton = false;
  3160. /// <summary>
  3161. /// 录制窗口内容
  3162. /// </summary>
  3163. /// <param name="sender"></param>
  3164. /// <param name="e"></param>
  3165. private void BtnRecord_Click(object sender, RoutedEventArgs e)
  3166. {
  3167. #region 防止连击
  3168. if (IsPressButton)
  3169. {
  3170. return;
  3171. }
  3172. else
  3173. {
  3174. IsPressButton = true;
  3175. new Thread(new ThreadStart(new Action(() =>
  3176. {
  3177. Thread.Sleep(500);
  3178. IsPressButton = false;
  3179. }))).Start();
  3180. }
  3181. #endregion 防止连击
  3182. Record();
  3183. if (!APP.CheckScreenCapturerRecorder())
  3184. {
  3185. MessageWindow.Show("使用此功能需安装环境,请在确定后依次点击“OK-Next>-Next>Install”完成安装!");
  3186. APP.InstallScreenCapturerRecorder();
  3187. return;
  3188. }
  3189. if (APP.PageContextData.currpage > 0)
  3190. {
  3191. blackboard_canvas.Visibility = Visibility.Visible;
  3192. }
  3193. else
  3194. {
  3195. MessageWindow.Show("请先导入文档或截图!");
  3196. return;
  3197. }
  3198. if (RectImgBorder.Visibility != Visibility.Hidden)
  3199. {
  3200. HideAngleBorder();
  3201. }
  3202. //btnStop.IsEnabled = true;//停止录制按钮可点击
  3203. if (RecordType == 0)
  3204. {
  3205. //停止中开始录制
  3206. RecordType = 1;
  3207. #region 检测麦克风扬声器是否可用
  3208. string AudioPath = FileToolsCommon.GetFileAbsolutePath("/temp/audio/");
  3209. FileToolsCommon.CreateDirectory(AudioPath);
  3210. string audioSpeakerPath = AudioPath + "adoS" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".m";
  3211. string audioMicrophonePath = AudioPath + "adoM" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".m";
  3212. try
  3213. {
  3214. FileToolsCommon.DeleteFile(audioSpeakerPath);
  3215. FileToolsCommon.DeleteFile(audioMicrophonePath);
  3216. }
  3217. catch (Exception)
  3218. {
  3219. }
  3220. //扬声器
  3221. if (APP.FFmpeg.StartRecordSpeakerAudio(audioSpeakerPath))
  3222. {
  3223. APP.FFmpeg.StopRecordAudio(2);
  3224. //Thread.Sleep(500);
  3225. //麦克风
  3226. if (APP.FFmpeg.StartRecordAudio(audioMicrophonePath))
  3227. {
  3228. }
  3229. else
  3230. {
  3231. //无法录制麦克风
  3232. MessageBoxResult Res = MessageWindow.Show("当前电脑无法录制麦克风,是否继续?", "消息提示", MessageBoxButton.OKCancel);
  3233. if (Res == MessageBoxResult.Cancel)
  3234. {
  3235. return;
  3236. }
  3237. }
  3238. APP.FFmpeg.StopRecordAudio(1);
  3239. }
  3240. else
  3241. {
  3242. //无法录制扬声器音频
  3243. MessageBoxResult Res = MessageWindow.Show("当前电脑无法录制音频,是否继续?", "消息提示", MessageBoxButton.OKCancel);
  3244. if (Res == MessageBoxResult.Cancel)
  3245. {
  3246. return;
  3247. }
  3248. }
  3249. #endregion 检测麦克风扬声器是否可用
  3250. }
  3251. else if (RecordType == 1)
  3252. {
  3253. //录制中暂停
  3254. RecordType = 2;
  3255. }
  3256. else if (RecordType == 2)
  3257. {
  3258. //暂停中继续录制
  3259. RecordType = 1;
  3260. }
  3261. new Thread(new ThreadStart(new Action(() =>
  3262. {
  3263. StartRecord(RecordType);
  3264. }))).Start();
  3265. }
  3266. /// <summary>
  3267. /// 停止录制窗口内容
  3268. /// </summary>
  3269. /// <param name="sender"></param>
  3270. /// <param name="e"></param>
  3271. private void BtnStop_Click(object sender, RoutedEventArgs e)
  3272. {
  3273. #region 防止连击
  3274. if (IsPressButton)
  3275. {
  3276. return;
  3277. }
  3278. else
  3279. {
  3280. IsPressButton = true;
  3281. new Thread(new ThreadStart(new Action(() =>
  3282. {
  3283. Thread.Sleep(500);
  3284. IsPressButton = false;
  3285. }))).Start();
  3286. }
  3287. #endregion 防止连击
  3288. if (RecordType != 0)
  3289. {
  3290. RecordType = 0;
  3291. blackboard_canvas.Visibility = Visibility.Collapsed;
  3292. new Thread(new ThreadStart(new Action(() =>
  3293. {
  3294. EndRecord();
  3295. }))).Start();
  3296. //鼠标模式
  3297. deviceMouse();
  3298. }
  3299. }
  3300. /// <summary>
  3301. /// 设置录屏文件地址
  3302. /// </summary>
  3303. private void SetUpVideoPathName()
  3304. {
  3305. }
  3306. /// <summary>
  3307. /// 开始录制和暂停录制
  3308. /// </summary>
  3309. private void StartRecord(int Type)
  3310. {
  3311. if (Type == 1)
  3312. {
  3313. if (IsFirstR)//是否第一次录制 初始化录制
  3314. {
  3315. //电子版切换笔模式
  3316. deviceHand();
  3317. VideoInfo = new Model_Video
  3318. {
  3319. VideoType = (Enum_VideoType)int.Parse(FileToolsCommon.GetConfigValue("VideoType")),
  3320. WkType = Enum_WKVidetype.RecordingLessons
  3321. };
  3322. ImgPath = APP.WKData.WkPath + "temp/Image/";
  3323. AudioPathName = APP.WKData.WkPath + "temp/audio/";
  3324. FileToolsCommon.DeleteDirectory(APP.WKData.WkPath + "temp/");
  3325. FileToolsCommon.CreateDirectory(APP.WKData.WkPath);
  3326. FileToolsCommon.CreateDirectory(ImgPath);
  3327. FileToolsCommon.CreateDirectory(AudioPathName);
  3328. AudioPathName += APP.WKData.WkName + ".MP3";
  3329. VideoSavePathName = APP.WKData.WkPath + APP.WKData.WkName + "_录制." + VideoInfo.VideoType.ToString();
  3330. VideoSynthesisPathName = APP.WKData.WkPath + APP.WKData.WkName + "_录制Syn." + VideoInfo.VideoType.ToString();
  3331. int num = 1;
  3332. while (FileToolsCommon.IsExistFile(VideoSavePathName))
  3333. {
  3334. VideoSavePathName = APP.WKData.WkPath + APP.WKData.WkName + "_录制_" + num + "." + VideoInfo.VideoType.ToString();
  3335. VideoSynthesisPathName = APP.WKData.WkPath + APP.WKData.WkName + "_录制Syn_" + num + "." + VideoInfo.VideoType.ToString();
  3336. num++;
  3337. }
  3338. #region 禁用按钮
  3339. Dispatcher.Invoke(() =>
  3340. {
  3341. //TxbTime.Visibility = Visibility.Visible;
  3342. //ImgLZImg.Visibility = Visibility.Visible;
  3343. BtnPrint.IsEnabled = false;
  3344. BtnScreenshot.IsEnabled = false;
  3345. BtnImport.IsEnabled = false;
  3346. BtnScreenRecording.IsEnabled = false;
  3347. BtnUpload.IsEnabled = false;
  3348. BtnSetUp.IsEnabled = false;
  3349. BtnDevice.IsEnabled = false;
  3350. BtnLoginType.IsEnabled = false;
  3351. blackboard_canvas.Visibility = Visibility.Visible;//zxyceshi
  3352. });
  3353. #endregion 禁用按钮
  3354. #region 设置录制大小
  3355. gridActWidth = (int)(GridMain.ActualWidth * (PrimaryScreen.DpiX / 96f));
  3356. gridActHeight = (int)(GridMain.ActualHeight * (PrimaryScreen.DpiY / 96f));
  3357. gridActWidth = gridActWidth % 2 > 0 ? gridActWidth - 1 : gridActWidth;
  3358. gridActHeight = gridActHeight % 2 > 0 ? gridActHeight - 1 : gridActHeight;
  3359. #endregion 设置录制大小
  3360. #region 录像倒计时
  3361. Dispatcher.Invoke(() =>
  3362. {
  3363. if (APP.W_CountdownWindow == null)
  3364. {
  3365. APP.W_CountdownWindow = new CountdownWindow();
  3366. APP.W_CountdownWindow.Initialize();
  3367. //APP.W_CountdownWindow.Topmost = true;
  3368. }
  3369. else
  3370. {
  3371. APP.W_CountdownWindow.Initialize();
  3372. //APP.W_CountdownWindow.Topmost = true;
  3373. }
  3374. APP.W_CountdownWindow.Show();
  3375. });
  3376. #endregion 录像倒计时
  3377. IsFirstR = false;
  3378. RsImgName = new List<string>();
  3379. SRTime = Convert.ToDateTime("2020-01-01 00:00:00");
  3380. ///启动截图
  3381. timer = new System.Threading.Timer(new TimerCallback(Timer_Elapsed), null, 0, 20);
  3382. }
  3383. //继续录制
  3384. //IsSuspendR = false;
  3385. //BtnRecording.Content = "暂停录制";
  3386. Dispatcher.Invoke(() =>
  3387. {
  3388. TxbType.Text = "准备录制";
  3389. BtnRecord.Visibility = Visibility.Collapsed;
  3390. BtnRecordSuspend.Visibility = Visibility.Visible;
  3391. BtnRecord.IsEnabled = true;
  3392. BtnStop.IsEnabled = true;
  3393. });
  3394. try
  3395. {
  3396. Thread.Sleep(1000);
  3397. bool IsRecordingSound = FileToolsCommon.GetConfigValue("IsRecordingSound") == "1";
  3398. bool IsRecordingMicrophone = FileToolsCommon.GetConfigValue("IsRecordingMicrophone") == "1";
  3399. IsRecordAudio = APP.FFmpeg.StartRecordingAudio(AudioPathName, out string ErrMessage, IsRecordingSound, IsRecordingMicrophone, APP.MicrophoneName);
  3400. Thread.Sleep(1000);
  3401. Dispatcher.Invoke(() =>
  3402. {
  3403. TxbType.Text = "正在录制";
  3404. if (!IsRecordAudio)
  3405. {
  3406. MessageWindow.Show(ErrMessage);
  3407. }
  3408. Recorddt = DateTime.Now;
  3409. IsStartCount = true;
  3410. //Stack();
  3411. //timer.Start();
  3412. });
  3413. }
  3414. catch (Exception ex)
  3415. {
  3416. MessageWindow.Show(ex.Message);
  3417. }
  3418. }
  3419. else if (Type == 2)
  3420. {
  3421. //暂停
  3422. //IsSuspendR = true;
  3423. Dispatcher.Invoke(() =>
  3424. {
  3425. TxbType.Text = "暂停中";
  3426. BtnRecord.Visibility = Visibility.Visible;
  3427. BtnRecordSuspend.Visibility = Visibility.Collapsed;
  3428. });
  3429. //TimeOut();
  3430. #region 2秒内不可点击
  3431. //new Thread(new ThreadStart(new Action(() =>
  3432. //{
  3433. Dispatcher.Invoke(() =>
  3434. {
  3435. BtnRecord.IsEnabled = false;
  3436. BtnStop.IsEnabled = false;
  3437. });
  3438. Thread.Sleep(2000);
  3439. Dispatcher.Invoke(() =>
  3440. {
  3441. BtnRecord.IsEnabled = true;
  3442. BtnStop.IsEnabled = true;
  3443. });
  3444. //}))).Start();
  3445. #endregion 2秒内不可点击
  3446. try
  3447. {
  3448. APP.FFmpeg.SuspendFFmpeg();
  3449. //new Thread(new ThreadStart(new Action(() =>
  3450. //{
  3451. while (APP.FFmpeg.myProcess != null)
  3452. {
  3453. Thread.Sleep(100);
  3454. }
  3455. IsStartCount = false;
  3456. //}))).Start();
  3457. }
  3458. catch (Exception ex)
  3459. {
  3460. Dispatcher.Invoke(() =>
  3461. {
  3462. MessageWindow.Show(ex.Message);
  3463. });
  3464. }
  3465. }
  3466. }
  3467. /// <summary>
  3468. /// 开始录制和暂停录制
  3469. /// </summary>
  3470. private void StartRecordOld(int Type)
  3471. {
  3472. if (Type == 1)
  3473. {
  3474. if (IsFirstR)//是否第一次录制 初始化录制
  3475. {
  3476. #region 检测麦克风扬声器是否可用
  3477. string AudioPath = FileToolsCommon.GetFileAbsolutePath("/temp/audio/");
  3478. FileToolsCommon.CreateDirectory(AudioPath);
  3479. string audioSpeakerPath = AudioPath + "adoS" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".m";
  3480. string audioMicrophonePath = AudioPath + "adoM" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".m";
  3481. try
  3482. {
  3483. FileToolsCommon.DeleteFile(audioSpeakerPath);
  3484. FileToolsCommon.DeleteFile(audioMicrophonePath);
  3485. }
  3486. catch (Exception)
  3487. {
  3488. }
  3489. //扬声器
  3490. if (APP.FFmpeg.StartRecordSpeakerAudio(audioSpeakerPath))
  3491. {
  3492. APP.FFmpeg.StopRecordAudio(2);
  3493. //Thread.Sleep(500);
  3494. //麦克风
  3495. if (APP.FFmpeg.StartRecordAudio(audioMicrophonePath))
  3496. {
  3497. }
  3498. else
  3499. {
  3500. //无法录制麦克风
  3501. MessageBoxResult Res = MessageWindow.Show("当前电脑无法录制麦克风,是否继续?", "消息提示", MessageBoxButton.OKCancel);
  3502. if (Res == MessageBoxResult.Cancel)
  3503. {
  3504. return;
  3505. }
  3506. }
  3507. APP.FFmpeg.StopRecordAudio(1);
  3508. }
  3509. else
  3510. {
  3511. //无法录制扬声器音频
  3512. MessageBoxResult Res = MessageWindow.Show("当前电脑无法录制音频,是否继续?", "消息提示", MessageBoxButton.OKCancel);
  3513. if (Res == MessageBoxResult.Cancel)
  3514. {
  3515. return;
  3516. }
  3517. }
  3518. #endregion 检测麦克风扬声器是否可用
  3519. //电子版切换笔模式
  3520. deviceHand();
  3521. //TxbTime.Visibility = Visibility.Visible;
  3522. //ImgLZImg.Visibility = Visibility.Visible;
  3523. VideoInfo = new Model_Video
  3524. {
  3525. VideoType = (Enum_VideoType)int.Parse(FileToolsCommon.GetConfigValue("VideoType")),
  3526. WkType = Enum_WKVidetype.RecordingLessons
  3527. };
  3528. ImgPath = APP.WKData.WkPath + "temp/Image/";
  3529. AudioPathName = APP.WKData.WkPath + "temp/audio/";
  3530. FileToolsCommon.DeleteDirectory(APP.WKData.WkPath + "temp/");
  3531. FileToolsCommon.CreateDirectory(APP.WKData.WkPath);
  3532. FileToolsCommon.CreateDirectory(ImgPath);
  3533. FileToolsCommon.CreateDirectory(AudioPathName);
  3534. AudioPathName += APP.WKData.WkName + ".MP3";
  3535. VideoSavePathName = APP.WKData.WkPath + APP.WKData.WkName + "_录制." + VideoInfo.VideoType.ToString();
  3536. VideoSynthesisPathName = APP.WKData.WkPath + APP.WKData.WkName + "_录制Syn." + VideoInfo.VideoType.ToString();
  3537. int num = 1;
  3538. while (FileToolsCommon.IsExistFile(VideoSavePathName))
  3539. {
  3540. VideoSavePathName = APP.WKData.WkPath + APP.WKData.WkName + "_录制_" + num + "." + VideoInfo.VideoType.ToString();
  3541. VideoSynthesisPathName = APP.WKData.WkPath + APP.WKData.WkName + "_录制Syn_" + num + "." + VideoInfo.VideoType.ToString();
  3542. num++;
  3543. }
  3544. #region 设置录屏唯一 废弃
  3545. //if (FileToolsCommon.IsExistFile(VideoSavePathName))
  3546. //{
  3547. // MessageBoxResult dr = MessageWindow.Show("课程已录制,是否覆盖?", "提示", MessageBoxButton.OKCancel);
  3548. // if (dr == MessageBoxResult.OK)
  3549. // {
  3550. // try
  3551. // {
  3552. // FileToolsCommon.DeleteFile(VideoSavePathName);
  3553. // APP.VideoList.RemoveAll(x => x.VideoPath == VideoSavePathName);
  3554. // }
  3555. // catch (Exception ex)
  3556. // {
  3557. // LogHelper.WriteErrLog("【录制】(StartRecord)无法移除视频," + ex.Message, ex);
  3558. // }
  3559. // }
  3560. // else
  3561. // {
  3562. // return;
  3563. // }
  3564. //}
  3565. #endregion 设置录屏唯一 废弃
  3566. #region 禁用按钮
  3567. BtnPrint.IsEnabled = false;
  3568. BtnScreenshot.IsEnabled = false;
  3569. BtnImport.IsEnabled = false;
  3570. BtnScreenRecording.IsEnabled = false;
  3571. BtnUpload.IsEnabled = false;
  3572. BtnSetUp.IsEnabled = false;
  3573. BtnDevice.IsEnabled = false;
  3574. BtnLoginType.IsEnabled = false;
  3575. blackboard_canvas.Visibility = Visibility.Visible;//zxyceshi
  3576. //myblackboard = new BlackboardNew(blackboard_canvas);
  3577. //DataContext = APP.pageData;
  3578. //drawingAttributes = new DrawingAttributes();
  3579. ////将 InkCanvas 的 DefaultDrawingAttributes 属性的值赋成创建的 DrawingAttributes 类的对象的引用
  3580. ////InkCanvas 通过 DefaultDrawingAttributes 属性来获取墨迹的各种设置,该属性的类型为 DrawingAttributes 型
  3581. //blackboard_canvas.DefaultDrawingAttributes = drawingAttributes;
  3582. //blackboard_canvas.UseCustomCursor = true;
  3583. //drawingAttributes.FitToCurve = true;
  3584. //drawingAttributes.IgnorePressure = false;
  3585. //drawingAttributes.Width = PenSize;
  3586. //drawingAttributes.Height = PenSize;
  3587. //drawingAttributes.Color = Color;
  3588. //blackboard_canvas.Cursor = System.Windows.Input.Cursors.Pen;
  3589. #endregion 禁用按钮
  3590. #region 设置录制大小
  3591. //gridActWidth = (int)GridMain.ActualWidth==0?1276: (int)GridMain.ActualWidth;
  3592. //gridActHeight = (int)GridMain.ActualHeight==0?898: (int)GridMain.ActualHeight;
  3593. gridActWidth = (int)(GridMain.ActualWidth * (PrimaryScreen.DpiX / 96f));
  3594. gridActHeight = (int)(GridMain.ActualHeight * (PrimaryScreen.DpiY / 96f));
  3595. gridActWidth = gridActWidth % 2 > 0 ? gridActWidth - 1 : gridActWidth;
  3596. gridActHeight = gridActHeight % 2 > 0 ? gridActHeight - 1 : gridActHeight;
  3597. #endregion 设置录制大小
  3598. #region 录像倒计时
  3599. if (APP.W_CountdownWindow == null)
  3600. {
  3601. APP.W_CountdownWindow = new CountdownWindow();
  3602. APP.W_CountdownWindow.Initialize();
  3603. //APP.W_CountdownWindow.Topmost = true;
  3604. }
  3605. else
  3606. {
  3607. APP.W_CountdownWindow.Initialize();
  3608. //APP.W_CountdownWindow.Topmost = true;
  3609. }
  3610. APP.W_CountdownWindow.Show();
  3611. #endregion 录像倒计时
  3612. IsFirstR = false;
  3613. RsImgName = new List<string>();
  3614. SRTime = Convert.ToDateTime("2020-01-01 00:00:00");
  3615. //TxbTime.Visibility = Visibility.Visible;
  3616. //ImgLZImg.Visibility = Visibility.Visible;
  3617. ///启动截图
  3618. timer = new System.Threading.Timer(new TimerCallback(Timer_Elapsed), null, 0, 20);
  3619. //{
  3620. // AutoReset = true//设置是否执行System.Timers.Timer.Elapsed事件
  3621. //};//设置执行一次(false)还是一直执行(true)
  3622. //timer.Elapsed += new System.Timers.ElapsedEventHandler(Timer_Elapsed);
  3623. //timer.Enabled = true; //启动计时器
  3624. }
  3625. //继续录制
  3626. //IsSuspendR = false;
  3627. //BtnRecording.Content = "暂停录制";
  3628. TxbType.Text = "准备录制";
  3629. BtnRecord.Visibility = Visibility.Collapsed;
  3630. BtnRecordSuspend.Visibility = Visibility.Visible;
  3631. #region 4秒内不可点击
  3632. //new Thread(new ThreadStart(new Action(() =>
  3633. //{
  3634. // Dispatcher.Invoke(() =>
  3635. // {
  3636. // BtnRecord.IsEnabled = false;
  3637. // btnStop.IsEnabled = false;
  3638. // ImgStop.Visibility = Visibility.Visible;
  3639. // ImgStopTwo.Visibility = Visibility.Collapsed;
  3640. // });
  3641. //}))).Start();
  3642. new Thread(new ThreadStart(new Action(() =>
  3643. {
  3644. //Thread.Sleep(4000);
  3645. Dispatcher.Invoke(() =>
  3646. {
  3647. BtnRecord.IsEnabled = true;
  3648. BtnStop.IsEnabled = true;
  3649. });
  3650. }))).Start();
  3651. #endregion 4秒内不可点击
  3652. try
  3653. {
  3654. new Thread(new ThreadStart(new Action(() =>
  3655. {
  3656. Thread.Sleep(1000);
  3657. bool IsRecordingSound = FileToolsCommon.GetConfigValue("IsRecordingSound") == "1";
  3658. bool IsRecordingMicrophone = FileToolsCommon.GetConfigValue("IsRecordingMicrophone") == "1";
  3659. IsRecordAudio = APP.FFmpeg.StartRecordingAudio(AudioPathName, out string ErrMessage, IsRecordingSound, IsRecordingMicrophone, APP.MicrophoneName);
  3660. Thread.Sleep(1000);
  3661. Dispatcher.Invoke(() =>
  3662. {
  3663. TxbType.Text = "正在录制";
  3664. if (!IsRecordAudio)
  3665. {
  3666. MessageWindow.Show(ErrMessage);
  3667. }
  3668. Recorddt = DateTime.Now;
  3669. IsStartCount = true;
  3670. //Stack();
  3671. //timer.Start();
  3672. });
  3673. }))).Start();
  3674. }
  3675. catch (Exception ex)
  3676. {
  3677. MessageWindow.Show(ex.Message);
  3678. }
  3679. }
  3680. else if (Type == 2)
  3681. {
  3682. //暂停
  3683. //IsSuspendR = true;
  3684. TxbType.Text = "暂停中";
  3685. BtnRecord.Visibility = Visibility.Visible;
  3686. BtnRecordSuspend.Visibility = Visibility.Collapsed;
  3687. //TimeOut();
  3688. #region 2秒内不可点击
  3689. new Thread(new ThreadStart(new Action(() =>
  3690. {
  3691. Dispatcher.Invoke(() =>
  3692. {
  3693. BtnRecord.IsEnabled = false;
  3694. BtnStop.IsEnabled = false;
  3695. });
  3696. Thread.Sleep(2000);
  3697. Dispatcher.Invoke(() =>
  3698. {
  3699. BtnRecord.IsEnabled = true;
  3700. BtnStop.IsEnabled = true;
  3701. });
  3702. }))).Start();
  3703. #endregion 2秒内不可点击
  3704. try
  3705. {
  3706. APP.FFmpeg.SuspendFFmpeg();
  3707. new Thread(new ThreadStart(new Action(() =>
  3708. {
  3709. while (APP.FFmpeg.myProcess != null)
  3710. {
  3711. Thread.Sleep(100);
  3712. }
  3713. IsStartCount = false;
  3714. }))).Start();
  3715. }
  3716. catch (Exception ex)
  3717. {
  3718. MessageWindow.Show(ex.Message);
  3719. }
  3720. }
  3721. }
  3722. /// <summary>
  3723. /// 记录上次截图时间
  3724. /// </summary>
  3725. private DateTime Recorddt = DateTime.Now;
  3726. /// <summary>
  3727. /// 录制保存图片计时器
  3728. /// </summary>
  3729. /// <param name="sender"></param>
  3730. private void Timer_Elapsed(object sender)
  3731. {
  3732. if (IsStartCount)
  3733. {
  3734. DateTime dt = DateTime.Now;
  3735. TimeSpan ts = dt.Subtract(Recorddt);//时间差
  3736. double tsmi = ts.TotalMilliseconds;
  3737. if (tsmi > 200.0)
  3738. {
  3739. Recorddt = Recorddt.AddMilliseconds(200);
  3740. Thread thread = new Thread(RecordSaveImage);
  3741. //开启线程
  3742. thread.Start();
  3743. }
  3744. }
  3745. }
  3746. /// <summary>
  3747. /// 录制保存图片
  3748. /// </summary>
  3749. private void RecordSaveImage()
  3750. {
  3751. try
  3752. {
  3753. if (IsStartCount)
  3754. {
  3755. string FilePathName = ImgPath + RsImgName.Count + ".png";
  3756. RsImgName.Add(FilePathName);
  3757. #region 设置大小
  3758. double RsW = (int)(GridMain.ActualWidth * (PrimaryScreen.DpiX / 96f));
  3759. double RsH = (int)(GridMain.ActualHeight * (PrimaryScreen.DpiY / 96f));
  3760. if (RsW > 1266)
  3761. {
  3762. double Proportion = RsH / RsW;
  3763. RsW = 1266;
  3764. RsH = RsW * Proportion;
  3765. RsH = ((int)RsH) % 2 > 0 ? (int)RsH - 1 : (int)RsH;
  3766. //RsH = 898;
  3767. }
  3768. #endregion 设置大小
  3769. //System.Windows.Application.Current.Dispatcher.Invoke(DispatcherPriority.Send, new ThreadStart(delegate
  3770. //{
  3771. //}));
  3772. Dispatcher.Invoke(() =>
  3773. {
  3774. //保存图片
  3775. ImageHelper.SaveUI(GridMain, FilePathName, gridActWidth, gridActHeight, (int)RsW, (int)RsH);
  3776. //ImageHelper.SaveUIToImage(GridMain, FilePathName, gridActWidth, gridActHeight, (int)RsW, (int)RsH);
  3777. //ImageHelper.SaveUIToImage(GridMain, FilePathName, (int)(GridMain.ActualWidth * (PrimaryScreen.DpiX / 96f)), (int)(GridMain.ActualHeight * (PrimaryScreen.DpiY / 96f)), 0, 0);
  3778. //ImageHelper.SaveUIToImage(GridMain, FilePathName, (int)(ActualWidth * (PrimaryScreen.DpiX / 96f)), (int)(ActualHeight * (PrimaryScreen.DpiY / 96f)), (int)RsW, (int)RsH);
  3779. //ImageHelper.SaveUIToImage(GridMain, FilePathName, (int)(ActualWidth * (PrimaryScreen.DpiX / 96f)), (int)(ActualHeight * (PrimaryScreen.DpiY / 96f)), 1281, 1026);
  3780. SRTime = SRTime.AddMilliseconds(200);
  3781. //if (TxbTime.Visibility == Visibility.Hidden)
  3782. //{
  3783. // TxbTime.Visibility = Visibility.Visible;
  3784. // ImgLZImg.Visibility = Visibility.Visible;
  3785. //}
  3786. if (SRTime.Hour > 0)
  3787. {
  3788. //Dispatcher.Invoke(() =>
  3789. //{
  3790. TxbTime.Text = SRTime.ToString("HH:mm:ss");
  3791. //});
  3792. }
  3793. else
  3794. {
  3795. //Dispatcher.Invoke(() =>
  3796. //{
  3797. TxbTime.Text = SRTime.ToString("mm:ss");
  3798. //});
  3799. }
  3800. });
  3801. }
  3802. }
  3803. catch (Exception ex)
  3804. {
  3805. LogHelper.WriteErrLog("【录制】(Timer_Elapsed)生成图片错误:" + ex.Message, ex);
  3806. }
  3807. }
  3808. /// <summary>
  3809. /// 停止录制并生成录制文件
  3810. /// </summary>
  3811. private void EndRecord()
  3812. {
  3813. if (!IsFirstR)
  3814. {
  3815. #region 恢复被禁用的按钮
  3816. Dispatcher.Invoke(() =>
  3817. {
  3818. //打印按钮不恢复
  3819. //BtnPrint.IsEnabled = true;
  3820. BtnScreenshot.IsEnabled = true;
  3821. BtnImport.IsEnabled = true;
  3822. BtnScreenRecording.IsEnabled = true;
  3823. BtnUpload.IsEnabled = true;
  3824. BtnSetUp.IsEnabled = true;
  3825. BtnDevice.IsEnabled = true;
  3826. BtnLoginType.IsEnabled = true;
  3827. //btnStop.IsEnabled = false;//停止录制按钮不可点击
  3828. });
  3829. #endregion 恢复被禁用的按钮
  3830. try
  3831. {
  3832. #region 清空画板数据
  3833. Dispatcher.Invoke(() =>
  3834. {
  3835. APP.PageContextData.currpage = 0;
  3836. APP.PageContextData.pagenum = 0;
  3837. myblackboard.clear();
  3838. APP.PageDrawList.Clear();
  3839. imgCanvas.Source = null;
  3840. imgDocumentation.Source = null;
  3841. imgPPT.Source = null;
  3842. GridPage.Visibility = Visibility.Collapsed;
  3843. });
  3844. #endregion 清空画板数据
  3845. //根据录制时间长度确定是否保存
  3846. if (SRTime.Hour > 0 || SRTime.Minute > 0 || SRTime.Second > 3)
  3847. {
  3848. #region 2秒内不可点击
  3849. Dispatcher.Invoke(() =>
  3850. {
  3851. BtnRecord.IsEnabled = false;
  3852. BtnStop.IsEnabled = false;
  3853. BtnScreenRecording.IsEnabled = false;
  3854. });
  3855. #endregion 2秒内不可点击
  3856. //缩略图
  3857. string ThumbnailPath = FileToolsCommon.GetDirectoryName(VideoSavePathName) + "ThumbnailPath/";
  3858. FileToolsCommon.CreateDirectory(ThumbnailPath);
  3859. //缩略图存储位置
  3860. string ThumbnailPathName = ThumbnailPath + FileToolsCommon.GetIOFileName(VideoSavePathName).Replace(".", "") + ".JPG";
  3861. try
  3862. {
  3863. APP.FFmpeg.StopFFmpeg(AudioPathName);
  3864. }
  3865. catch (Exception ex)
  3866. {
  3867. LogHelper.WriteErrLog("【录制停止】:合并音频你文件失败," + ex.Message, ex);
  3868. }
  3869. IsStartCount = false;
  3870. //停止截图
  3871. while (APP.FFmpeg.myProcess != null)
  3872. {
  3873. Thread.Sleep(100);
  3874. }
  3875. Dispatcher.Invoke(() =>
  3876. {
  3877. timer.Change(-1, 0);
  3878. timer.Dispose();
  3879. //End();
  3880. TxbTime.Text = "00:00";
  3881. //TxbTime.Visibility = Visibility.Hidden;
  3882. //ImgLZImg.Visibility = Visibility.Hidden;
  3883. //TxbType.Visibility = Visibility.Visible;
  3884. TxbType.Text = "保存中";
  3885. });
  3886. //new Thread(new ThreadStart(new Action(() =>
  3887. //{
  3888. //判断音频是否存在 判断音频临时文件夹是否存在
  3889. if (IsRecordAudio)
  3890. {
  3891. if (!FileToolsCommon.IsExistFile(AudioPathName))
  3892. {
  3893. Thread.Sleep(100);
  3894. }
  3895. if (FileToolsCommon.IsExistDirectory(FileToolsCommon.GetDirectoryName(AudioPathName) + "temp/"))
  3896. {
  3897. Thread.Sleep(100);
  3898. }
  3899. }
  3900. else
  3901. {
  3902. //没有录制音频
  3903. AudioPathName = null;
  3904. }
  3905. //合成视频
  3906. bool SynRes = APP.FFmpeg.SynthesisVideo(ImgPath, AudioPathName, VideoSynthesisPathName, 5, gridActWidth, gridActHeight, out string ErrMessage);
  3907. //}))).Start();
  3908. //new Thread(new ThreadStart(new Action(() =>
  3909. //{
  3910. if (!SynRes)
  3911. {
  3912. Dispatcher.Invoke(() =>
  3913. {
  3914. MessageWindow.Show("录制失败," + ErrMessage);
  3915. BtnRecord.IsEnabled = true;
  3916. BtnStop.IsEnabled = false;
  3917. BtnPrint.IsEnabled = false;
  3918. BtnScreenRecording.IsEnabled = true;
  3919. TxbType.Text = "准备就绪";
  3920. BtnRecord.Visibility = Visibility.Visible;
  3921. BtnRecordSuspend.Visibility = Visibility.Collapsed;
  3922. });
  3923. return;
  3924. }
  3925. Dispatcher.Invoke(() =>
  3926. {
  3927. TxbType.Text = "转码中";
  3928. });
  3929. while (!FileToolsCommon.IsExistFile(VideoSynthesisPathName))
  3930. {
  3931. Thread.Sleep(100);
  3932. }
  3933. while (FileToolsCommon.IsExistDirectory(FileToolsCommon.GetDirectoryName(VideoSynthesisPathName) + "temp/"))
  3934. {
  3935. Thread.Sleep(100);
  3936. }
  3937. FileToolsCommon.DeleteFile(ThumbnailPathName);
  3938. VideoInfo.RSTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  3939. Thread.Sleep(500);
  3940. //VideoInfo.VideoSize = FileToolsCommon.GetFileSizeByMB(VideoSavePathName).ToString() + " MB";
  3941. VideoInfo.VideoPath = VideoSavePathName;
  3942. VideoInfo.ThumbnailPath = ThumbnailPathName;
  3943. //生成缩略图
  3944. bool ThuRes = APP.FFmpeg.GenerateThumbnails(VideoSynthesisPathName, ThumbnailPathName, 200, 130);
  3945. Thread.Sleep(500);
  3946. APP.FFmpeg.VideoTranscode(VideoSynthesisPathName, VideoSavePathName, gridActWidth, gridActHeight);
  3947. VideoInfo.FileGuid = Guid.NewGuid().ToString();
  3948. VideoInfo.IsUpload = false;
  3949. VideoInfo.Uploaded = 0;
  3950. //VideoInfo.Savefolder = APP.UserInfo.Schoolid + "/resource";
  3951. if (!APP.VideoList.Exists(x => x.FileGuid == VideoInfo.FileGuid) || !APP.VideoList.Exists(x => x.VideoPath == VideoInfo.VideoPath))
  3952. {
  3953. APP.VideoList.Add(VideoInfo);
  3954. //保存数据
  3955. APP.SaveWkData();
  3956. }
  3957. IsFirstR = true;
  3958. Dispatcher.Invoke(() =>
  3959. {
  3960. BtnRecord.IsEnabled = true;
  3961. BtnStop.IsEnabled = false;
  3962. BtnPrint.IsEnabled = false;
  3963. BtnScreenRecording.IsEnabled = true;
  3964. TxbType.Text = "准备就绪";
  3965. BtnRecord.Visibility = Visibility.Visible;
  3966. BtnRecordSuspend.Visibility = Visibility.Collapsed;
  3967. });
  3968. }
  3969. else
  3970. {
  3971. APP.FFmpeg.SuspendFFmpeg();
  3972. IsStartCount = false;
  3973. timer.Change(-1, 0);
  3974. timer.Dispose();
  3975. IsFirstR = true;
  3976. IsStartCount = false;
  3977. //停止截图
  3978. while (APP.FFmpeg.myProcess != null)
  3979. {
  3980. Thread.Sleep(100);
  3981. }
  3982. Dispatcher.Invoke(() =>
  3983. {
  3984. BtnRecord.IsEnabled = true;
  3985. BtnStop.IsEnabled = false;
  3986. BtnPrint.IsEnabled = false;
  3987. BtnScreenRecording.IsEnabled = true;
  3988. MessageWindow.Show("录制时间过短,请重新录制!");
  3989. TxbType.Text = "准备就绪";
  3990. BtnRecord.Visibility = Visibility.Visible;
  3991. BtnRecordSuspend.Visibility = Visibility.Collapsed;
  3992. TxbTime.Text = "00:00";
  3993. //TxbTime.Visibility = Visibility.Hidden;
  3994. //ImgLZImg.Visibility = Visibility.Hidden;
  3995. });
  3996. }
  3997. //List<Model_Video> VideoList
  3998. }
  3999. catch (Exception ex)
  4000. {
  4001. Dispatcher.Invoke(() =>
  4002. {
  4003. MessageWindow.Show(ex.Message);
  4004. });
  4005. }
  4006. }
  4007. }
  4008. #endregion 录制窗口
  4009. #region 登录
  4010. /// <summary>
  4011. /// 登录事件
  4012. /// </summary>
  4013. /// <param name="sender"></param>
  4014. /// <param name="e"></param>
  4015. private void BtnLoginType_Click(object sender, RoutedEventArgs e)
  4016. {
  4017. if ("未登录".Equals(TxbLoginType.Text) || ImgHeadImgN.Visibility == Visibility.Visible)
  4018. {
  4019. Login();
  4020. }
  4021. else
  4022. {
  4023. MessageBoxResult dr = MessageWindow.Show("确定退出登录?", "提示", MessageBoxButton.OKCancel);
  4024. if (dr == MessageBoxResult.OK)
  4025. {
  4026. LoginType();
  4027. Login();
  4028. }
  4029. }
  4030. }
  4031. /// <summary>
  4032. /// 登录
  4033. /// </summary>
  4034. private void Login()
  4035. {
  4036. if (APP.W_LoginWindow == null)
  4037. {
  4038. APP.W_LoginWindow = new LoginWindow
  4039. {
  4040. WindowStartupLocation = WindowStartupLocation.CenterOwner,
  4041. Owner = this
  4042. };
  4043. }
  4044. else
  4045. {
  4046. APP.W_LoginWindow.Initialize();
  4047. }
  4048. APP.W_LoginWindow.ShowDialog();
  4049. if (APP.IsLoginType)
  4050. {
  4051. string HeadpicPath = FileToolsCommon.GetFileAbsolutePath("/Data/" + APP.UserInfo.Username + ".png");
  4052. if (FileToolsCommon.IsExistFile(HeadpicPath))
  4053. {
  4054. ImgHead.ImageSource = new BitmapImage(new Uri(HeadpicPath));
  4055. }
  4056. else
  4057. {
  4058. ImgHead.ImageSource = new BitmapImage(new Uri("pack://application:,,,/BlackImages/HM_HeadImg.png"));
  4059. }
  4060. TxbLoginType.Text = APP.UserInfo.Username;
  4061. ImgHeadImgN.Visibility = Visibility.Collapsed;
  4062. ImgHeadImg.Visibility = Visibility.Visible;
  4063. //APP.UserInfo.Userphone
  4064. //ImgUpload.Visibility = Visibility.Visible;
  4065. //ImgUploadTwo.Visibility = Visibility.Collapsed;
  4066. }
  4067. else
  4068. {
  4069. TxbLoginType.Text = "未登录";
  4070. ImgHeadImgN.Visibility = Visibility.Visible;
  4071. ImgHeadImg.Visibility = Visibility.Collapsed;
  4072. //ImgUpload.Visibility = Visibility.Collapsed;
  4073. //ImgUploadTwo.Visibility = Visibility.Visible;
  4074. }
  4075. }
  4076. /// <summary>
  4077. /// 状态更改为未登录
  4078. /// </summary>
  4079. private void LoginType()
  4080. {
  4081. APP.IsLoginType = false;
  4082. TxbLoginType.Text = "未登录";
  4083. ImgHeadImgN.Visibility = Visibility.Visible;
  4084. ImgHeadImg.Visibility = Visibility.Collapsed;
  4085. APP.UserInfo = new Model_UserInfo();
  4086. //ImgUpload.Visibility = Visibility.Collapsed;
  4087. //ImgUploadTwo.Visibility = Visibility.Visible;
  4088. }
  4089. #endregion 登录
  4090. #region 分页
  4091. /// 上一页 </summary> <param name="sender"></param> <param name="e"></param>
  4092. private void last_button_Click(object sender, RoutedEventArgs e)
  4093. {
  4094. if (APP.PageContextData.currpage > 1)
  4095. {
  4096. mouseDown = false;
  4097. HideAngleBorder();
  4098. //隐藏跳转
  4099. //txbCurrpage.Visibility = Visibility.Visible;
  4100. //txtJump.Visibility = Visibility.Hidden;
  4101. //BtnJumpPage.Visibility = Visibility.Hidden;
  4102. //if(!APP.PageDrawList[APP.pageData.currpage - 1].IsImageLocation)
  4103. //{
  4104. // ImgWG();
  4105. //}
  4106. APP.PageContextData.currpage -= 1;
  4107. JumpPageClick();
  4108. }
  4109. }
  4110. /// <summary>
  4111. /// 下一页
  4112. /// </summary>
  4113. /// <param name="sender"></param>
  4114. /// <param name="e"></param>
  4115. private void next_btn_Click(object sender, RoutedEventArgs e)
  4116. {
  4117. if (APP.PageContextData.currpage < APP.PageContextData.pagenum)
  4118. {
  4119. mouseDown = false;
  4120. HideAngleBorder();
  4121. //隐藏跳转
  4122. //txbCurrpage.Visibility = Visibility.Visible;
  4123. //txtJump.Visibility = Visibility.Hidden;
  4124. //BtnJumpPage.Visibility = Visibility.Hidden;
  4125. //if (!APP.PageDrawList[APP.pageData.currpage - 1].IsImageLocation)
  4126. //{
  4127. // ImgWG();
  4128. //}
  4129. APP.PageContextData.currpage += 1;
  4130. JumpPageClick();
  4131. }
  4132. }
  4133. /// <summary>
  4134. /// 跳转
  4135. /// </summary>
  4136. private void JumpPageClick()
  4137. {
  4138. myblackboard.changepage(APP.PageContextData.currpage - 1);
  4139. ScroMain.ScrollToVerticalOffset(0);
  4140. if (BtnImport.IsEnabled)
  4141. {
  4142. ///截图可用
  4143. BtnScreenshot.IsEnabled = true;
  4144. }
  4145. if (APP.PageContextData.currpage <= APP.PageDrawList.Count)
  4146. {
  4147. if (APP.PageDrawList[APP.PageContextData.currpage - 1].ImageLocation != null)
  4148. {
  4149. APP.PageDrawList[APP.PageContextData.currpage - 1].IsImageLocation = true;
  4150. }
  4151. if (!string.IsNullOrWhiteSpace(txbCurrpage.Text) && APP.PageContextData.currpage <= APP.PageDrawList.Count && APP.PageContextData.currpage > 0 && !string.IsNullOrWhiteSpace(APP.PageDrawList[APP.PageContextData.currpage - 1].PageImagePath))
  4152. {
  4153. if (APP.PageDrawList[APP.PageContextData.currpage - 1].ImgDocumentation)
  4154. {
  4155. if ("ppt".Equals(APP.PageDrawList[APP.PageContextData.currpage - 1].Type))
  4156. {
  4157. imgCanvas.Source = null;
  4158. imgDocumentation.Source = null;
  4159. imgPPT.Source = new BitmapImage(new Uri(APP.PageDrawList[APP.PageContextData.currpage - 1].PageImagePath));
  4160. BtnScreenshot.IsEnabled = false;
  4161. }
  4162. else
  4163. {
  4164. imgPPT.Source = null;
  4165. imgCanvas.Source = null;
  4166. imgDocumentation.Source = new BitmapImage(new Uri(APP.PageDrawList[APP.PageContextData.currpage - 1].PageImagePath));
  4167. BtnScreenshot.IsEnabled = false;
  4168. }
  4169. //imgCanvas.Source = null;
  4170. //imgDocumentation.Source = new BitmapImage(new Uri(APP.PageDrawList[APP.pageData.currpage - 1].PageImagePath));
  4171. //ImgScreenshot.Visibility = Visibility.Collapsed;//当前页为导入时不可截图
  4172. //ImgScreenshotTwo.Visibility = Visibility.Visible;
  4173. //btnScreenshot.IsEnabled = false;
  4174. }
  4175. else
  4176. {
  4177. imgPPT.Source = null;
  4178. imgDocumentation.Source = null;
  4179. imgCanvas.Source = new BitmapImage(new Uri(APP.PageDrawList[APP.PageContextData.currpage - 1].PageImagePath));
  4180. APP.PageDrawList[APP.PageContextData.currpage - 1].IsImageLocation = false;
  4181. if (APP.PageDrawList[APP.PageContextData.currpage - 1].ImageLocation != null && APP.PageDrawList[APP.PageContextData.currpage - 1].ImageLocation.X > 0)
  4182. {
  4183. //var group = IMG.FindResource("Imageview") as TransformGroup;
  4184. //#region 高低 缩放比例
  4185. //if (APP.PageDrawList[APP.pageData.currpage - 1].ImageSize != null)
  4186. //{
  4187. // var transform1 = group.Children[0] as ScaleTransform;
  4188. // transform1.ScaleX = APP.PageDrawList[APP.pageData.currpage - 1].ImageSize.ScaleX;
  4189. // transform1.ScaleY = APP.PageDrawList[APP.pageData.currpage - 1].ImageSize.ScaleY;
  4190. // imgCanvas.Width = APP.PageDrawList[APP.pageData.currpage - 1].ImageSizes.CenterX;
  4191. // imgCanvas.Height = APP.PageDrawList[APP.pageData.currpage - 1].ImageSizes.CenterY;
  4192. //}
  4193. //#endregion
  4194. //#region 坐标XY轴
  4195. //var transform = group.Children[1] as TranslateTransform;
  4196. //transform.X = APP.PageDrawList[APP.pageData.currpage - 1].ImageLocation.X;
  4197. //transform.Y = APP.PageDrawList[APP.pageData.currpage - 1].ImageLocation.Y;
  4198. //#endregion
  4199. mouseDown = false;
  4200. ImgXY();
  4201. }
  4202. }
  4203. }
  4204. else
  4205. {
  4206. imgPPT.Source = null;
  4207. imgCanvas.Source = null;
  4208. imgDocumentation.Source = null;
  4209. }
  4210. #region 修改跳转页码
  4211. CbxPageList.SelectedIndex = APP.PageContextData.currpage - 1;
  4212. #endregion 修改跳转页码
  4213. }
  4214. }
  4215. private void ImgXY()
  4216. {
  4217. imgCanvas.Width = APP.PageDrawList[APP.PageContextData.currpage - 1].ImageSizes.CenterX;
  4218. imgCanvas.Height = APP.PageDrawList[APP.PageContextData.currpage - 1].ImageSizes.CenterY;
  4219. imgCanvas.Margin = new Thickness(APP.PageDrawList[APP.PageContextData.currpage - 1].ImageLocation.X, APP.PageDrawList[APP.PageContextData.currpage - 1].ImageLocation.Y, 0, 0);
  4220. //imgCanvas.Margin.Left= APP.PageDrawList[APP.pageData.currpage - 1].ImageLocation.X;
  4221. //transform.Y = APP.PageDrawList[APP.pageData.currpage - 1].ImageLocation.Y;
  4222. }
  4223. private void ImgWG()
  4224. {
  4225. mouseDown = false;
  4226. APP.PageDrawList[APP.PageContextData.currpage - 1].ImageLocation = new TranslateTransform
  4227. {
  4228. X = imgCanvas.Margin.Left,
  4229. Y = imgCanvas.Margin.Top
  4230. };
  4231. APP.PageDrawList[APP.PageContextData.currpage - 1].ImageSizes = new ScaleTransform
  4232. {
  4233. CenterX = imgCanvas.ActualWidth,
  4234. CenterY = imgCanvas.ActualHeight
  4235. };
  4236. }
  4237. #endregion 分页
  4238. #region 图像缩放,移动
  4239. private bool mouseDown;
  4240. private System.Windows.Point mouseXY;
  4241. private void IMG1_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
  4242. {
  4243. ContentControl img = sender as ContentControl;
  4244. if (img == null)
  4245. {
  4246. return;
  4247. }
  4248. img.CaptureMouse();
  4249. mouseDown = true;
  4250. mouseXY = e.GetPosition(img);
  4251. //Console.WriteLine("mouseXY.X = " + mouseXY.X + "; mouseXY.Y = " + mouseXY.Y);
  4252. }
  4253. private void IMG1_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
  4254. {
  4255. ContentControl img = sender as ContentControl;
  4256. if (img == null)
  4257. {
  4258. return;
  4259. }
  4260. img.ReleaseMouseCapture();
  4261. mouseDown = false;
  4262. }
  4263. private void IMG1_MouseMove(object sender, System.Windows.Input.MouseEventArgs e)
  4264. {
  4265. ContentControl img = sender as ContentControl;
  4266. if (img == null)
  4267. {
  4268. return;
  4269. }
  4270. if (mouseDown)
  4271. {
  4272. Domousemove(img, e);
  4273. }
  4274. }
  4275. /// <summary>
  4276. /// x y轴
  4277. /// </summary>
  4278. /// <param name="img"></param>
  4279. /// <param name="e"></param>
  4280. private void Domousemove(ContentControl img, System.Windows.Input.MouseEventArgs e)
  4281. {
  4282. if (e.LeftButton != MouseButtonState.Pressed)
  4283. {
  4284. return;
  4285. }
  4286. if (APP.PageDrawList[APP.PageContextData.currpage - 1].ImageLocation != null && APP.PageDrawList[APP.PageContextData.currpage - 1].IsImageLocation)
  4287. {
  4288. return;
  4289. }
  4290. TransformGroup group = IMG.FindResource("Imageview") as TransformGroup;
  4291. TranslateTransform transform = group.Children[1] as TranslateTransform;
  4292. System.Windows.Point position = e.GetPosition(img);
  4293. transform.X -= mouseXY.X - position.X;
  4294. transform.Y -= mouseXY.Y - position.Y;
  4295. mouseXY = position;
  4296. APP.PageDrawList[APP.PageContextData.currpage - 1].ImageLocation = new TranslateTransform
  4297. {
  4298. X = transform.X,
  4299. Y = transform.Y
  4300. };
  4301. //APP.PageDrawList[APP.pageData.currpage - 1].IsImageLocation = false;
  4302. }
  4303. private void IMG1_MouseWheel(object sender, MouseWheelEventArgs e)
  4304. {
  4305. ContentControl img = sender as ContentControl;
  4306. if (img == null)
  4307. {
  4308. return;
  4309. }
  4310. System.Windows.Point point = e.GetPosition(img);
  4311. //Console.WriteLine("point.X = " + point.X + "; point.Y=" + point.Y);
  4312. System.Windows.Point PicLocate = e.GetPosition(imgCanvas);
  4313. //Console.WriteLine("PicEmap.X = " + PicLocate.X + "; PicEmap.Y=" + PicLocate.Y);
  4314. TransformGroup group = IMG.FindResource("Imageview") as TransformGroup;
  4315. double delta = e.Delta * 0.001;
  4316. DowheelZoom(group, point, delta);
  4317. }
  4318. private void DowheelZoom(TransformGroup group, System.Windows.Point point, double delta)
  4319. {
  4320. System.Windows.Point pointToContent = group.Inverse.Transform(point);
  4321. ScaleTransform transform = group.Children[0] as ScaleTransform;
  4322. if (transform.ScaleX + delta < 0.1)
  4323. {
  4324. return;
  4325. }
  4326. transform.ScaleX += delta;
  4327. transform.ScaleY += delta;
  4328. TranslateTransform transform1 = group.Children[1] as TranslateTransform;
  4329. transform1.X = -1 * ((pointToContent.X * transform.ScaleX) - point.X);
  4330. transform1.Y = -1 * ((pointToContent.Y * transform.ScaleY) - point.Y);
  4331. //LogHelper.WriteInfoLog("【img宽高】" + imgCanvas.ActualWidth.ToString() + ":"
  4332. // + imgCanvas.ActualHeight.ToString() + "百分比:" + transform.ScaleX.ToString() + ":" + transform.ScaleY.ToString()
  4333. // );
  4334. //Console.WriteLine("transform.ScaleX = " + transform.ScaleX + "; transform.ScaleY = " + transform.ScaleY);
  4335. //APP.PageDrawList[APP.pageData.currpage - 1].ImageSize = new ScaleTransform();
  4336. //APP.PageDrawList[APP.pageData.currpage - 1].ImageSize.ScaleX = transform.ScaleX;
  4337. //APP.PageDrawList[APP.pageData.currpage - 1].ImageSize.ScaleY = transform.ScaleY;
  4338. APP.PageDrawList[APP.PageContextData.currpage - 1].ImageLocation = new TranslateTransform
  4339. {
  4340. X = transform1.X,
  4341. Y = transform1.Y
  4342. };
  4343. APP.PageDrawList[APP.PageContextData.currpage - 1].ImageSizes = new ScaleTransform
  4344. {
  4345. CenterX = imgCanvas.ActualWidth,
  4346. CenterY = imgCanvas.ActualHeight
  4347. };
  4348. APP.PageDrawList[APP.PageContextData.currpage - 1].IsImageLocation = false;
  4349. }
  4350. #endregion 图像缩放,移动
  4351. #region 拓思德点阵笔
  4352. #region 值初始化
  4353. // 不同尺寸点阵纸点阵宽高尺寸计算方法为:纸张物理尺寸(毫米)/0.3 *8,详见 开发必读.pdf 文档
  4354. /// <summary>
  4355. /// A4点阵纸点阵宽度
  4356. /// </summary>
  4357. private const int A4_WIDTH = 5600;
  4358. /// <summary>
  4359. /// A4点阵纸点阵高度
  4360. /// </summary>
  4361. private const int A4_HEIGHT = 7920;
  4362. ///// <summary>
  4363. ///// 画板
  4364. ///// </summary>
  4365. //private Graphics graphics;
  4366. /// <summary>
  4367. /// 笔画坐标数组
  4368. /// </summary>
  4369. //private List<System.Drawing.Point> stroke;
  4370. /// <summary>
  4371. /// 笔序列号
  4372. /// </summary>
  4373. private string penSerial;
  4374. /// <summary>
  4375. /// 笔是否在点
  4376. /// </summary>
  4377. private bool isPenDown;
  4378. //当前点阵地址
  4379. private string currentPageSerial = string.Empty;
  4380. //不同点阵地址对应的笔迹绘制图片,用于实现在不同点阵地址书写切换时,显示书写内容自动切换
  4381. //本例图片放在内存中存储,对于大量或者需要在多个点阵地址对应图片进行切换演示,建议将图片存储到文件,以免内存溢出
  4382. private Dictionary<string, System.Drawing.Image> pagesDic = new Dictionary<string, System.Drawing.Image>();
  4383. #endregion 值初始化
  4384. public void InitPen()
  4385. {
  4386. //stroke = new List<System.Drawing.Point>();
  4387. //获取点阵笔实例,并绑定点阵笔事件
  4388. //将授权文件内容传入,获取点阵笔对象实例
  4389. APP.digitalPen = DigitalPenHID.GetInstance(certificates.MyLicense.Bytes);
  4390. //绑定笔连接事件
  4391. APP.digitalPen.PenConnected += OnPenConnect;
  4392. //绑定笔断开事件
  4393. APP.digitalPen.PenDisconnect += OnPenDisconnect;
  4394. //绑定笔书写输出坐标事件
  4395. APP.digitalPen.PenCoordinate += OnPenCoordinate;
  4396. //绑定抬笔事件
  4397. APP.digitalPen.PenUp += OnPenUp;
  4398. //绑定落笔事件
  4399. APP.digitalPen.PenDown += OnPenDown;
  4400. APP.digitalPen.PenBatteryCapacity += OnBatteryCapacity;
  4401. APP.digitalPen.PenMemoryFillLevel += OnMemoryFillLevel;
  4402. //完成初始化点阵笔,开始与点阵笔通信
  4403. ERROR_CODE ER = APP.digitalPen.Start();
  4404. ////绑定笔在新的点阵地址页面书写事件
  4405. //APP.digitalPen.PenNewPage += APP.digitalPen_OnPenNewPage;
  4406. ////绑定笔信息事件
  4407. //APP.digitalPen.PenInfo += APP.digitalPen_OnPenInfo;
  4408. //启动接收笔数据,完成初始化工作
  4409. ERROR_CODE rc = APP.digitalPen.Start();
  4410. //判断是否成功
  4411. if (ER != ERROR_CODE.ERROR_OK)
  4412. {
  4413. MessageWindow.Show("初始化失败,授权过期,返回值:" + ER.ToString());
  4414. }
  4415. }
  4416. /// <summary>
  4417. /// 落笔
  4418. /// </summary>
  4419. /// <param name="time">时间戳,1970年1月1日到现在的总毫秒数</param>
  4420. /// <param name="penSerial">点阵笔序列号</param>
  4421. /// <param name="penType">点阵笔型号编号</param>
  4422. private void OnPenDown(ulong time, string penSerial, int penType)
  4423. {
  4424. if (CheckAccess())
  4425. {
  4426. Action<ulong, string, int> action = new Action<ulong, string, int>(OnPenDown);
  4427. Dispatcher.Invoke(action, new object[] { time, penSerial, penType });
  4428. }
  4429. else
  4430. {
  4431. //labPenSerial.Text = penSerial;
  4432. //labPenStatus.Text = "PenDown";
  4433. isPenDown = true;
  4434. //Dispatcher.Invoke(new Action(() =>
  4435. //{
  4436. // for (int i = 0; i < APP.PageDrawList.Count; i++)
  4437. // {
  4438. // if (APP.PageDrawList[i].PageCode == penSerial)
  4439. // {
  4440. // if (i < APP.pageData.pagenum)
  4441. // {
  4442. // if (i < APP.pageData.currpage)
  4443. // {
  4444. // int num = APP.pageData.currpage - i;
  4445. // APP.pageData.currpage -= num;
  4446. // myblackboard.changepage(APP.pageData.currpage - 1);
  4447. // if (APP.PageDrawList.Count > 0)
  4448. // {
  4449. // if (!string.IsNullOrWhiteSpace(txbCurrpage.Text) && APP.pageData.currpage <= APP.PageDrawList.Count && APP.pageData.currpage > 0 && !string.IsNullOrWhiteSpace(APP.PageDrawList[APP.pageData.currpage - 1].PageImagePath))
  4450. // {
  4451. // //imgCanvas.Source = new BitmapImage(new Uri(APP.Paths[APP.pageData.currpage - 1]));//cs
  4452. // imgCanvas.Source = new BitmapImage(new Uri(APP.PageDrawList[APP.pageData.currpage - 1].PageImagePath));
  4453. // }
  4454. // else
  4455. // {
  4456. // imgCanvas.Source = null;
  4457. // }
  4458. // }
  4459. // }
  4460. // else
  4461. // {
  4462. // int num = i - APP.pageData.currpage;
  4463. // APP.pageData.currpage += num;
  4464. // myblackboard.changepage(APP.pageData.currpage - 1);
  4465. // if (APP.PageDrawList.Count > 0)
  4466. // {
  4467. // if (!string.IsNullOrWhiteSpace(txbCurrpage.Text) && APP.pageData.currpage <= APP.PageDrawList.Count && !string.IsNullOrWhiteSpace(APP.PageDrawList[APP.pageData.currpage - 1].PageImagePath))
  4468. // {
  4469. // //imgCanvas.Source = new BitmapImage(new Uri(APP.Paths[APP.pageData.currpage-1]));
  4470. // imgCanvas.Source = new BitmapImage(new Uri(APP.PageDrawList[APP.pageData.currpage - 1].PageImagePath));
  4471. // }
  4472. // else
  4473. // {
  4474. // imgCanvas.Source = null;
  4475. // }
  4476. // }
  4477. // }
  4478. // }
  4479. // return;
  4480. // }
  4481. // }
  4482. // //myblackboard.changepages(0, 0, true);
  4483. // //myblackboard.changepaget(0, 0, true, blackboard_canvas);
  4484. //}));
  4485. }
  4486. //myblackboard.changepages(0, 0, true);
  4487. }
  4488. /// <summary>
  4489. /// 抬笔
  4490. /// </summary>
  4491. /// <param name="time">时间戳,1970年1月1日到现在的总毫秒数</param>
  4492. /// <param name="penSerial">点阵笔序列号</param>
  4493. /// <param name="penType">点阵笔型号编号</param>
  4494. private void OnPenUp(ulong time, string penSerial, int penType)
  4495. {
  4496. if (CheckAccess())
  4497. {
  4498. Action<ulong, string, int> action = new Action<ulong, string, int>(OnPenUp);
  4499. Dispatcher.Invoke(action, new object[] { time, penSerial, penType });
  4500. }
  4501. else
  4502. {
  4503. isPenDown = false;
  4504. APP.PenSerial = penSerial;
  4505. //int leftPoints = stroke.Count % 3;
  4506. //if (0 != leftPoints)
  4507. //{
  4508. // int from = stroke.Count - leftPoints - 1;
  4509. // if (from < 0)
  4510. // from = 0;
  4511. // int to = stroke.Count - 1;
  4512. // DrawCoordinates(from, to);
  4513. //}
  4514. //stroke.Clear();
  4515. }
  4516. if (APP.PageContextData.currpage > 0)
  4517. {
  4518. Dispatcher.Invoke(new Action(() =>
  4519. {
  4520. myblackboard.changepages(0, 0, true, Color, PenSize, APP.PageContextData.currpage - 1, 0);
  4521. }));
  4522. }
  4523. }
  4524. /// <summary>
  4525. /// 笔断开
  4526. /// </summary>
  4527. /// <param name="time">时间戳,1970年1月1日到现在的总毫秒数</param>
  4528. /// <param name="penSerial">点阵笔序列号</param>
  4529. /// <param name="penType">点阵笔型号编号</param>
  4530. private void OnPenDisconnect(ulong time, string penSerial, int penType)
  4531. {
  4532. if (CheckAccess())
  4533. {
  4534. Action<ulong, string, int> action = new Action<ulong, string, int>(OnPenDisconnect);
  4535. Dispatcher.Invoke(action, new object[] { time, penSerial, penType });
  4536. }
  4537. else
  4538. {
  4539. APP.PenSerial = penSerial;
  4540. APP.PenStatus = false;
  4541. UpdateDevStatus();
  4542. //Dispatcher.Invoke(new Action(() =>
  4543. //{
  4544. // txbNotConnected.Text = "未连接";
  4545. // txbNotConnecteds.Text = "未连接";
  4546. //}));
  4547. }
  4548. }
  4549. /// <summary>
  4550. /// 笔连接
  4551. /// </summary>
  4552. /// <param name="time">时间戳,1970年1月1日到现在的总毫秒数</param>
  4553. /// <param name="penSerial">点阵笔序列号</param>
  4554. /// <param name="penType">点阵笔型号编号</param>
  4555. private void OnPenConnect(ulong time, string penSerial, int penType)
  4556. {
  4557. if (CheckAccess())
  4558. {
  4559. Action<ulong, string, int> action = new Action<ulong, string, int>(OnPenConnect);
  4560. Dispatcher.Invoke(action, new object[] { time, penSerial, penType });
  4561. }
  4562. else
  4563. {
  4564. APP.PenSerial = penSerial;
  4565. APP.PenStatus = true;
  4566. this.penSerial = penSerial;
  4567. //连接后,在获取笔数据前,可以清除笔内的历史数据
  4568. //APP.digitalPen.ClearMemory(penSerial);
  4569. //开始接收笔数据
  4570. APP.digitalPen.GetPenData(penSerial);
  4571. UpdateDevStatus();
  4572. }
  4573. }
  4574. /// <summary>
  4575. /// 电池电量
  4576. /// </summary>
  4577. /// <param name="time"></param>
  4578. /// <param name="penSerial"></param>
  4579. /// <param name="penType"></param>
  4580. /// <param name="capacity"></param>
  4581. private void OnBatteryCapacity(ulong time, string penSerial, int penType, byte capacity)
  4582. {
  4583. if (CheckAccess())
  4584. {
  4585. Action<ulong, string, int, byte> action = new Action<ulong, string, int, byte>(OnBatteryCapacity);
  4586. Dispatcher.Invoke(action, new object[] { time, penSerial, penType, capacity });
  4587. }
  4588. else
  4589. {
  4590. //System.Windows.MessageWindow.Show("电池电量:" + capacity.ToString());
  4591. }
  4592. }
  4593. /// <summary>
  4594. /// 已用存储
  4595. /// </summary>
  4596. /// <param name="time"></param>
  4597. /// <param name="penSerial"></param>
  4598. /// <param name="penType"></param>
  4599. /// <param name="fillLevel"></param>
  4600. private void OnMemoryFillLevel(ulong time, string penSerial, int penType, byte fillLevel)
  4601. {
  4602. if (CheckAccess())
  4603. {
  4604. Action<ulong, string, int, byte> action = new Action<ulong, string, int, byte>(OnMemoryFillLevel);
  4605. Dispatcher.Invoke(action, new object[] { time, penSerial, penType, fillLevel });
  4606. }
  4607. else
  4608. {
  4609. //System.Windows.MessageWindow.Show("存储:" + fillLevel.ToString());
  4610. }
  4611. }
  4612. /// <summary>
  4613. /// 笔书写,收到坐标
  4614. /// </summary>
  4615. /// <param name="time">时间戳,1970年1月1日到现在的总毫秒数</param>
  4616. /// <param name="penSerial">点阵笔序列号</param>
  4617. /// <param name="penType">点阵笔型号编号</param>
  4618. /// <param name="pageSerial">点阵地址</param>
  4619. /// <param name="cx">x坐标</param>
  4620. /// <param name="cy">y坐标</param>
  4621. /// <param name="force">压力值</param>
  4622. private void OnPenCoordinate(ulong time, string penSerial, int penType, string pageSerial, int cx, int cy, byte force)
  4623. {
  4624. if (CheckAccess())
  4625. {
  4626. Action<ulong, string, int, string, int, int, byte> ac = new Action<ulong, string, int, string, int, int, byte>(OnPenCoordinate);
  4627. Dispatcher.Invoke(ac, new object[] { time, pageSerial, penType, pageSerial, cx, cy, force });
  4628. }
  4629. else
  4630. {
  4631. //判断是否是落笔后输出的坐标,在设置悬浮模式下,落笔前的悬浮坐标不绘制
  4632. if (!isPenDown)
  4633. {
  4634. return;
  4635. }
  4636. //stroke.Add(new System.Drawing.Point(cx, cy));
  4637. double PropW = blackboard_canvas.ActualWidth / A4_WIDTH;
  4638. double PropH = blackboard_canvas.ActualHeight / A4_HEIGHT;
  4639. //点
  4640. double tempX = cx * PropW;
  4641. double tempY = cy * PropH;
  4642. //pageSerial //点阵IP地址 与打印的页面关联
  4643. if (APP.PageContextData.currpage > 0)
  4644. {
  4645. Dispatcher.Invoke(new Action(() =>
  4646. {
  4647. float Pressure = force / 100f;
  4648. //myblackboard.changepages(testX, testY,false);
  4649. myblackboard.changepages(tempX, tempY, false, Color, PenSize, APP.PageContextData.currpage - 1, Pressure);
  4650. #region 设置滚动条位置
  4651. //点在显示页面上方
  4652. if (tempY < ScroMain.VerticalOffset)
  4653. {
  4654. //滚动条当前位置
  4655. double RollCurrentLocation = ScroMain.VerticalOffset;
  4656. //向上滚动至以点为中心需要滚动的距离
  4657. double UpRoll = (RollCurrentLocation - tempY) + (ScroMain.ActualHeight / 2);
  4658. //如果小于0则等于0
  4659. double RollLocation = RollCurrentLocation - UpRoll;
  4660. if (RollLocation < 0)
  4661. {
  4662. RollLocation = 0;
  4663. }
  4664. ////滚动条实际偏移量
  4665. //double RollOffset = RollCurrentLocation - RollLocation;
  4666. ScroMain.ScrollToVerticalOffset(RollLocation);
  4667. }
  4668. //点在显示页面下方
  4669. if (tempY > ScroMain.VerticalOffset + ScroMain.ActualHeight)
  4670. {
  4671. //滚动条当前位置
  4672. double RollCurrentLocation = ScroMain.VerticalOffset;
  4673. //向下滚动至以点为中心需要滚动的距离
  4674. double DownRoll = (tempY - RollCurrentLocation) - (ScroMain.ActualHeight / 2);
  4675. //如果小于0则等于0
  4676. double RollLocation = RollCurrentLocation + DownRoll;
  4677. //滚动条最大滚动值
  4678. double ScrollbarMaxNum = GridM.ActualHeight - ScroMain.ActualHeight;
  4679. if (RollLocation > ScrollbarMaxNum)
  4680. {
  4681. RollLocation = ScrollbarMaxNum;
  4682. }
  4683. ////滚动条实际偏移量
  4684. //double RollOffset = RollLocation-RollCurrentLocation;
  4685. ScroMain.ScrollToVerticalOffset(RollLocation);
  4686. }
  4687. #endregion 设置滚动条位置
  4688. //gridM.Height //A4高度
  4689. //ScroMain.VerticalOffset;//获取滚动条位置
  4690. //ScroMain.ActualHeight//A4纸显示高度
  4691. //ScroMain.ScrollToHorizontalOffset()//设置滚动条位置
  4692. //Mouse.GetPosition(this)
  4693. if (tempX > 0 && tempY > 0)
  4694. {
  4695. //System.Windows.Point getP = blackboard_canvas.PointToScreen(new System.Windows.Point(testX, testY));
  4696. System.Windows.Point getP = ScroMain.PointToScreen(new System.Windows.Point(tempX, tempY - ScroMain.VerticalOffset));
  4697. SetCursorPos((int)getP.X, (int)getP.Y);
  4698. }
  4699. }));
  4700. }
  4701. ////每3个点画一条曲线
  4702. //if (stroke.Count % 3 == 0)
  4703. //{
  4704. // int from = stroke.Count - 3 - 1;
  4705. // if (from < 0)
  4706. // from = 0;
  4707. // int to = stroke.Count - 1;
  4708. // DrawCoordinates(from, to);
  4709. //}
  4710. }
  4711. }
  4712. /// <summary>
  4713. /// 停止笔
  4714. /// </summary>
  4715. public void StopDigitalPen()
  4716. {
  4717. //停止,释放资源
  4718. APP.digitalPen.Stop();
  4719. }
  4720. /// <summary>
  4721. /// 清空笔内存储
  4722. /// </summary>
  4723. public void ClearPenStorage()
  4724. {
  4725. if (!string.IsNullOrEmpty(penSerial))
  4726. {
  4727. APP.digitalPen.ClearMemory(penSerial);
  4728. }
  4729. }
  4730. /// <summary>
  4731. /// 获取剩余电量
  4732. /// </summary>
  4733. public void GetPenElectricityQuantity()
  4734. {
  4735. if (!string.IsNullOrEmpty(penSerial))
  4736. {
  4737. APP.digitalPen.GetBatteryCapacity(penSerial);
  4738. }
  4739. }
  4740. /// <summary>
  4741. /// 获取存储空间
  4742. /// </summary>
  4743. public void GetUsedStorage()
  4744. {
  4745. if (!string.IsNullOrEmpty(penSerial))
  4746. {
  4747. APP.digitalPen.GetMemoryFillLevel(penSerial);
  4748. }
  4749. }
  4750. /// <summary>
  4751. /// 开启悬浮
  4752. /// </summary>
  4753. public void 开启悬浮()
  4754. {
  4755. if (!string.IsNullOrEmpty(penSerial))
  4756. {
  4757. APP.digitalPen.SetPenHoverMode(true, penSerial);
  4758. }
  4759. }
  4760. /// <summary>
  4761. /// 关闭悬浮
  4762. /// </summary>
  4763. public void 关闭悬浮()
  4764. {
  4765. if (!string.IsNullOrEmpty(penSerial))
  4766. {
  4767. APP.digitalPen.SetPenHoverMode(false, penSerial);
  4768. }
  4769. }
  4770. /// <summary>
  4771. /// 引用user32.dll动态链接库(windows api), 使用库中定义 API:SetCursorPos 设置光标位置
  4772. /// </summary>
  4773. [System.Runtime.InteropServices.DllImport("user32.dll")]
  4774. private static extern int SetCursorPos(int x, int y);
  4775. #endregion 拓思德点阵笔
  4776. #region 写字板模式
  4777. #region 值初始化
  4778. [System.Runtime.InteropServices.DllImport("kernel32.dll", CharSet = System.Runtime.InteropServices.CharSet.Auto)]
  4779. public static extern void OutputDebugString(string message);
  4780. public bool usbIsConnected = false;
  4781. //Angle angle = Angle._270;
  4782. private eDeviceType deviceType = eDeviceType.Unknow;
  4783. ///// <summary>
  4784. ///// 点缩放比例
  4785. ///// </summary>
  4786. //private double m_nCompress = 0;
  4787. //private double m_nCompress_x = 0;
  4788. //private double m_nCompress_y = 0;
  4789. ///// <summary>
  4790. ///// 0:画布根据板子适配
  4791. ///// 1:板子根据画布适配
  4792. ///// </summary>
  4793. //private int type = 1;//默认画笔根据板子适配
  4794. //bool bScreenO = false;//判断是否是横屏,默认横屏,true:横屏幕;false:竖屏
  4795. //Drawing drawing;
  4796. //List<RobotPoint> plist = new List<RobotPoint>();
  4797. //画布宽高
  4798. //private int m_nDeviceW = 21000;
  4799. //private int m_nDeviceH = 29700;
  4800. private int m_nDeviceW = 22600;
  4801. private int m_nDeviceH = 16650;
  4802. private RobotpenGateway.robotpenController.returnPointData date = null;
  4803. //private int nResource = 0;
  4804. //private ReportRate RR = ReportRate.R_200;
  4805. //string Mac = string.Empty;
  4806. //int Recog_create = 0;
  4807. //int Recog_adddate = 0;
  4808. //int Recog_start = 0;
  4809. public bool isOpen = true;
  4810. //PrintType ptype = PrintType.NoMarkCode_FB2;
  4811. //int pageData = 0;
  4812. //bool AreSynchronized = false;
  4813. /// <summary>
  4814. /// 是否为笔模式
  4815. /// </summary>
  4816. private bool IsPen = false;
  4817. private bool IsT8 = true;
  4818. #endregion 值初始化
  4819. #region 罗博智慧笔
  4820. /// <summary>
  4821. /// 笔模式
  4822. /// </summary>
  4823. private void deviceHand()
  4824. {
  4825. IsPen = true;
  4826. if (APP.IsOutputInfoLog)
  4827. {
  4828. LogHelper.WriteInfoLog(string.Format("切换笔模式:设备类型:{0}", deviceType.ToString()));
  4829. }
  4830. if (deviceType == eDeviceType.T8B_D2 || deviceType == eDeviceType.T8Y || deviceType == eDeviceType.T8S_LQ)
  4831. {
  4832. IsT8 = true;
  4833. robotpenController.GetInstance().setDeviceMode(eDeviceMode.DEVICE_HAND);
  4834. if (APP.IsOutputInfoLog)
  4835. {
  4836. LogHelper.WriteInfoLog("使用robotpenController.GetInstance().setDeviceMode(eDeviceMode.DEVICE_HAND)切换");
  4837. }
  4838. }
  4839. else
  4840. {
  4841. IsT8 = false;
  4842. //获取当前设备模式,根据模式切换鼠标和笔
  4843. robotpenController.GetInstance()._Send(cmdId.SearchMode);
  4844. if (APP.IsOutputInfoLog)
  4845. {
  4846. LogHelper.WriteInfoLog("发送(cmdId.SearchMode)");
  4847. }
  4848. }
  4849. }
  4850. /// <summary>
  4851. /// 鼠标模式
  4852. /// </summary>
  4853. private void deviceMouse()
  4854. {
  4855. IsPen = false;
  4856. if (deviceType == eDeviceType.T8B_D2 || deviceType == eDeviceType.T8Y || deviceType == eDeviceType.T8S_LQ)
  4857. {
  4858. IsT8 = true;
  4859. robotpenController.GetInstance().setDeviceMode(eDeviceMode.DEVICE_MOUSE);
  4860. if (APP.IsOutputInfoLog)
  4861. {
  4862. LogHelper.WriteInfoLog("使用robotpenController.GetInstance().setDeviceMode(eDeviceMode.DEVICE_MOUSE)切换");
  4863. }
  4864. }
  4865. else
  4866. {
  4867. IsT8 = false;
  4868. //获取当前设备模式,根据模式切换鼠标和笔
  4869. robotpenController.GetInstance()._Send(cmdId.SearchMode);
  4870. if (APP.IsOutputInfoLog)
  4871. {
  4872. LogHelper.WriteInfoLog("发送(cmdId.SearchMode)");
  4873. }
  4874. }
  4875. }
  4876. private void Form1_searchModeEvt(int modeType)
  4877. {
  4878. //笔模式
  4879. if (modeType == 1)
  4880. {
  4881. if (APP.IsOutputInfoLog)
  4882. {
  4883. LogHelper.WriteInfoLog("当前为笔模式时,切换回鼠标模式");
  4884. }
  4885. //当前为笔模式时 切换回鼠标模式
  4886. if (!IsPen && !IsT8)
  4887. {
  4888. robotpenController.GetInstance()._Send(cmdId.SwitchMode);
  4889. if (APP.IsOutputInfoLog)
  4890. {
  4891. LogHelper.WriteInfoLog("T7设备切换成鼠标模式._Send(cmdId.SwitchMode)");
  4892. }
  4893. }
  4894. }
  4895. else
  4896. {
  4897. if (APP.IsOutputInfoLog)
  4898. {
  4899. LogHelper.WriteInfoLog("当前为鼠标模式 切换为笔模式");
  4900. }
  4901. //当前为鼠标模式 切换为笔模式
  4902. if (isOpen && !IsT8)
  4903. {
  4904. robotpenController.GetInstance()._Send(cmdId.SwitchMode);
  4905. if (APP.IsOutputInfoLog)
  4906. {
  4907. LogHelper.WriteInfoLog("T7设备切换成笔模式._Send(cmdId.SwitchMode)");
  4908. }
  4909. }
  4910. }
  4911. }
  4912. private void Form1_switchModeEvt(int modeType)
  4913. {
  4914. if (modeType == 1)
  4915. {
  4916. if (APP.IsOutputInfoLog)
  4917. {
  4918. LogHelper.WriteInfoLog("当前为笔模式");
  4919. }
  4920. if (!IsPen)
  4921. {
  4922. deviceMouse();
  4923. }
  4924. ////当前为笔模式时 切换回鼠标模式
  4925. //if (!IsPen && !IsT8)
  4926. //{
  4927. // robotpenController.GetInstance()._Send(cmdId.SwitchMode);
  4928. // if (APP.IsOutputInfoLog)
  4929. // {
  4930. // LogHelper.WriteInfoLog("T7设备切换成鼠标模式._Send(cmdId.SwitchMode)");
  4931. // }
  4932. //}
  4933. }
  4934. else
  4935. {
  4936. if (APP.IsOutputInfoLog)
  4937. {
  4938. LogHelper.WriteInfoLog("当前为鼠标模式");
  4939. }
  4940. if (IsPen)
  4941. {
  4942. deviceHand();
  4943. }
  4944. ////当前为鼠标模式 切换为笔模式
  4945. //if (isOpen && !IsT8)
  4946. //{
  4947. // robotpenController.GetInstance()._Send(cmdId.SwitchMode);
  4948. // if (APP.IsOutputInfoLog)
  4949. // {
  4950. // LogHelper.WriteInfoLog("T7设备切换成笔模式._Send(cmdId.SwitchMode)");
  4951. // }
  4952. //}
  4953. }
  4954. }
  4955. //初始化笔服务
  4956. private void InitlbPen()
  4957. {
  4958. try
  4959. {
  4960. robotpenController.GetInstance()._ConnectInitialize(eDeviceType.Gateway, IntPtr.Zero);
  4961. robotpenController.GetInstance().deviceChangeEvt += new robotpenController.DeviceChange(Form1_deviceChangeEvt);
  4962. robotpenController.GetInstance().searchModeEvt += Form1_searchModeEvt;
  4963. robotpenController.GetInstance().switchModeEvt += Form1_switchModeEvt;
  4964. //robotpenController.GetInstance().deviceChangeEvt += new robotpenController.DeviceChange(Form1_deviceChangeEvt);
  4965. //robotpenController.GetInstance().gatewatVersionEvt += Form1_gatewatVersionEvt;
  4966. //robotpenController.GetInstance().nodeStatusEvt += Form1_nodeStatusEvt;
  4967. //// 所有设备均注册该页码显示消息 目前只有T9设备才会有页码识别功能, 客户代码可以根据设备来判断是否消费该事件
  4968. //robotpenController.GetInstance().showPageEvt += new robotpenController.ShowPage(Form1_showPageEvt);
  4969. // T8A 按键消息 为了适应其他demo也能响应, 所以任何demo都消费此事件, 客户代码可根据设备类型判断是否消费此事件
  4970. robotpenController.GetInstance().keyPressEvt += new robotpenController.KeyPress(Form1_keyPressEvt);
  4971. //robotpenController.GetInstance().PageSensorCallback_Evt += Rbtnet__PageSensorEvt_;
  4972. date = new RobotpenGateway.robotpenController.returnPointData(Form1_bigDataReportEvt1);
  4973. robotpenController.GetInstance().initDeletgate(ref date);
  4974. CheckUsbConnect();
  4975. ////robotpenController.GetInstance().returnOptimizePointDataEvt += new robotpenController.returnOptimizePointData(Form1_returnOptimizePointDataEvt);
  4976. //robotpenController.GetInstance().startSyncNoteDataEvt += new robotpenController.startSyncNoteData(Form1_startSyncNoteDataEvt);
  4977. //robotpenController.GetInstance().startSyncNoteData_kzEvt += Form1_startSyncNoteData_kzEvt;
  4978. //robotpenController.GetInstance().syncNoteDataEvt += new robotpenController.syncNoteData(Form1_syncNoteDataEvt);
  4979. //robotpenController.GetInstance().endSyncNoteDataEvt += new robotpenController.endSyncNoteData(Form1_endSyncNoteDataEvt);
  4980. //robotpenController.GetInstance().getOfflineNoteDataEvt += new robotpenController.getOfflineNoteData(Form1_getOfflineNoteDataEvt);
  4981. }
  4982. catch (Exception ex)
  4983. {
  4984. LogHelper.WriteErrLog("设备初始化失败:" + ex.Message, ex);
  4985. }
  4986. }
  4987. /// <summary>
  4988. /// 委托实例函数,用于异步修改listview显示的USB连接设备信息
  4989. /// </summary>
  4990. private void SetListView()
  4991. {
  4992. if (usbIsConnected)
  4993. {
  4994. robotpenController.GetInstance()._CloseConnect();
  4995. }
  4996. CheckUsbConnect();
  4997. }
  4998. /// <summary>
  4999. /// 设备插拔消息,更新listview
  5000. /// </summary>
  5001. /// <param name="bStatus"></param>
  5002. /// <param name="uPid"></param>
  5003. private void Form1_deviceChangeEvt(bool bStatus, ushort uPid)
  5004. {
  5005. //throw new NotImplementedException();
  5006. //Console.WriteLine();
  5007. try
  5008. {
  5009. if (APP.IsOutputInfoLog)
  5010. {
  5011. LogHelper.WriteInfoLog(string.Format("设备状态{0} PID = {1}", bStatus, uPid));
  5012. }
  5013. }
  5014. catch (Exception)
  5015. {
  5016. }
  5017. //SetListView();
  5018. CheckUsbConnect();
  5019. }
  5020. /// <summary>
  5021. /// 书写
  5022. /// </summary>
  5023. /// ///
  5024. /// <param name="bIndex"></param>
  5025. /// <param name="bPenStatus"></param>
  5026. /// <param name="bx"></param>
  5027. /// <param name="by"></param>
  5028. /// <param name="bPress"></param>
  5029. private void Form1_bigDataReportEvt1(byte bIndex, byte bPenStatus, short bx, short by, short bPress)
  5030. {
  5031. if (bx == 0 && by == 0 && bPenStatus == 0 && bPress == 0)
  5032. {
  5033. return;
  5034. }
  5035. //17是按下,16是抬起
  5036. if (bPenStatus == 16 || bPenStatus == 0)
  5037. {
  5038. //stroke.Clear();
  5039. if (APP.PageContextData.currpage > 0)
  5040. {
  5041. Dispatcher.Invoke(new Action(() =>
  5042. {
  5043. myblackboard.changepages(0, 0, true, Color, PenSize, APP.PageContextData.currpage - 1, 0);
  5044. }));
  5045. }
  5046. }
  5047. ////按下
  5048. //if (bPenStatus == 17)
  5049. //{
  5050. //}
  5051. //if (APP.IsOutputInfoLog)
  5052. //{
  5053. // LogHelper.WriteInfoLog(string.Format(@"x={0},y={1},s={2},p={3}", bx, by, bPenStatus, bPress));
  5054. //}
  5055. //stroke.Add(new System.Drawing.Point(by, bx));
  5056. double PropW = blackboard_canvas.ActualWidth / m_nDeviceH;
  5057. double PropH = blackboard_canvas.ActualHeight / m_nDeviceW;
  5058. //点
  5059. double tempY = (m_nDeviceW - bx) * PropH;
  5060. double tempX = by * PropW;
  5061. //pageSerial //点阵IP地址 与打印的页面关联
  5062. if (APP.PageContextData.currpage > 0)
  5063. {
  5064. Dispatcher.Invoke(new Action(() =>
  5065. {
  5066. float Pressure = bPress / 100f;
  5067. //myblackboard.changepages(testX, testY,false);
  5068. if (bPress > 0)
  5069. {
  5070. myblackboard.changepages(tempX, tempY, false, Color, PenSize, APP.PageContextData.currpage - 1, Pressure);
  5071. }
  5072. #region 设置滚动条位置
  5073. //点在显示页面上方
  5074. if (tempY < ScroMain.VerticalOffset)
  5075. {
  5076. //滚动条当前位置
  5077. double RollCurrentLocation = ScroMain.VerticalOffset;
  5078. //向上滚动至以点为中心需要滚动的距离
  5079. double UpRoll = (RollCurrentLocation - tempY) + (ScroMain.ActualHeight / 2);
  5080. //如果小于0则等于0
  5081. double RollLocation = RollCurrentLocation - UpRoll;
  5082. if (RollLocation < 0)
  5083. {
  5084. RollLocation = 0;
  5085. }
  5086. ////滚动条实际偏移量
  5087. //double RollOffset = RollCurrentLocation - RollLocation;
  5088. ScroMain.ScrollToVerticalOffset(RollLocation);
  5089. }
  5090. //点在显示页面下方
  5091. if (tempY > ScroMain.VerticalOffset + ScroMain.ActualHeight)
  5092. {
  5093. //滚动条当前位置
  5094. double RollCurrentLocation = ScroMain.VerticalOffset;
  5095. //向下滚动至以点为中心需要滚动的距离
  5096. double DownRoll = (tempY - RollCurrentLocation) - (ScroMain.ActualHeight / 2);
  5097. //如果小于0则等于0
  5098. double RollLocation = RollCurrentLocation + DownRoll;
  5099. //滚动条最大滚动值
  5100. double ScrollbarMaxNum = GridM.ActualHeight - ScroMain.ActualHeight;
  5101. if (RollLocation > ScrollbarMaxNum)
  5102. {
  5103. RollLocation = ScrollbarMaxNum;
  5104. }
  5105. ////滚动条实际偏移量
  5106. //double RollOffset = RollLocation-RollCurrentLocation;
  5107. ScroMain.ScrollToVerticalOffset(RollLocation);
  5108. }
  5109. #endregion 设置滚动条位置
  5110. if (tempX > 0 && tempY > 0)
  5111. {
  5112. //System.Windows.Point getP = blackboard_canvas.PointToScreen(new System.Windows.Point(testX, testY));
  5113. System.Windows.Point getP = ScroMain.PointToScreen(new System.Windows.Point(tempX, tempY - ScroMain.VerticalOffset));
  5114. SetCursorPos((int)getP.X, (int)getP.Y);
  5115. }
  5116. }));
  5117. }
  5118. }
  5119. /// <summary>
  5120. /// 判断是否有设备连接
  5121. /// </summary>
  5122. public void CheckUsbConnect()
  5123. {
  5124. usbIsConnected = false;
  5125. Thread.Sleep(200);
  5126. int nDeviceCount = robotpenController.GetInstance()._GetDeviceCount();
  5127. if (APP.IsOutputInfoLog)
  5128. {
  5129. LogHelper.WriteInfoLog(string.Format("当前有 {0} 个设备", nDeviceCount));
  5130. }
  5131. if (nDeviceCount > 0)
  5132. {
  5133. //this.listView1.BeginUpdate();
  5134. for (int i = 0; i < nDeviceCount; ++i)
  5135. {
  5136. ushort npid = 0;
  5137. ushort nvid = 0;
  5138. string strDeviceName = string.Empty;
  5139. eDeviceType dtype = eDeviceType.Unknow;
  5140. if (robotpenController.GetInstance()._GetAvailableDevice(i, ref npid, ref nvid, ref strDeviceName, ref dtype))
  5141. {
  5142. if (!usbIsConnected)
  5143. {
  5144. usbIsConnected = true;
  5145. deviceType = dtype;
  5146. robotpenController.GetInstance()._ConnectInitialize(deviceType, IntPtr.Zero);
  5147. int nRes = robotpenController.GetInstance()._ConnectOpen();
  5148. if (nRes != 0)
  5149. {
  5150. //LogHelper.WriteInfoLog(string.Format(@"x={0},y={1},s={2},p={3}", bx, by, bPenStatus, bPress));
  5151. LogHelper.WriteErrLog("设备自动连接失败,请重新插拔设备或尝试手动连接!", null);
  5152. usbIsConnected = false;
  5153. break;
  5154. }
  5155. //robotpenController.GetInstance()._Send(cmdId.SwitchMode);
  5156. robotpenController.GetInstance()._Send(cmdId.GetConfig);
  5157. APP.BoardStatus = true;
  5158. try
  5159. {
  5160. int banWidth = robotpenController.GetInstance().getWidth();
  5161. int banHeight = robotpenController.GetInstance().getHeight();
  5162. if (banWidth > 0 && banHeight > 0)
  5163. {
  5164. if (banWidth > banHeight)
  5165. {
  5166. m_nDeviceW = banWidth;
  5167. m_nDeviceH = banHeight;
  5168. }
  5169. else
  5170. {
  5171. m_nDeviceW = banHeight;
  5172. m_nDeviceH = banWidth;
  5173. }
  5174. }
  5175. if (APP.IsOutputInfoLog)
  5176. {
  5177. LogHelper.WriteInfoLog(string.Format("手写板宽度为:{0} 高度为:{1}", m_nDeviceW, m_nDeviceH));
  5178. }
  5179. }
  5180. catch (Exception ex)
  5181. {
  5182. LogHelper.WriteErrLog("手写板大小获取失败:" + ex.Message, ex);
  5183. }
  5184. UpdateDevStatus();
  5185. if (APP.IsOutputInfoLog)
  5186. {
  5187. LogHelper.WriteInfoLog(string.Format("设备类型:{0}", deviceType.ToString()));
  5188. }
  5189. new Thread(new ThreadStart(new Action(() =>
  5190. {
  5191. Thread.Sleep(500);
  5192. robotpenController.GetInstance()._Send(cmdId.SearchMode);
  5193. }))).Start();
  5194. }
  5195. }
  5196. }
  5197. }
  5198. else
  5199. {
  5200. APP.BoardStatus = false;
  5201. UpdateDevStatus();
  5202. }
  5203. }
  5204. /// <summary>
  5205. /// 按键回调函数
  5206. /// </summary>
  5207. /// <param name="Value"></param>
  5208. private void Form1_keyPressEvt(eKeyPress Value)
  5209. {
  5210. Dispatcher.Invoke(new Action(() =>
  5211. {
  5212. switch (Value)
  5213. {
  5214. case eKeyPress.CLICK:
  5215. break;
  5216. case eKeyPress.DBCLICK:
  5217. break;
  5218. case eKeyPress.PAGEUP:
  5219. last_button_Click(null, null);
  5220. break;
  5221. case eKeyPress.PAGEDOWN:
  5222. next_btn_Click(null, null);
  5223. break;
  5224. case eKeyPress.CREATEPAGE://关机键
  5225. break;
  5226. case eKeyPress.KEY_A:
  5227. break;
  5228. case eKeyPress.KEY_B:
  5229. break;
  5230. case eKeyPress.KEY_C:
  5231. break;
  5232. case eKeyPress.KEY_D:
  5233. break;
  5234. case eKeyPress.KEY_E:
  5235. break;
  5236. case eKeyPress.KEY_F:
  5237. break;
  5238. case eKeyPress.KEY_UP:
  5239. last_button_Click(null, null);
  5240. break;
  5241. case eKeyPress.KEY_DOWN:
  5242. next_btn_Click(null, null);
  5243. break;
  5244. case eKeyPress.KEY_YES:
  5245. break;
  5246. case eKeyPress.KEY_NO:
  5247. break;
  5248. case eKeyPress.KEY_CANCEL:
  5249. break;
  5250. case eKeyPress.KEY_OK:
  5251. break;
  5252. case eKeyPress.PAGEUPCLICK://上一页
  5253. last_button_Click(null, null);
  5254. break;
  5255. case eKeyPress.PAGEUPDBCLICK://双击上一页
  5256. break;
  5257. case eKeyPress.PAGEUPPRESS://长按上一页
  5258. break;
  5259. case eKeyPress.PAGEDOWNCLICK://下一页
  5260. next_btn_Click(null, null);
  5261. break;
  5262. case eKeyPress.PAGEDOWNDBCLICK://双击下一页
  5263. break;
  5264. case eKeyPress.PAGEDOWNPRESS://长按下一页
  5265. break;
  5266. }
  5267. }));
  5268. }
  5269. #endregion 罗博智慧笔
  5270. /// <summary>
  5271. /// 更新设备状态显示
  5272. /// </summary>
  5273. public void UpdateDevStatus()
  5274. {
  5275. if (APP.BoardStatus && (APP.PenStatus || APP.TQLPenStatus))
  5276. {
  5277. Dispatcher.Invoke(new Action(() =>
  5278. {
  5279. txbNotConnected.Text = "笔/板已连接";
  5280. txbNotConnecteds.Text = "笔/板已连接";
  5281. }));
  5282. }
  5283. else if (APP.BoardStatus)
  5284. {
  5285. Dispatcher.Invoke(new Action(() =>
  5286. {
  5287. txbNotConnected.Text = "手写板已连接";
  5288. txbNotConnecteds.Text = "手写板已连接";
  5289. }));
  5290. }
  5291. else if (APP.PenStatus)
  5292. {
  5293. Dispatcher.Invoke(new Action(() =>
  5294. {
  5295. txbNotConnected.Text = "智能笔已连接";
  5296. txbNotConnecteds.Text = "智能笔已连接";
  5297. }));
  5298. }
  5299. else if (APP.TQLPenStatus)
  5300. {
  5301. Dispatcher.Invoke(new Action(() =>
  5302. {
  5303. txbNotConnected.Text = "智能笔已连接";
  5304. txbNotConnecteds.Text = "智能笔已连接";
  5305. }));
  5306. }
  5307. else
  5308. {
  5309. Dispatcher.Invoke(new Action(() =>
  5310. {
  5311. txbNotConnected.Text = "未连接";
  5312. txbNotConnecteds.Text = "未连接";
  5313. }));
  5314. }
  5315. }
  5316. #endregion 写字板模式
  5317. #region 腾千里手写笔
  5318. /// <summary>
  5319. /// 是否在书写
  5320. /// </summary>
  5321. private bool isTQLPenDown = false;
  5322. /// <summary>
  5323. /// TQL点阵笔宽高
  5324. /// </summary>
  5325. private static float TQLA4_WIDTH = (float)2480 / (float)300 * (float)25.4 / (float)1.524; //(float)1075 / (float)150 * (float)25.4 / (float)1.524; //OID4
  5326. private static float TQLA4_HEIGHT = (float)3509 / (float)300 * (float)25.4 / (float)1.524;//(float)1512 / (float)150 * (float)25.4 / (float)1.524;
  5327. /// <summary>
  5328. /// TQL初始化
  5329. /// </summary>
  5330. public void InitTQLPPen()
  5331. {
  5332. if (APP.TQLPenevents == null)
  5333. {
  5334. APP.TQLPenevents = new PenEvents(1);
  5335. }
  5336. else
  5337. {
  5338. APP.TQLPenevents.InToType = 1;
  5339. }
  5340. }
  5341. /// <summary>
  5342. /// 笔落下
  5343. /// </summary>
  5344. public void TQLDown()
  5345. {
  5346. isTQLPenDown = true;
  5347. if (APP.PageContextData.currpage > 0)
  5348. {
  5349. Dispatcher.Invoke(new Action(() =>
  5350. {
  5351. myblackboard.changepages(0, 0, true, Color, PenSize, APP.PageContextData.currpage - 1, 0);
  5352. }));
  5353. }
  5354. }
  5355. /// <summary>
  5356. /// 笔抬起
  5357. /// </summary>
  5358. public void TQLUp()
  5359. {
  5360. isTQLPenDown = false;
  5361. //stroke.Clear();
  5362. if (APP.PageContextData.currpage > 0)
  5363. {
  5364. Dispatcher.Invoke(new Action(() =>
  5365. {
  5366. myblackboard.changepages(0, 0, true, Color, PenSize, APP.PageContextData.currpage - 1, 0);
  5367. }));
  5368. }
  5369. }
  5370. /// <summary>
  5371. /// 笔书写
  5372. /// </summary>
  5373. /// <param name="cx"></param>
  5374. /// <param name="cy"></param>
  5375. /// <param name="force"></param>
  5376. public void TQLPenWrite(double cx, double cy, int force)
  5377. {
  5378. //判断是否是落笔后输出的坐标,在设置悬浮模式下,落笔前的悬浮坐标不绘制
  5379. if (!isTQLPenDown)
  5380. {
  5381. return;
  5382. }
  5383. double PropW = blackboard_canvas.ActualWidth / TQLA4_WIDTH;
  5384. double PropH = blackboard_canvas.ActualHeight / TQLA4_HEIGHT;
  5385. //点
  5386. double tempX = cx * PropW;
  5387. double tempY = cy * PropH;
  5388. if (APP.PageContextData.currpage > 0)
  5389. {
  5390. Dispatcher.Invoke(new Action(() =>
  5391. {
  5392. //0~1023,亦即有 1024 阶供应用软件后续应用之用,如笔锋笔触,暂无用
  5393. float Pressure = (float)force / 1023f;
  5394. myblackboard.changepages(tempX, tempY, false, Color, PenSize, APP.PageContextData.currpage - 1, Pressure);
  5395. #region 设置滚动条位置
  5396. //点在显示页面上方
  5397. if (tempY < ScroMain.VerticalOffset)
  5398. {
  5399. //滚动条当前位置
  5400. double RollCurrentLocation = ScroMain.VerticalOffset;
  5401. //向上滚动至以点为中心需要滚动的距离
  5402. double UpRoll = (RollCurrentLocation - tempY) + (ScroMain.ActualHeight / 2);
  5403. //如果小于0则等于0
  5404. double RollLocation = RollCurrentLocation - UpRoll;
  5405. if (RollLocation < 0)
  5406. {
  5407. RollLocation = 0;
  5408. }
  5409. ////滚动条实际偏移量
  5410. //double RollOffset = RollCurrentLocation - RollLocation;
  5411. ScroMain.ScrollToVerticalOffset(RollLocation);
  5412. }
  5413. //点在显示页面下方
  5414. if (tempY > ScroMain.VerticalOffset + ScroMain.ActualHeight)
  5415. {
  5416. //滚动条当前位置
  5417. double RollCurrentLocation = ScroMain.VerticalOffset;
  5418. //向下滚动至以点为中心需要滚动的距离
  5419. double DownRoll = (tempY - RollCurrentLocation) - (ScroMain.ActualHeight / 2);
  5420. //如果小于0则等于0
  5421. double RollLocation = RollCurrentLocation + DownRoll;
  5422. //滚动条最大滚动值
  5423. double ScrollbarMaxNum = GridM.ActualHeight - ScroMain.ActualHeight;
  5424. if (RollLocation > ScrollbarMaxNum)
  5425. {
  5426. RollLocation = ScrollbarMaxNum;
  5427. }
  5428. ////滚动条实际偏移量
  5429. //double RollOffset = RollLocation-RollCurrentLocation;
  5430. ScroMain.ScrollToVerticalOffset(RollLocation);
  5431. }
  5432. #endregion 设置滚动条位置
  5433. if (tempX > 0 && tempY > 0)
  5434. {
  5435. System.Windows.Point getP = ScroMain.PointToScreen(new System.Windows.Point(tempX, tempY - ScroMain.VerticalOffset));
  5436. SetCursorPos((int)getP.X, (int)getP.Y);
  5437. }
  5438. }));
  5439. }
  5440. }
  5441. #endregion 腾千里手写笔
  5442. #region 图片拉伸移动
  5443. private System.Windows.Point initialPoint;
  5444. /// <summary>
  5445. /// 隐藏图片四个点和线
  5446. /// </summary>
  5447. private void HideAngleBorder()
  5448. {
  5449. RectLeftUp.Visibility = Visibility.Hidden;
  5450. RectRightUp.Visibility = Visibility.Hidden;
  5451. RectLeftDown.Visibility = Visibility.Hidden;
  5452. RectRightDown.Visibility = Visibility.Hidden;
  5453. RectImgBorder.Visibility = Visibility.Hidden;
  5454. }
  5455. private void ShowAngleBorder()
  5456. {
  5457. PointLocation();
  5458. RectLeftUp.Visibility = Visibility.Visible;
  5459. RectRightUp.Visibility = Visibility.Visible;
  5460. RectLeftDown.Visibility = Visibility.Visible;
  5461. RectRightDown.Visibility = Visibility.Visible;
  5462. RectImgBorder.Visibility = Visibility.Visible;
  5463. }
  5464. /// <summary>
  5465. /// 确定四个点和边框的位置大小
  5466. /// </summary>
  5467. private void PointLocation()
  5468. {
  5469. RectImgBorder.Width = imgCanvas.ActualWidth + 10.0;
  5470. RectImgBorder.Height = imgCanvas.ActualHeight + 10.0;
  5471. RectImgBorder.Margin = new Thickness(imgCanvas.Margin.Left - 5.0, imgCanvas.Margin.Top - 5.0, 0, 0);
  5472. Canvas.SetLeft(RectLeftUp, imgCanvas.Margin.Left - 10.0);
  5473. Canvas.SetTop(RectLeftUp, imgCanvas.Margin.Top - 10.0);
  5474. Canvas.SetLeft(RectRightUp, imgCanvas.Margin.Left + imgCanvas.ActualWidth - 10.0);
  5475. Canvas.SetTop(RectRightUp, imgCanvas.Margin.Top - 10.0);
  5476. Canvas.SetLeft(RectLeftDown, imgCanvas.Margin.Left - 10.0);
  5477. Canvas.SetTop(RectLeftDown, imgCanvas.Margin.Top + imgCanvas.ActualHeight - 10.0);
  5478. Canvas.SetLeft(RectRightDown, imgCanvas.Margin.Left + imgCanvas.ActualWidth - 10.0);
  5479. Canvas.SetTop(RectRightDown, imgCanvas.Margin.Top + imgCanvas.ActualHeight - 10.0);
  5480. }
  5481. private void PicEMap_MouseDown(object sender, MouseButtonEventArgs e)
  5482. {
  5483. System.Windows.Point point = e.GetPosition(imgCanvas);
  5484. initialPoint = point;
  5485. HideAngleBorder();
  5486. }
  5487. private void imgCanvas_MouseMove(object sender, System.Windows.Input.MouseEventArgs e)
  5488. {
  5489. if (e.LeftButton == MouseButtonState.Pressed && mouseDown)
  5490. {
  5491. System.Windows.Point point = e.GetPosition(imgCanvas);
  5492. imgCanvas.Margin = new Thickness(imgCanvas.Margin.Left + (point.X - initialPoint.X), imgCanvas.Margin.Top + (point.Y - initialPoint.Y), 0, 0);
  5493. APP.PageDrawList[APP.PageContextData.currpage - 1].ImageLocation = new TranslateTransform
  5494. {
  5495. X = imgCanvas.Margin.Left,
  5496. Y = imgCanvas.Margin.Top
  5497. };
  5498. APP.PageDrawList[APP.PageContextData.currpage - 1].ImageSizes = new ScaleTransform
  5499. {
  5500. CenterX = imgCanvas.ActualWidth,
  5501. CenterY = imgCanvas.ActualHeight
  5502. };
  5503. APP.PageDrawList[APP.PageContextData.currpage - 1].IsImageLocation = false;
  5504. }
  5505. }
  5506. private void imgCanvas_MouseUp(object sender, MouseButtonEventArgs e)
  5507. {
  5508. if (mouseDown)
  5509. {
  5510. ShowAngleBorder();
  5511. }
  5512. }
  5513. private System.Drawing.PointF imgRightDown;
  5514. /// <summary>
  5515. /// 设置控件最上层
  5516. /// </summary>
  5517. /// <param name="element"></param>
  5518. public void BringToFront(Thumb element)//图片置于最顶层显示
  5519. {
  5520. if (element == null)
  5521. {
  5522. return;
  5523. }
  5524. Canvas parent = element.Parent as Canvas;
  5525. if (parent == null)
  5526. {
  5527. return;
  5528. }
  5529. int maxZ = parent.Children.OfType<UIElement>()//linq语句,取Zindex的最大值
  5530. .Where(x => x != element)
  5531. .Select(x => Canvas.GetZIndex(x))
  5532. .Max();
  5533. Canvas.SetZIndex(element, maxZ + 1);
  5534. }
  5535. private void RectRightUp_DragStarted(object sender, System.Windows.Controls.Primitives.DragStartedEventArgs e)
  5536. {
  5537. try
  5538. {
  5539. Thumb thu = (Thumb)sender;
  5540. BringToFront(thu);
  5541. imgRightDown = new System.Drawing.PointF((float)(imgCanvas.Margin.Left + imgCanvas.ActualWidth), (float)(imgCanvas.Margin.Top + imgCanvas.ActualHeight));
  5542. HideAngleBorder();
  5543. switch (thu.Name)
  5544. {
  5545. case "RectLeftUp":
  5546. RectLeftUp.Visibility = Visibility.Visible;
  5547. break;
  5548. case "RectRightUp":
  5549. RectRightUp.Visibility = Visibility.Visible;
  5550. break;
  5551. case "RectLeftDown":
  5552. RectLeftDown.Visibility = Visibility.Visible;
  5553. break;
  5554. case "RectRightDown":
  5555. RectRightDown.Visibility = Visibility.Visible;
  5556. break;
  5557. default:
  5558. break;
  5559. }
  5560. }
  5561. catch (Exception ex)
  5562. {
  5563. MessageWindow.Show(ex.Message);
  5564. }
  5565. }
  5566. private void RectRightUp_DragDelta(object sender, System.Windows.Controls.Primitives.DragDeltaEventArgs e)
  5567. {
  5568. try
  5569. {
  5570. if (mouseDown)
  5571. {
  5572. Thumb thu = (Thumb)sender;
  5573. #region 判断是否超出 暂无
  5574. double plul = Canvas.GetLeft(RectLeftUp);
  5575. double plut = Canvas.GetTop(RectLeftUp);
  5576. double prdl = Canvas.GetLeft(RectRightDown);
  5577. double prdt = Canvas.GetTop(RectRightDown);
  5578. #endregion 判断是否超出 暂无
  5579. //Canvas.SetLeft(thu, Canvas.GetLeft(thu) + e.HorizontalChange);
  5580. //Canvas.SetTop(thu, Canvas.GetTop(thu) + e.VerticalChange);
  5581. double imgW = 0;
  5582. double imgH = 0;
  5583. double imgX = 0;
  5584. double imgY = 0;
  5585. switch (thu.Name)
  5586. {
  5587. case "RectLeftUp":
  5588. #region 左上
  5589. imgW = imgRightDown.X - (Mouse.GetPosition(GridM).X);
  5590. imgH = imgRightDown.Y - (Mouse.GetPosition(GridM).Y);
  5591. imgX = 0;
  5592. imgY = 0;
  5593. if (imgW < 50)
  5594. {
  5595. imgCanvas.Width = 50;
  5596. imgX = imgCanvas.Margin.Left;
  5597. Canvas.SetLeft(thu, Canvas.GetLeft(RectRightDown) - 50);
  5598. }
  5599. else
  5600. {
  5601. imgCanvas.Width = imgW;
  5602. imgX = Mouse.GetPosition(GridM).X;
  5603. Canvas.SetLeft(thu, Canvas.GetLeft(thu) + e.HorizontalChange);
  5604. }
  5605. if (imgH < 50)
  5606. {
  5607. imgCanvas.Height = 50;
  5608. imgY = imgCanvas.Margin.Top;
  5609. Canvas.SetTop(thu, Canvas.GetTop(RectRightDown) - 50);
  5610. }
  5611. else
  5612. {
  5613. imgCanvas.Height = imgH;
  5614. imgY = Mouse.GetPosition(GridM).Y;
  5615. Canvas.SetTop(thu, Canvas.GetTop(thu) + e.VerticalChange);
  5616. }
  5617. imgCanvas.Margin = new Thickness(imgX, imgY, 0, 0);
  5618. #endregion 左上
  5619. break;
  5620. case "RectRightUp":
  5621. #region 右上
  5622. imgW = Mouse.GetPosition(GridM).X - imgCanvas.Margin.Left;
  5623. imgH = imgRightDown.Y - (Mouse.GetPosition(GridM).Y);
  5624. imgX = 0;
  5625. imgY = 0;
  5626. if (imgW < 50)
  5627. {
  5628. imgCanvas.Width = 50;
  5629. imgX = imgCanvas.Margin.Left;
  5630. Canvas.SetLeft(thu, Canvas.GetLeft(RectLeftUp) + 50);
  5631. }
  5632. else
  5633. {
  5634. imgCanvas.Width = imgW;
  5635. imgX = imgCanvas.Margin.Left;
  5636. Canvas.SetLeft(thu, Canvas.GetLeft(thu) + e.HorizontalChange);
  5637. }
  5638. if (imgH < 50)
  5639. {
  5640. imgCanvas.Height = 50;
  5641. imgY = imgCanvas.Margin.Top;
  5642. Canvas.SetTop(thu, Canvas.GetTop(RectRightDown) - 50);
  5643. }
  5644. else
  5645. {
  5646. imgCanvas.Height = imgH;
  5647. imgY = Mouse.GetPosition(GridM).Y;
  5648. Canvas.SetTop(thu, Canvas.GetTop(thu) + e.VerticalChange);
  5649. }
  5650. imgCanvas.Margin = new Thickness(imgX, imgY, 0, 0);
  5651. #endregion 右上
  5652. break;
  5653. case "RectLeftDown":
  5654. #region 左下
  5655. imgW = imgRightDown.X - (Mouse.GetPosition(GridM).X);
  5656. imgH = Mouse.GetPosition(GridM).Y - imgCanvas.Margin.Top;
  5657. imgX = 0;
  5658. imgY = 0;
  5659. if (imgW < 50)
  5660. {
  5661. imgCanvas.Width = 50;
  5662. imgX = imgCanvas.Margin.Left;
  5663. Canvas.SetLeft(thu, Canvas.GetLeft(RectRightDown) - 50);
  5664. }
  5665. else
  5666. {
  5667. imgCanvas.Width = imgW;
  5668. imgX = Mouse.GetPosition(GridM).X;
  5669. Canvas.SetLeft(thu, Canvas.GetLeft(thu) + e.HorizontalChange);
  5670. }
  5671. if (imgH < 50)
  5672. {
  5673. imgCanvas.Height = 50;
  5674. imgY = imgCanvas.Margin.Top;
  5675. Canvas.SetTop(thu, Canvas.GetTop(RectLeftUp) + 50);
  5676. }
  5677. else
  5678. {
  5679. imgCanvas.Height = imgH;
  5680. imgY = imgCanvas.Margin.Top;
  5681. Canvas.SetTop(thu, Canvas.GetTop(thu) + e.VerticalChange);
  5682. }
  5683. imgCanvas.Margin = new Thickness(imgX, imgY, 0, 0);
  5684. //imgCanvas.Width = imgRightDown.X - (Mouse.GetPosition(GridM).X);
  5685. //imgCanvas.Height = Mouse.GetPosition(GridM).Y - imgCanvas.Margin.Top;
  5686. //imgCanvas.Margin = new Thickness(Mouse.GetPosition(GridM).X, imgCanvas.Margin.Top, 0, 0);
  5687. #endregion 左下
  5688. break;
  5689. case "RectRightDown":
  5690. #region 右下
  5691. imgW = Mouse.GetPosition(GridM).X - imgCanvas.Margin.Left;
  5692. imgH = Mouse.GetPosition(GridM).Y - imgCanvas.Margin.Top;
  5693. if (imgW < 50)
  5694. {
  5695. imgCanvas.Width = 50;
  5696. Canvas.SetLeft(thu, Canvas.GetLeft(RectLeftUp) + 50);
  5697. }
  5698. else
  5699. {
  5700. imgCanvas.Width = imgW;
  5701. Canvas.SetLeft(thu, Canvas.GetLeft(thu) + e.HorizontalChange);
  5702. }
  5703. if (imgH < 50)
  5704. {
  5705. imgCanvas.Height = 50;
  5706. Canvas.SetTop(thu, Canvas.GetTop(RectLeftUp) + 50);
  5707. }
  5708. else
  5709. {
  5710. imgCanvas.Height = imgH;
  5711. Canvas.SetTop(thu, Canvas.GetTop(thu) + e.VerticalChange);
  5712. }
  5713. //imgCanvas.Margin = new Thickness(imgX, imgY, 0, 0);
  5714. //imgCanvas.Width += e.HorizontalChange;
  5715. //imgCanvas.Height += e.VerticalChange;
  5716. #endregion 右下
  5717. break;
  5718. default:
  5719. break;
  5720. }
  5721. APP.PageDrawList[APP.PageContextData.currpage - 1].ImageLocation = new TranslateTransform
  5722. {
  5723. X = imgCanvas.Margin.Left,
  5724. Y = imgCanvas.Margin.Top
  5725. };
  5726. APP.PageDrawList[APP.PageContextData.currpage - 1].ImageSizes = new ScaleTransform
  5727. {
  5728. CenterX = imgCanvas.ActualWidth,
  5729. CenterY = imgCanvas.ActualHeight
  5730. };
  5731. APP.PageDrawList[APP.PageContextData.currpage - 1].IsImageLocation = false;
  5732. }
  5733. //lbl1.Content = imgCanvas.Margin.Left + "," + imgCanvas.Margin.Top;
  5734. //lbl2.Content = (imgCanvas.Margin.Left+ imgCanvas.Width) +"," + imgCanvas.Margin.Top;
  5735. //lbl3.Content = imgCanvas.Margin.Left + "," + (imgCanvas.Margin.Top+ imgCanvas.Height);
  5736. //lbl4.Content= (imgCanvas.Margin.Left + imgCanvas.Width )+ "," + (imgCanvas.Margin.Top + imgCanvas.Height);
  5737. }
  5738. catch (Exception)
  5739. {
  5740. MessageWindow.Show("图片过小!");
  5741. }
  5742. }
  5743. private void RectRightUp_DragCompleted(object sender, System.Windows.Controls.Primitives.DragCompletedEventArgs e)
  5744. {
  5745. ShowAngleBorder();
  5746. }
  5747. /// <summary>
  5748. /// 点击标题栏 隐藏截图的四个点和线
  5749. /// </summary>
  5750. /// <param name="sender"></param>
  5751. /// <param name="e"></param>
  5752. private void Grid_MouseDown(object sender, MouseButtonEventArgs e)
  5753. {
  5754. HideAngleBorder();
  5755. }
  5756. /// <summary>
  5757. /// 鼠标左键点击事件
  5758. /// </summary>
  5759. /// <param name="sender"></param>
  5760. /// <param name="e"></param>
  5761. private void Window_MouseLeftButtonDown_1(object sender, MouseButtonEventArgs e)
  5762. {
  5763. if (RectImgBorder.Visibility != Visibility.Hidden)
  5764. {
  5765. HideAngleBorder();
  5766. }
  5767. }
  5768. #endregion 图片拉伸移动
  5769. #region 方法
  5770. /// <summary>
  5771. /// 录屏 录制 截图 导入文档 增加 主页面显示
  5772. /// </summary>
  5773. private void Record()
  5774. {
  5775. PageHide();
  5776. GridMain.Visibility = Visibility.Visible;
  5777. GridRecordingTitle.Visibility = Visibility.Visible;
  5778. if (APP.PageContextData.pagenum > 0)
  5779. {
  5780. GridPage.Visibility = Visibility.Visible;
  5781. }
  5782. DataContext = APP.PageContextData;
  5783. }
  5784. /// <summary>
  5785. /// 设置页面显示
  5786. /// </summary>
  5787. private void SetUp()
  5788. {
  5789. }
  5790. #endregion 方法
  5791. #region 跳转
  5792. /// <summary>
  5793. /// 跳转
  5794. /// </summary>
  5795. /// <param name="sender"></param>
  5796. /// <param name="e"></param>
  5797. private void CbxPageList_SelectionChanged(object sender, SelectionChangedEventArgs e)
  5798. {
  5799. #region 安全
  5800. if (CbxPageList.SelectedValue == null)
  5801. {
  5802. return;
  5803. }
  5804. if (APP.PageContextData.currpage == int.Parse(CbxPageList.SelectedValue.ToString()))
  5805. {
  5806. return;
  5807. }
  5808. #endregion 安全
  5809. int JumpPage;
  5810. try
  5811. {
  5812. JumpPage = int.Parse(CbxPageList.SelectedValue.ToString());
  5813. }
  5814. catch (Exception)
  5815. {
  5816. MessageWindow.Show("操作有误!请输入有效的页码!");
  5817. return;
  5818. }
  5819. if (JumpPage < 1)
  5820. {
  5821. JumpPage = 1;
  5822. }
  5823. if (JumpPage > int.Parse(txbTotalpage.Text))
  5824. {
  5825. JumpPage = int.Parse(txbTotalpage.Text);
  5826. }
  5827. #region 跳转
  5828. APP.PageContextData.currpage = JumpPage;
  5829. JumpPageClick();
  5830. #endregion 跳转
  5831. }
  5832. #endregion 跳转
  5833. #region 原跳转
  5834. /// <summary>
  5835. /// 跳转页
  5836. /// </summary>
  5837. /// <param name="sender"></param>
  5838. /// <param name="e"></param>
  5839. private void txbCurrpage_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
  5840. {
  5841. if (e.ClickCount == 2)
  5842. {
  5843. try
  5844. {
  5845. if (int.Parse(txbCurrpage.Text) > 0)
  5846. {
  5847. //txtJump.Text = txbCurrpage.Text;
  5848. //txbCurrpage.Visibility = Visibility.Hidden;
  5849. //txtJump.Visibility = Visibility.Visible;
  5850. //BtnJumpPage.Visibility = Visibility.Visible;
  5851. //txtJump.Focus();
  5852. //txtJump.SelectAll();
  5853. }
  5854. }
  5855. catch (Exception)
  5856. {
  5857. }
  5858. }
  5859. }
  5860. /// <summary>
  5861. /// 确定跳转
  5862. /// </summary>
  5863. /// <param name="sender"></param>
  5864. /// <param name="e"></param>
  5865. private void BtnJumpPage_Click(object sender, RoutedEventArgs e)
  5866. {
  5867. int JumpPage = 0;
  5868. //try
  5869. //{
  5870. // JumpPage = int.Parse(txtJump.Text);
  5871. //}
  5872. //catch (Exception ex)
  5873. //{
  5874. // MessageWindow.Show("操作有误!请输入有效的页码!");
  5875. // return;
  5876. //}
  5877. if (JumpPage < 1)
  5878. {
  5879. JumpPage = 1;
  5880. }
  5881. if (JumpPage > int.Parse(txbTotalpage.Text))
  5882. {
  5883. JumpPage = int.Parse(txbTotalpage.Text);
  5884. }
  5885. #region 跳转
  5886. APP.PageContextData.currpage = JumpPage;
  5887. JumpPageClick();
  5888. #endregion 跳转
  5889. //txbCurrpage.Visibility = Visibility.Visible;
  5890. //txtJump.Visibility = Visibility.Hidden;
  5891. //BtnJumpPage.Visibility = Visibility.Hidden;
  5892. }
  5893. /// <summary>
  5894. /// 只允许输入数字
  5895. /// </summary>
  5896. /// <param name="sender"></param>
  5897. /// <param name="e"></param>
  5898. private void txtJump_PreviewTextInput(object sender, TextCompositionEventArgs e)
  5899. {
  5900. Regex re = new Regex("[^0-9.-]+");
  5901. e.Handled = re.IsMatch(e.Text);
  5902. }
  5903. private void txtJump_KeyDown(object sender, System.Windows.Input.KeyEventArgs e)
  5904. {
  5905. if (e.Key == Key.Enter)
  5906. {
  5907. BtnJumpPage_Click(null, null);
  5908. }
  5909. }
  5910. #endregion 原跳转
  5911. #region 打印
  5912. /// <summary>
  5913. /// 下拉框数据源
  5914. /// </summary>
  5915. public DataTable data = new DataTable();
  5916. private DataTable dtComponentsUniqueNo;
  5917. /// <summary>
  5918. /// 打印进度
  5919. /// </summary>
  5920. private System.Timers.Timer timesPrint;
  5921. /// <summary>
  5922. /// 打印消息
  5923. /// </summary>
  5924. private System.Timers.Timer timesPrintMsg;
  5925. private double wit = 0;
  5926. private double hei = 0;
  5927. /// <summary>
  5928. /// 打印状态消息
  5929. /// </summary>
  5930. private string PrintMsg = "打印中";
  5931. /// <summary>
  5932. /// 打印初始化
  5933. /// </summary>
  5934. public void InitPrint()
  5935. {
  5936. ResizeMode = ResizeMode.NoResize;
  5937. List<string> defaList = LatticeFileHelper.GetPrinterList(out string defa);
  5938. if (defaList.Count > 0)
  5939. {
  5940. data.Columns.Add("Value");
  5941. data.Columns.Add("Key");
  5942. for (int i = 0; i < defaList.Count; i++)
  5943. {
  5944. //创建一行
  5945. DataRow row = data.NewRow();
  5946. //将此行添加到table中
  5947. data.Rows.Add(row);
  5948. data.Rows[i]["Value"] = defaList[i];
  5949. data.Rows[i]["Key"] = i.ToString();
  5950. }
  5951. dtComponentsUniqueNo = data.DefaultView.ToTable();
  5952. cmbClass.ItemsSource = dtComponentsUniqueNo.DefaultView;
  5953. cmbClass.SelectedIndex = 0;
  5954. }
  5955. Dictionary<int, int> dicItem = new Dictionary<int, int>();
  5956. dicItem.Add(0, 600);
  5957. dicItem.Add(1, 1200);
  5958. CbxDpi.ItemsSource = dicItem;
  5959. CbxDpi.SelectedIndex = 0;
  5960. Dictionary<int, string> dictypeItem = new Dictionary<int, string>();
  5961. dictypeItem.Add(0, "2x2");
  5962. dictypeItem.Add(1, "3x3");
  5963. dictypeItem.Add(2, "4x4");
  5964. CbxType.ItemsSource = dictypeItem;
  5965. CbxType.SelectedIndex = 0;
  5966. TQLInit();
  5967. }
  5968. /// <summary>
  5969. /// 初始化页面
  5970. /// </summary>
  5971. /// <param name="_imgPath"></param>
  5972. /// <param name="_wit"></param>
  5973. /// <param name="_hei"></param>
  5974. public void InitializePrint(string _imgPath, double _wit, double _hei)
  5975. {
  5976. wit = _wit;
  5977. hei = _hei;
  5978. if (!string.IsNullOrWhiteSpace(_imgPath))
  5979. {
  5980. imgPri.Source = new BitmapImage(new Uri(_imgPath));
  5981. }
  5982. else
  5983. {
  5984. imgPri.Source = null;
  5985. }
  5986. GridPrintMask.Visibility = Visibility.Collapsed;
  5987. }
  5988. #region TQL打印
  5989. /// <summary>
  5990. /// 授权文件位置
  5991. /// </summary>
  5992. private string TQLAuthorizationPath;
  5993. /// <summary>
  5994. /// 授权码
  5995. /// </summary>
  5996. private string gKeyStr;
  5997. private TmatrixClass TMC = new TmatrixClass();
  5998. public static string gPrintFileName;
  5999. //string gDirectory = Application.StartupPath;
  6000. //string gFileName = "";
  6001. private bool gbInitDone = false;
  6002. //string gUserName = "";
  6003. //string gPassword = "";
  6004. //private string gEKeyStr;
  6005. private iTextSharp.text.Document document;
  6006. private enum TMATRIX_POINT_TYPE
  6007. {
  6008. TmatrixPointType_2x2 = 0, // 2x2 Point Type
  6009. TmatrixPointType_3x3 = 1, // 3x3 Point Type
  6010. };
  6011. private enum TMATRIX_OBJECT_TYPE
  6012. {
  6013. TMATRIX_OT_ElementCode = 0, // 此类型对象的Index范围是:75497472~83886079(十六进制为:0x04800000~0x04ffffff)
  6014. TMATRIX_OT_PositionCode, // 此类型对象没有Index
  6015. };
  6016. /// <summary>
  6017. /// TQL初始化打印
  6018. /// </summary>
  6019. private void TQLInit()
  6020. {
  6021. ///初始化
  6022. if (TMC.TmatrixInitialize() == false)
  6023. {
  6024. //MessageBox.Show(this, "点阵码初始化失败!", "生成点阵码", MessageBoxButtons.OK, MessageBoxIcon.Error);
  6025. //Close();
  6026. }
  6027. else
  6028. {
  6029. gbInitDone = true;
  6030. }
  6031. document = new iTextSharp.text.Document(iTextSharp.text.PageSize.A4, 0, 0, 0, 0);
  6032. try
  6033. {
  6034. TQLAuthorizationPath = FileToolsCommon.GetFileAbsolutePath("/LatticeXML/S0_O000_B0000_P000-255.tmx");
  6035. StreamReader gsr = new StreamReader(TQLAuthorizationPath);
  6036. gKeyStr = gsr.ReadLine();
  6037. gsr.Close();
  6038. string KeyCheckResult = TMC.TmatrixKeyCheck_OID4(gKeyStr);
  6039. if (KeyCheckResult.Substring(0, 1) == "1")
  6040. {
  6041. MessageWindow.Show("打印服务授权过期,请联系厂家更换授权!");
  6042. LogHelper.WriteErrLog("打印服务授权过期:" + KeyCheckResult, null);
  6043. gbInitDone = false;
  6044. }
  6045. else if (KeyCheckResult.Substring(0, 1) == "0")
  6046. {
  6047. }
  6048. }
  6049. catch (Exception ex)
  6050. {
  6051. LogHelper.WriteErrLog("打印服务授权失败:" + ex.Message, ex);
  6052. MessageWindow.Show("打印服务授权失败,请联系厂家!");
  6053. gbInitDone = false;
  6054. }
  6055. }
  6056. /// <summary>
  6057. /// 铺码
  6058. /// </summary>
  6059. private bool GenerateCode(string PDFPath)
  6060. {
  6061. try
  6062. {
  6063. if (gbInitDone == false)
  6064. {
  6065. MessageWindow.Show("打印功能无法使用,无效授权。");
  6066. return false;
  6067. }
  6068. try
  6069. {
  6070. string directoryPath = FileToolsCommon.GetDirectoryName(PDFPath);
  6071. FileToolsCommon.DeleteDirectory(directoryPath + "Bg with Images/");
  6072. FileToolsCommon.DeleteDirectory(directoryPath + "Bg with Vector Images/");
  6073. FileToolsCommon.DeleteDirectory(directoryPath + "Bg without Vector Images/");
  6074. FileToolsCommon.DeleteDirectory(directoryPath + "Vector Images/");
  6075. }
  6076. catch (Exception)
  6077. {
  6078. }
  6079. int i;
  6080. for (i = 0; i < 4; i++)
  6081. {
  6082. int DPIValue = 0;
  6083. int TypeValue = 0;
  6084. try
  6085. {
  6086. DPIValue = CbxDpi.SelectedIndex;
  6087. //TypeValue = CbxType.SelectedIndex;
  6088. }
  6089. catch (Exception)
  6090. {
  6091. }
  6092. APP.gPointType[i] = TypeValue;
  6093. APP.gPointDPI[i] = DPIValue;
  6094. }
  6095. APP.gbGenerateBGWithVImage = false;
  6096. APP.gbGenerateVImage = false;
  6097. APP.gbGenerateBGWithoutVImage = false;
  6098. APP.gbGenerateBGWithImage = true;
  6099. //初始页
  6100. int SPID = 0;
  6101. bool[] bPublishImageType = new bool[4];
  6102. bPublishImageType[0] = APP.gbGenerateBGWithVImage;
  6103. bPublishImageType[1] = APP.gbGenerateVImage;
  6104. bPublishImageType[2] = APP.gbGenerateBGWithoutVImage;
  6105. bPublishImageType[3] = APP.gbGenerateBGWithImage;
  6106. PDFPath = PDFPath.Replace("/", "\\");
  6107. string sGenerateResult = TMC.GenerateTmatrixCode_OID4(gKeyStr, PDFPath, SPID, APP.gPointType, bPublishImageType, APP.gPointDPI);
  6108. if (sGenerateResult.Substring(0, 1) == "1")
  6109. {
  6110. Dispatcher.Invoke(() =>
  6111. {
  6112. MessageWindow.Show("打印功能无法使用,无效授权。");
  6113. });
  6114. return false;
  6115. }
  6116. return true;
  6117. }
  6118. catch (Exception ex)
  6119. {
  6120. Dispatcher.Invoke(() =>
  6121. {
  6122. MessageWindow.Show("打印失败:" + ex.Message);
  6123. });
  6124. return false;
  6125. }
  6126. }
  6127. #endregion TQL打印
  6128. /// <summary>
  6129. /// 打印
  6130. /// </summary>
  6131. /// <param name="sender"></param>
  6132. /// <param name="e"></param>
  6133. private void BtnPrint_Print_Click(object sender, RoutedEventArgs e)
  6134. {
  6135. if (string.IsNullOrWhiteSpace(cmbClass.Text))
  6136. {
  6137. MessageWindow.Show("请设置打印机!");
  6138. return;
  6139. }
  6140. BtnPrint.IsEnabled = false;
  6141. Thread myThread = new Thread(StartPrint);
  6142. List<string> StrList = new List<string>();
  6143. int ipdf = 102;
  6144. string imgPath = FileToolsCommon.GetFileAbsolutePath("temp/");
  6145. string tempImgPath = imgPath;
  6146. imgPath += "101.pdf";
  6147. while (File.Exists(imgPath))
  6148. {
  6149. imgPath = tempImgPath + ipdf.ToString() + ".pdf";
  6150. ipdf++;
  6151. }
  6152. StrList.Add(imgPath);
  6153. //打印数量
  6154. int PrinterNum = Convert.ToInt32(txbNumberOfCopies.Content);
  6155. StrList.Add(PrinterNum.ToString());
  6156. //打印机名称
  6157. string PrinterName = cmbClass.Text;
  6158. StrList.Add(PrinterName);
  6159. PrintMsg = "准备中";
  6160. msgnum = 0;
  6161. num = 0;
  6162. GridPrintMask.Visibility = Visibility.Visible;
  6163. myThread.Start(StrList);
  6164. timesPrint = new System.Timers.Timer(100);
  6165. timesPrint.Elapsed += Times_ElapsedClick;
  6166. timesPrint.Start();
  6167. timesPrintMsg = new System.Timers.Timer(500);
  6168. timesPrintMsg.Elapsed += TimesPrintMsg_Elapsed;
  6169. timesPrintMsg.Start();
  6170. }
  6171. private int msgnum = 0;
  6172. /// <summary>
  6173. /// 消息
  6174. /// </summary>
  6175. /// <param name="sender"></param>
  6176. /// <param name="e"></param>
  6177. private void TimesPrintMsg_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
  6178. {
  6179. if (msgnum > 5)
  6180. msgnum = 0;
  6181. else
  6182. msgnum++;
  6183. string point = "";
  6184. point = point.ToString().PadRight(msgnum, '.');
  6185. Dispatcher.Invoke(() =>
  6186. {
  6187. LabPrintMessage.Content = PrintMsg + point;
  6188. });
  6189. }
  6190. private int num = 0;
  6191. /// <summary>
  6192. /// 计时器
  6193. /// </summary>
  6194. /// <param name="sender"></param>
  6195. /// <param name="e"></param>
  6196. private void Times_ElapsedClick(object sender, System.Timers.ElapsedEventArgs e)
  6197. {
  6198. Dispatcher.Invoke(() =>
  6199. {
  6200. pgbProcess.Value = num;
  6201. lbProcess.Content = num.ToString() + "%";
  6202. if (num < 99)
  6203. {
  6204. num++;
  6205. timesPrint.Interval += (num / 2);
  6206. }
  6207. else
  6208. {
  6209. timesPrint.Stop();
  6210. }
  6211. });
  6212. }
  6213. /// <summary>
  6214. /// 开始打印
  6215. /// </summary>
  6216. private void StartPrint(object obj)
  6217. {
  6218. try
  6219. {
  6220. document = new iTextSharp.text.Document(iTextSharp.text.PageSize.A4, 0f, 0f, 0f, 0f);
  6221. PrintMsg = "生成文件";
  6222. msgnum = 0;
  6223. List<string> objStr1 = (List<string>)obj;
  6224. string SourcePath1 = objStr1[0];
  6225. try
  6226. {
  6227. SourcePath1 = SourcePath1.Replace("/", "\\");
  6228. FileStream fs = new FileStream(SourcePath1, FileMode.Create, FileAccess.ReadWrite);
  6229. document.AddAuthor("星火微课");//作者
  6230. document.AddCreationDate();//创建时候
  6231. document.AddCreator("星火微课");//创建者
  6232. document.AddSubject("点阵文件");//主题
  6233. document.AddTitle("PrintTmatrixCode");//标题
  6234. document.AddKeywords("Print");
  6235. document.AddHeader("TmatrixCode", "0");
  6236. Thread.Sleep(300);
  6237. iTextSharp.text.pdf.PdfWriter.GetInstance(document, fs);
  6238. }
  6239. catch (Exception)
  6240. {
  6241. }
  6242. document.Open();
  6243. iTextSharp.text.Image image;
  6244. for (int i = 0; i < APP.PageDrawList.Count; i++)
  6245. {
  6246. long ii = Timestamp();
  6247. string directoryPath = AppDomain.CurrentDomain.BaseDirectory + "Temp\\";
  6248. string filePathOutPut = Path.Combine(directoryPath, string.Format("print{0}{1}.jpg", ii, i));
  6249. RectangleF rectangleFs = new RectangleF();
  6250. MergerPrintImg("", filePathOutPut, rectangleFs, out string errmsg);
  6251. image = iTextSharp.text.Image.GetInstance(filePathOutPut);
  6252. if (string.IsNullOrEmpty(APP.PageDrawList[i].PageImagePath))//没有图片
  6253. {
  6254. }
  6255. else if (APP.PageDrawList[i].ImgDocumentation == true && !APP.PageDrawList[i].Type.Equals("ppt"))
  6256. {
  6257. image = iTextSharp.text.Image.GetInstance(APP.PageDrawList[i].PageImagePath);
  6258. }
  6259. else
  6260. {
  6261. RectangleF rectangleF = new RectangleF(0, 0, 0, 0);
  6262. Dispatcher.Invoke(() =>
  6263. {
  6264. rectangleF = new RectangleF
  6265. {
  6266. Width = (float)APP.PageDrawList[i].ImageSizes.CenterX,
  6267. Height = (float)APP.PageDrawList[i].ImageSizes.CenterY,
  6268. X = (float)APP.PageDrawList[i].ImageLocation.X,
  6269. Y = (float)APP.PageDrawList[i].ImageLocation.Y
  6270. };
  6271. });
  6272. string msgs = string.Empty;
  6273. bool isImg = MergerPrintImg(APP.PageDrawList[i].PageImagePath, filePathOutPut, rectangleF, out msgs);
  6274. if (isImg)
  6275. {
  6276. image = iTextSharp.text.Image.GetInstance(filePathOutPut);
  6277. }
  6278. else
  6279. {
  6280. image = iTextSharp.text.Image.GetInstance(APP.PageDrawList[i].PageImagePath);
  6281. }
  6282. }
  6283. if (image.Height > iTextSharp.text.PageSize.A4.Height)
  6284. {
  6285. image.ScaleToFit(iTextSharp.text.PageSize.A4.Width, iTextSharp.text.PageSize.A4.Height);
  6286. }
  6287. else if (image.Width > iTextSharp.text.PageSize.A4.Width)
  6288. {
  6289. image.ScaleToFit(iTextSharp.text.PageSize.A4.Width, iTextSharp.text.PageSize.A4.Height);
  6290. }
  6291. image.Alignment = iTextSharp.text.Image.ALIGN_MIDDLE;
  6292. document.NewPage();
  6293. document.Add(image);
  6294. //iTextSharp.text.Chunk c1 = new iTextSharp.text.Chunk("Hello World");
  6295. //iTextSharp.text.Phrase p1 = new iTextSharp.text.Phrase();
  6296. //p1.Leading = 150; //行间距
  6297. //document.Add(p1);
  6298. }
  6299. //Console.WriteLine("转换成功!");
  6300. document.Close();
  6301. }
  6302. catch (Exception ex)
  6303. {
  6304. Dispatcher.Invoke(() =>
  6305. {
  6306. BtnPrint.IsEnabled = true;
  6307. timesPrint.Stop();
  6308. timesPrintMsg.Stop();
  6309. GridPrintMask.Visibility = Visibility.Collapsed;
  6310. MessageWindow.Show(ex.Message);
  6311. return;
  6312. });
  6313. LogHelper.WriteErrLog("打印转换PDF失败,原因:" + ex.Message, ex);
  6314. }
  6315. List<string> objStr = (List<string>)obj;
  6316. //PDF位置
  6317. string SourcePath = objStr[0];
  6318. int PrinterNum = int.Parse(objStr[1]);
  6319. string PrinterName = objStr[2];
  6320. PrintMsg = "铺码中";
  6321. msgnum = 0;
  6322. Thread.Sleep(500);
  6323. //腾千里生成点阵文件
  6324. if (GenerateCode(SourcePath))
  6325. {
  6326. //打印机名称
  6327. string directoryPath = FileToolsCommon.GetDirectoryName(SourcePath) + "Bg with Images/";
  6328. string[] strs = FileToolsCommon.GetFileNames(directoryPath);
  6329. try
  6330. {
  6331. for (int i = 0; i < strs.Count(); i++)
  6332. {
  6333. timesPrint.Stop();
  6334. PrintMsg = "正在打印第" + (i + 1) + "/" + strs.Count() + "页中";
  6335. msgnum = 0;
  6336. num = 0;
  6337. timesPrint.Interval = 100;
  6338. timesPrint.Start();
  6339. string fileName = strs[i];
  6340. Print(fileName, PrinterName, (short)PrinterNum);
  6341. }
  6342. }
  6343. catch (Exception ex)
  6344. {
  6345. Dispatcher.Invoke(() =>
  6346. {
  6347. MessageWindow.Show("打印失败:" + ex.Message);
  6348. BtnPrint.IsEnabled = true;
  6349. timesPrint.Stop();
  6350. GridPrintMask.Visibility = Visibility.Collapsed;
  6351. return;
  6352. });
  6353. }
  6354. Dispatcher.Invoke(() =>
  6355. {
  6356. BtnPrint.IsEnabled = true;
  6357. num = 99;
  6358. timesPrint.Stop();
  6359. pgbProcess.Value = 100;
  6360. lbProcess.Content = "100%";
  6361. GridPrintMask.Visibility = Visibility.Collapsed;
  6362. MessageWindow.Show("已加入打印机队列,打印中。");
  6363. });
  6364. }
  6365. else
  6366. {
  6367. Dispatcher.Invoke(() =>
  6368. {
  6369. BtnPrint.IsEnabled = true;
  6370. timesPrint.Stop();
  6371. timesPrintMsg.Stop();
  6372. GridPrintMask.Visibility = Visibility.Collapsed;
  6373. return;
  6374. });
  6375. }
  6376. #region 拓思德生成点阵文件
  6377. ////TPF文件位置
  6378. //string TPFPath = FileToolsCommon.GetFileAbsolutePath("temp/");
  6379. //FileToolsCommon.CreateDirectory(TPFPath);
  6380. //TPFPath += "101.TPF";
  6381. ////生成点阵文件
  6382. //LatticeFileHelper.GeneratingPDF(SourcePath, TPFPath, out int pr, out string msg, out string outPut/*, pyte*/);
  6383. //while (!FileToolsCommon.IsExistFile(TPFPath))
  6384. //{
  6385. // Thread.Sleep(100);
  6386. //}
  6387. //while (string.IsNullOrWhiteSpace(pr.ToString()))
  6388. //{
  6389. // Thread.Sleep(100);
  6390. //}
  6391. //Thread.Sleep(1000);
  6392. #endregion 拓思德生成点阵文件
  6393. #region 拓思德打印
  6394. ////打印
  6395. //LatticeFileHelper.PrinterTPFFile(TPFPath, PrinterNum, PrinterName, out int printResult, out string standardError, out string standardOutput);
  6396. //if (printResult == 0)
  6397. //{
  6398. // Dispatcher.Invoke(() =>
  6399. // {
  6400. // btnClose.IsEnabled = true;
  6401. // btnPrint.IsEnabled = true;
  6402. // num = 99;
  6403. // timesPrint.Stop();
  6404. // pgbProcess.Value = 100;
  6405. // lbProcess.Content = "100%";
  6406. // MessageWindow.Show("打印成功!");
  6407. // GridPrintMask.Visibility = Visibility.Collapsed;
  6408. // });
  6409. //}
  6410. //else
  6411. //{
  6412. // Dispatcher.Invoke(() =>
  6413. // {
  6414. // btnClose.IsEnabled = true;
  6415. // btnPrint.IsEnabled = true;
  6416. // timesPrint.Stop();
  6417. // GridPrintMask.Visibility = Visibility.Collapsed;
  6418. // MessageWindow.Show(standardError);
  6419. // });
  6420. //}
  6421. #endregion 拓思德打印
  6422. }
  6423. /// <summary>
  6424. /// 调用打印机打印
  6425. /// </summary>
  6426. /// <param name="PDFPath">PDF文件路径</param>
  6427. /// <param name="PrinterName">打印机名称</param>
  6428. private void Print(string PDFPath, string PrinterName, short PrinterNum = 1)
  6429. {
  6430. //加载PDF文档
  6431. PdfDocument doc = new PdfDocument();
  6432. doc.LoadFromFile(PDFPath);
  6433. //指定打印机
  6434. doc.PrintSettings.PrinterName = PrinterName;
  6435. //静默打印PDF文档
  6436. doc.PrintSettings.PrintController = new StandardPrintController();
  6437. ////设置文档打印页码范围
  6438. //doc.PrintSettings.SelectPageRange(1, 5);
  6439. //打印不连续的页面
  6440. //doc.PrintSettings.SelectSomePages(new int[] { 1, 3, 5, 7 });
  6441. //设置打印份数为2份
  6442. doc.PrintSettings.Copies = PrinterNum;
  6443. //打印PDF文档
  6444. doc.Print();
  6445. }
  6446. /// <summary>
  6447. /// 生成图片
  6448. /// </summary>
  6449. /// <param name="_path">图片地址</param>
  6450. /// <param name="_saveimg">保存位置</param>
  6451. /// <param name="_rectangle">图片位置</param>
  6452. /// <param name="errmsg">错误消息</param>
  6453. /// <returns></returns>
  6454. private bool MergerPrintImg(string _path, string _saveimg, RectangleF _rectangle, out string errmsg)
  6455. {
  6456. errmsg = null;
  6457. try
  6458. {
  6459. Bitmap bitmap = null;
  6460. //创建要显示的图片对象,根据参数的个数设置宽度
  6461. Bitmap backgroudImg = new Bitmap((int)/*GridM.ActualWidth*/wit, (int)/*GridM.ActualHeight*/hei);
  6462. Graphics g = Graphics.FromImage(backgroudImg);
  6463. //清除画布,背景设置为白色
  6464. g.Clear(System.Drawing.Color.White);
  6465. if (!string.IsNullOrWhiteSpace(_path))
  6466. {
  6467. bitmap = ImageHelper.ReadBitmapFile(_path);
  6468. g.DrawImage(bitmap, _rectangle);
  6469. }
  6470. #region 添加箭头
  6471. string Str = "↑";
  6472. SolidBrush mybrush = new SolidBrush(System.Drawing.Color.Black); //设置默认画刷颜色
  6473. System.Drawing.Font myfont = new System.Drawing.Font("黑体", 14); //设置默认字体格式
  6474. g.DrawString(Str, myfont, mybrush, new System.Drawing.Rectangle((int)wit - 50, 20, 50, 50));
  6475. #endregion 添加箭头
  6476. backgroudImg.Save(_saveimg);
  6477. g.Dispose();
  6478. backgroudImg.Dispose();
  6479. if (bitmap != null)
  6480. {
  6481. bitmap.Dispose();
  6482. }
  6483. GC.Collect();
  6484. return true;
  6485. }
  6486. catch (Exception ex)
  6487. {
  6488. errmsg = ex.Message;
  6489. LogHelper.WriteErrLog("【截图合成】(MergerImg)图片合成失败:" + ex.Message, ex);
  6490. return false;
  6491. }
  6492. }
  6493. /// <summary>
  6494. /// 减
  6495. /// </summary>
  6496. /// <param name="sender"></param>
  6497. /// <param name="e"></param>
  6498. private void BtnPrintLess_Click(object sender, RoutedEventArgs e)
  6499. {
  6500. int num = Convert.ToInt32(txbNumberOfCopies.Content);
  6501. if (num > 1)
  6502. {
  6503. num--;
  6504. txbNumberOfCopies.Content = num.ToString();
  6505. }
  6506. }
  6507. /// <summary>
  6508. /// 新增
  6509. /// </summary>
  6510. /// <param name="sender"></param>
  6511. /// <param name="e"></param>
  6512. private void BtnPrintAdd_Click(object sender, RoutedEventArgs e)
  6513. {
  6514. int num = Convert.ToInt32(txbNumberOfCopies.Content);
  6515. if (num > 0)
  6516. {
  6517. num++;
  6518. txbNumberOfCopies.Content = num.ToString();
  6519. }
  6520. }
  6521. /// <summary>
  6522. /// 打印说明
  6523. /// </summary>
  6524. /// <param name="sender"></param>
  6525. /// <param name="e"></param>
  6526. private void btnPrintExplain_Click(object sender, RoutedEventArgs e)
  6527. {
  6528. System.Diagnostics.Process.Start(FileToolsCommon.GetFileAbsolutePath("/星火微课点阵码打印及印刷指导手册.docx"));
  6529. }
  6530. #endregion 打印
  6531. #region 设备检测
  6532. /// <summary>
  6533. /// 设备检测
  6534. /// </summary>
  6535. /// <param name="sender"></param>
  6536. /// <param name="e"></param>
  6537. private void BtnDevice_Click(object sender, RoutedEventArgs e)
  6538. {
  6539. if (APP.W_DeviceWindow == null)
  6540. {
  6541. APP.W_DeviceWindow = new DeviceWindow();
  6542. APP.W_DeviceWindow.Owner = this;
  6543. }
  6544. rbnTurnOff.IsChecked = true;
  6545. RbnTurnOff_Click(null, null);
  6546. APP.W_DeviceWindow.Initialize();
  6547. APP.W_DeviceWindow.ShowDialog();
  6548. }
  6549. #endregion 设备检测
  6550. }
  6551. public class PageData
  6552. {
  6553. public int PageCode { get; set; }
  6554. public string PageName { get; set; }
  6555. }
  6556. }