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

XHMicroLessonSystemWindow.xaml.cs 253KB

пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 3 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 3 година
пре 4 година
пре 4 година
пре 4 година
пре 3 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 3 година
пре 3 година
пре 3 година
пре 3 година
пре 3 година
пре 3 година
пре 3 година
пре 3 година
пре 3 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 3 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 4 година
пре 3 година
пре 3 година
пре 4 година
пре 4 година
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794
  1. using Aspose.Slides;
  2. using Aspose.Words;
  3. using Aspose.Words.Saving;
  4. using ComeCapture;
  5. using Common.system;
  6. using RobotpenGateway;
  7. using System;
  8. using System.Collections.Generic;
  9. using System.Diagnostics;
  10. using System.Drawing;
  11. using System.Drawing.Imaging;
  12. using System.IO;
  13. using System.Linq;
  14. using System.Text;
  15. using System.Text.RegularExpressions;
  16. using System.Threading;
  17. using System.Windows;
  18. using System.Windows.Controls;
  19. using System.Windows.Controls.Primitives;
  20. using System.Windows.Forms;
  21. using System.Windows.Ink;
  22. using System.Windows.Input;
  23. using System.Windows.Media;
  24. using System.Windows.Media.Imaging;
  25. using System.Windows.Threading;
  26. using TStudyDigitalPen.HID;
  27. using XHWK.Model;
  28. using XHWK.WKTool.DAL;
  29. using XHWK.WKTool.UControl;
  30. namespace XHWK.WKTool
  31. {
  32. /// <summary>
  33. /// 主页面
  34. /// </summary>
  35. public partial class XHMicroLessonSystemWindow : Window
  36. {
  37. #region 字段
  38. /// <summary>
  39. /// 页码下拉列表
  40. /// </summary>
  41. List<PageData> PageData =null;
  42. private FolderBrowserDialog Ofd;
  43. private DialogResult Result;
  44. public BlackboardNew myblackboard;
  45. private System.Windows.Forms.DialogResult result;
  46. private System.Windows.Forms.OpenFileDialog ofd;
  47. //声明一个 DrawingAttributes 类型的变量
  48. private DrawingAttributes drawingAttributes;
  49. private Model_Video VideoInfo = null;
  50. ////定义事件
  51. //public event ChangeTextHandler ChangeTextEvent;
  52. //定义委托
  53. public delegate void ChangeTextHandler(string text);
  54. //定义委托
  55. public delegate void ChangeTextHandlers(string text, int i);
  56. /// <summary>
  57. /// 图片
  58. /// </summary>
  59. private string[] ImgPDFPath = new string[300];
  60. /// <summary>
  61. /// 当前颜色
  62. /// </summary>
  63. private System.Windows.Media.Color Color = System.Windows.Media.Colors.Red;
  64. /// <summary>
  65. /// 笔迹粗细
  66. /// </summary>
  67. private int PenSize = 2;
  68. //private DispatcherTimer t = null;
  69. /// <summary>
  70. /// 计时器状态
  71. /// </summary>
  72. private enum State
  73. {
  74. Start,
  75. Pause,
  76. End
  77. }
  78. /// <summary>
  79. /// 状态
  80. /// </summary>
  81. private State _state = State.End;
  82. /// <summary>
  83. /// 计时用
  84. /// </summary>
  85. private TimeSpan _timeSpan = new TimeSpan(0, 0, 0, 0, 0);
  86. #region 上传
  87. /// <summary>
  88. /// 视频模型
  89. /// </summary>
  90. private List<Model_Video> model_VideoList = null;
  91. /// <summary>
  92. /// 数据列表
  93. /// </summary>
  94. internal FileDirectoryData pageData = new FileDirectoryData();
  95. /// <summary>
  96. /// 下标
  97. /// </summary>
  98. private int Subscript = 0;
  99. /// <summary>
  100. /// 是否是修改状态
  101. /// </summary>
  102. private bool IsModify = false;
  103. #endregion
  104. private double screeHeight = SystemParameters.FullPrimaryScreenHeight;
  105. private double screeWidth = SystemParameters.FullPrimaryScreenWidth;
  106. /// <summary>
  107. /// 键盘钩子
  108. /// </summary>
  109. private KeyboardHookCommon k_hook;
  110. #endregion
  111. #region 初始化
  112. /// <summary>
  113. /// 主页面
  114. /// </summary>
  115. public XHMicroLessonSystemWindow()
  116. {
  117. 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=")));
  118. 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=")));
  119. 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=")));
  120. InitializeComponent();
  121. float WorkW = PrimaryScreen.ScaleWorkingAreaSize.Width;
  122. float WorkH = PrimaryScreen.ScaleWorkingAreaSize.Height;
  123. double proportion = 1036.0 / 1290.0;
  124. //限制大小 确保大屏幕下录制不会卡死 暂时
  125. if (WorkW > 1920.0)
  126. {
  127. Width = 1920;
  128. Height = 1036;
  129. }
  130. else
  131. {
  132. Width = (PrimaryScreen.ScaleWorkingAreaSize.Height) / proportion - (BorderThickness.Left + BorderThickness.Right);
  133. Height = PrimaryScreen.ScaleWorkingAreaSize.Height - (BorderThickness.Top + BorderThickness.Bottom);
  134. }
  135. GridContent.Width = Width - 14;
  136. GridContent.Height = Height;
  137. #region 读取本地配置
  138. if (File.Exists(APP.dataPath + "interfaceAddress.txt")) //若不为空
  139. {
  140. APP.apiUrl = System.IO.File.ReadAllText(APP.dataPath + "interfaceAddress.txt", Encoding.Default);
  141. }
  142. if (File.Exists(APP.dataPath + "imageUploadAddress.txt")) //若不为空
  143. {
  144. APP.uploadUrl = System.IO.File.ReadAllText(APP.dataPath + "imageUploadAddress.txt", Encoding.Default);
  145. }
  146. if (File.Exists(APP.dataPath + "pictureShowsAddress.txt")) //若不为空
  147. {
  148. APP.showImageUrl = System.IO.File.ReadAllText(APP.dataPath + "pictureShowsAddress.txt", Encoding.Default);
  149. }
  150. #endregion
  151. //GridMain.Height= PrimaryScreen.ScaleScreenSize().Height - 40;
  152. //this.Top = (screeHeight - this.Height) / 2;
  153. //this.Left = (screeWidth - this.Width) / 2;
  154. ResizeMode = System.Windows.ResizeMode.CanMinimize;
  155. btnPrint.IsEnabled = false;
  156. myblackboard = new BlackboardNew(blackboard_canvas);
  157. APP.pageData.pagenum = 0;
  158. APP.pageData.currpage = 0;
  159. DataContext = APP.pageData;
  160. //APP.SaveDraw();//画板模型第一页初始化
  161. APP.PageDrawList = new List<Model_DrawData>();
  162. Model_DrawData model_DrawData = new Model_DrawData
  163. {
  164. PageNum = APP.pageData.currpage
  165. };
  166. APP.PageDrawList.Add(model_DrawData);
  167. txbv.Text = "v" + FileToolsCommon.GetConfigValue("VersionName");
  168. txbStoragePath.Content = FileToolsCommon.GetConfigValue("VideoType");
  169. if (FileToolsCommon.GetConfigValue("IsSound").Equals("true"))
  170. {
  171. rbnY.IsChecked = true;
  172. }
  173. else
  174. {
  175. rbnN.IsChecked = true;
  176. }
  177. txbStoragePath.Content = FileToolsCommon.GetConfigValue("VideoSavePath");
  178. Initialize();
  179. InitPen();
  180. InitlbPen();
  181. }
  182. /// <summary>
  183. /// 初始化
  184. /// </summary>
  185. public void Initialize()
  186. {
  187. if (APP.isDebug)
  188. {
  189. txbVersion.Text = "测试版:";
  190. }
  191. else
  192. {
  193. txbVersion.Text = "正式版:";
  194. }
  195. #region 数据初始化
  196. string pathTemp = AppDomain.CurrentDomain.BaseDirectory + "Temp\\";
  197. FileToolsCommon.CreateDirectory(pathTemp);
  198. APP.pageData.pagenum = 0;
  199. APP.pageData.currpage = APP.pageData.pagenum;
  200. btnStop.IsEnabled = false;//停止录制按钮不可点击
  201. #endregion
  202. k_hook = new KeyboardHookCommon();
  203. k_hook.KeyDownEvent += K_hook_KeyDownEvent;
  204. k_hook.Start();//安装键盘钩子
  205. APP.CameraPosition = FileToolsCommon.GetConfigValue("CameraPosition");
  206. //创建 DrawingAttributes 类的一个实例
  207. drawingAttributes = new DrawingAttributes();
  208. //将 InkCanvas 的 DefaultDrawingAttributes 属性的值赋成创建的 DrawingAttributes 类的对象的引用
  209. //InkCanvas 通过 DefaultDrawingAttributes 属性来获取墨迹的各种设置,该属性的类型为 DrawingAttributes 型
  210. blackboard_canvas.DefaultDrawingAttributes = drawingAttributes;
  211. blackboard_canvas.UseCustomCursor = true;
  212. drawingAttributes.FitToCurve = true;
  213. drawingAttributes.IgnorePressure = false;
  214. drawingAttributes.Width = PenSize;
  215. drawingAttributes.Height = PenSize;
  216. drawingAttributes.Color = Color;
  217. blackboard_canvas.Cursor = System.Windows.Input.Cursors.Pen;
  218. //wfhCamera.Visibility = Visibility.Hidden;
  219. ImgPDFPath = null;
  220. ImgPDFPath = new string[300];
  221. //gridM.Height = gridM.ActualWidth / proportion;
  222. //gridM.Height = gridM.Width / proportion;
  223. }
  224. /// <summary>
  225. /// 初始化快捷键
  226. /// </summary>
  227. public void InitializeKeyDownEvent()
  228. {
  229. k_hook.Start();//安装键盘钩子
  230. }
  231. /// <summary>
  232. /// 快捷键
  233. /// </summary>
  234. /// <param name="sender"></param>
  235. /// <param name="e"></param>
  236. private void K_hook_KeyDownEvent(object sender, System.Windows.Forms.KeyEventArgs e)
  237. {
  238. if (e.KeyValue == (int)System.Windows.Forms.Keys.Left)
  239. {
  240. if (APP.pageData.currpage > 1)
  241. {
  242. //上一页
  243. last_button_Click(null, null);
  244. }
  245. }
  246. if (e.KeyValue == (int)System.Windows.Forms.Keys.Right)
  247. {
  248. if (APP.pageData.currpage < APP.pageData.pagenum)
  249. {
  250. //下一页
  251. next_btn_Click(null, null);
  252. }
  253. }
  254. if (e.KeyValue == (int)System.Windows.Forms.Keys.Delete)
  255. {
  256. if (RectImgBorder.Visibility != Visibility.Hidden)
  257. {
  258. HideAngleBorder();
  259. imgCanvas.Source = null;
  260. APP.PageDrawList[APP.pageData.currpage - 1].PdfImagePath = null;
  261. APP.PageDrawList[APP.pageData.currpage - 1].PageImagePath = null;
  262. }
  263. }
  264. }
  265. /// <summary>
  266. /// 加载完成后调整录制区域大小
  267. /// </summary>
  268. /// <param name="sender"></param>
  269. /// <param name="e"></param>
  270. private void Window_Loaded(object sender, RoutedEventArgs e)
  271. {
  272. //调整录制区域宽高
  273. double proportion = 210.0 / 297.0;
  274. gridM.Height = gridM.ActualWidth / proportion;
  275. }
  276. #endregion
  277. #region 事件
  278. /// <summary>
  279. /// 窗体移动
  280. /// </summary>
  281. /// <param name="sender"></param>
  282. /// <param name="e"></param>
  283. private void Window_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
  284. {
  285. DragMove();
  286. }
  287. #region 摄像头
  288. private System.Timers.Timer times;
  289. private List<string> RbnOpen;
  290. private bool IsRbnOpen = false;
  291. /// <summary>
  292. /// 摄像头打开事件
  293. /// </summary>
  294. /// <param name="sender"></param>
  295. /// <param name="e"></param>
  296. private void RbnOpen_Click(object sender, RoutedEventArgs e)
  297. {
  298. if (!IsRbnOpen)
  299. {
  300. #region 防止连击
  301. if (IsPressButton)
  302. {
  303. return;
  304. }
  305. else
  306. {
  307. IsPressButton = true;
  308. new Thread(new ThreadStart(new Action(() =>
  309. {
  310. //Dispatcher.Invoke(new Action(() => { rbnTurnOff.IsEnabled = false; }));
  311. Thread.Sleep(500);
  312. //Dispatcher.Invoke(new Action(() => { rbnTurnOff.IsEnabled = true; }));
  313. IsPressButton = false;
  314. }))).Start();
  315. }
  316. #endregion
  317. CameraHelper.UpdateCameraDevices();
  318. if (CameraHelper.CameraDevices.Count > 0)
  319. {
  320. CameraHelper.SetCameraDevice(0);
  321. RbnOpen = new List<string>();
  322. times = new System.Timers.Timer(200)//初始值为300
  323. {
  324. AutoReset = true//设置是否执行System.Timers.Timer.Elapsed事件
  325. };//设置执行一次(false)还是一直执行(true)
  326. times.Elapsed += new System.Timers.ElapsedEventHandler(Times_Elapsed);
  327. times.Enabled = true; //启动计时器
  328. IsRbnOpen = true;
  329. string imgPath = FileToolsCommon.GetFileAbsolutePath("Temp/imgplayer");
  330. FileToolsCommon.CreateDirectory(imgPath);
  331. }
  332. }
  333. }
  334. private int I = 9999;
  335. private void Times_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
  336. {
  337. if (IsRbnOpen)
  338. {
  339. try
  340. {
  341. Dispatcher.Invoke(() =>
  342. {
  343. if (I > 10010)
  344. {
  345. long time = Timestamp();
  346. string imgPath = FileToolsCommon.GetFileAbsolutePath("Temp/imgplayer");
  347. //string FilePathName = ImgPath + RsImgName.Count + ".png";
  348. string path = CameraHelper.CaptureImage(imgPath, time.ToString());
  349. if (!string.IsNullOrWhiteSpace(path))
  350. {
  351. RbnOpen.Add(path);
  352. imgPlayerRight.Visibility = Visibility.Visible;
  353. /// < !--摄像头位置 1.右上 2.左上 3.右下 4.左下-- >
  354. if ("1".Equals(APP.CameraPosition))
  355. {
  356. imgPlayerRight.Visibility = Visibility.Visible;
  357. imgPlayerLeft.Visibility = Visibility.Collapsed;
  358. imgPlayerRightUnder.Visibility = Visibility.Collapsed;
  359. imgPlayerLeftUnder.Visibility = Visibility.Collapsed;
  360. imgPlayerRight.Source = new BitmapImage(new Uri(path));
  361. }
  362. else if ("2".Equals(APP.CameraPosition))
  363. {
  364. imgPlayerRight.Visibility = Visibility.Collapsed;
  365. imgPlayerLeft.Visibility = Visibility.Visible;
  366. imgPlayerRightUnder.Visibility = Visibility.Collapsed;
  367. imgPlayerLeftUnder.Visibility = Visibility.Collapsed;
  368. imgPlayerLeft.Source = new BitmapImage(new Uri(path));
  369. }
  370. else if ("3".Equals(APP.CameraPosition))
  371. {
  372. imgPlayerRight.Visibility = Visibility.Collapsed;
  373. imgPlayerLeft.Visibility = Visibility.Collapsed;
  374. imgPlayerRightUnder.Visibility = Visibility.Visible;
  375. imgPlayerLeftUnder.Visibility = Visibility.Collapsed;
  376. imgPlayerRightUnder.Source = new BitmapImage(new Uri(path));
  377. }
  378. else if ("4".Equals(APP.CameraPosition))
  379. {
  380. imgPlayerRight.Visibility = Visibility.Collapsed;
  381. imgPlayerLeft.Visibility = Visibility.Collapsed;
  382. imgPlayerRightUnder.Visibility = Visibility.Collapsed;
  383. imgPlayerLeftUnder.Visibility = Visibility.Visible;
  384. imgPlayerLeftUnder.Source = new BitmapImage(new Uri(path));
  385. }
  386. else
  387. {
  388. imgPlayerLeft.Visibility = Visibility.Collapsed;
  389. imgPlayerRightUnder.Visibility = Visibility.Collapsed;
  390. imgPlayerLeftUnder.Visibility = Visibility.Collapsed;
  391. imgPlayerRight.Source = new BitmapImage(new Uri(path));
  392. }
  393. }
  394. }
  395. I++;
  396. });
  397. }
  398. catch (Exception ex)
  399. {
  400. LogHelper.WriteErrLog("【摄像】(Times_Elapsed)生成图片错误:" + ex.Message, ex);
  401. }
  402. }
  403. }
  404. /// <summary>
  405. /// 摄像头关闭事件
  406. /// </summary>
  407. /// <param name="sender"></param>
  408. /// <param name="e"></param>
  409. private void RbnTurnOff_Click(object sender, RoutedEventArgs e)
  410. {
  411. if (IsRbnOpen)
  412. {
  413. #region 防止连击
  414. if (IsPressButton)
  415. {
  416. return;
  417. }
  418. else
  419. {
  420. IsPressButton = true;
  421. new Thread(new ThreadStart(new Action(() =>
  422. {
  423. //Dispatcher.Invoke(new Action(() => { rbnOpen.IsEnabled = false; }));
  424. Thread.Sleep(500);
  425. //Dispatcher.Invoke(new Action(() => { rbnOpen.IsEnabled = true; }));
  426. IsPressButton = false;
  427. }))).Start();
  428. }
  429. #endregion
  430. IsRbnOpen = false;
  431. imgPlayerRight.Visibility = Visibility.Collapsed;
  432. imgPlayerLeft.Visibility = Visibility.Collapsed;
  433. imgPlayerRightUnder.Visibility = Visibility.Collapsed;
  434. imgPlayerLeftUnder.Visibility = Visibility.Collapsed;
  435. CameraHelper.CloseDevice();
  436. I = 9999;
  437. }
  438. }
  439. #endregion
  440. /// <summary>
  441. /// 关闭事件
  442. /// </summary>
  443. /// <param name="sender"></param>
  444. /// <param name="e"></param>
  445. private void BtnDown_Click(object sender, RoutedEventArgs e)
  446. {
  447. if (IsFirstR)
  448. {
  449. MessageBoxResult br = MessageWindow.Show("确定退出系统?", "退出", MessageBoxButton.OKCancel);
  450. if (br == MessageBoxResult.OK)
  451. {
  452. APP.Killffmpeg();
  453. APP.SaveWkData();
  454. APP.SaveDraw();
  455. Thread.Sleep(100);
  456. System.Environment.Exit(0);
  457. }
  458. }
  459. else
  460. {
  461. MessageWindow.Show("当前正在录制,请先停止录制。");
  462. return;
  463. //MessageBoxResult dr = MessageWindow.Show("当前正在录制,是否停止录制?", "提示", MessageBoxButton.OKCancel);
  464. //if (dr == MessageBoxResult.OK)
  465. //{
  466. // APP.SaveWkData();
  467. // APP.SaveDraw();
  468. // BtnStop_Click(null, null);
  469. // while (!IsFirstR)
  470. // {
  471. // Thread.Sleep(100);
  472. // }
  473. // System.Environment.Exit(0);
  474. //}
  475. //else
  476. //{
  477. // return;
  478. //}
  479. }
  480. }
  481. /// <summary>
  482. /// 增加事件
  483. /// </summary>
  484. /// <param name="sender"></param>
  485. /// <param name="e"></param>
  486. private void BtnAdd_Click(object sender, RoutedEventArgs e)
  487. {
  488. Record();
  489. if (APP.pageData.currpage > 0)
  490. {
  491. APP.PageDrawList[APP.pageData.currpage - 1].IsImageLocation = true;
  492. }
  493. if (IsStartCount && blackboard_canvas.Visibility == Visibility.Collapsed)
  494. {
  495. blackboard_canvas.Visibility = Visibility.Visible;
  496. }
  497. APP.pageData.pagenum += 1;
  498. HideAngleBorder();
  499. gridPage.Visibility = Visibility.Visible;//页码大于0 显示
  500. APP.pageData.currpage = APP.pageData.pagenum;
  501. myblackboard.changepage(APP.pageData.currpage - 1);
  502. scroMain.ScrollToVerticalOffset(0);
  503. ///清空页面图片UI
  504. imgCanvas.Source = null;
  505. imgDocumentation.Source = null;
  506. imgPPT.Source = null;
  507. if (APP.pageData.pagenum == 1)
  508. {
  509. APP.PageDrawList = new List<Model_DrawData>();
  510. }
  511. ///画板模型增加一页
  512. Model_DrawData model_DrawData = new Model_DrawData
  513. {
  514. PageNum = APP.pageData.currpage
  515. };
  516. APP.PageDrawList.Add(model_DrawData);
  517. ImgPrint.Visibility = Visibility.Visible;//可打印
  518. ImgPrintTwo.Visibility = Visibility.Collapsed;
  519. btnPrint.IsEnabled = true;
  520. //APP.SaveDraw();
  521. if (btnImport.IsEnabled == true)
  522. {
  523. ///截图可用
  524. ImgScreenshot.Visibility = Visibility.Visible;
  525. ImgScreenshotTwo.Visibility = Visibility.Collapsed;
  526. btnScreenshot.IsEnabled = true;
  527. }
  528. #region 插入页码
  529. PageData = new List<PageData>();
  530. for (int i = 1; i <= APP.pageData.pagenum; i++)
  531. {
  532. PageData pd = new PageData();
  533. pd.PageName = i.ToString();// + "页";
  534. pd.PageCode = i;
  535. PageData.Add(pd);
  536. }
  537. CbxPageList.ItemsSource = PageData;
  538. CbxPageList.SelectedIndex = APP.pageData.currpage - 1;
  539. #endregion
  540. }
  541. /// <summary>
  542. /// 打印事件
  543. /// </summary>
  544. /// <param name="sender"></param>
  545. /// <param name="e"></param>
  546. private void BtnPrint_Click(object sender, RoutedEventArgs e)
  547. {
  548. try
  549. {
  550. //3种情况 1.文档图片 2.截图图片 3.没有图片
  551. if (APP.PageDrawList.Count == 0)
  552. {
  553. MessageWindow.Show("没有可打印的页,您可以通过加页、截图或导入来增加页!");
  554. return;
  555. }
  556. //iTextSharp.text.Document document = new iTextSharp.text.Document(iTextSharp.text.PageSize.A4, 0, 0, 0, 0);
  557. ////iTextSharp.text.Rectangle page = new iTextSharp.text.Rectangle(iTextSharp.text.PageSize.A4., 250f);//cs
  558. //////设置纸张横向
  559. ////document.SetPageSize(iTextSharp.text.PageSize.A4.Rotate());
  560. //string imgPath = FileToolsCommon.GetFileAbsolutePath("temp/");
  561. //FileToolsCommon.CreateDirectory(imgPath);
  562. //imgPath += "101.pdf";
  563. //iTextSharp.text.pdf.PdfWriter.GetInstance(document, new FileStream(imgPath, FileMode.Create, FileAccess.ReadWrite));
  564. //document.Open();
  565. //iTextSharp.text.Image image;
  566. //for (int i = 0; i < APP.PageDrawList.Count; i++)
  567. //{
  568. // long ii = Timestamp();
  569. // string directoryPath = AppDomain.CurrentDomain.BaseDirectory + "Temp\\";
  570. // string filePathOutPut = Path.Combine(directoryPath, string.Format("print{0}{1}.jpg", ii, i));
  571. // RectangleF rectangleFs = new RectangleF();
  572. // MergerImg("", filePathOutPut, rectangleFs, out string errmsg);
  573. // image = iTextSharp.text.Image.GetInstance(filePathOutPut);
  574. // if (string.IsNullOrEmpty(APP.PageDrawList[i].PageImagePath))//没有图片
  575. // {
  576. // }
  577. // else if (APP.PageDrawList[i].ImgDocumentation == true&& !APP.PageDrawList[i].Type.Equals("ppt"))
  578. // {
  579. // image = iTextSharp.text.Image.GetInstance(APP.PageDrawList[i].PageImagePath);
  580. // }
  581. // else
  582. // {
  583. // RectangleF rectangleF = new RectangleF
  584. // {
  585. // Width = (float)APP.PageDrawList[i].ImageSizes.CenterX,
  586. // Height = (float)APP.PageDrawList[i].ImageSizes.CenterY,
  587. // X = (float)APP.PageDrawList[i].ImageLocation.X,
  588. // Y = (float)APP.PageDrawList[i].ImageLocation.Y
  589. // };
  590. // string msg = string.Empty;
  591. // bool isImg = MergerImg(APP.PageDrawList[i].PageImagePath, filePathOutPut, rectangleF, out msg);
  592. // if (isImg)
  593. // {
  594. // image = iTextSharp.text.Image.GetInstance(filePathOutPut);
  595. // }
  596. // else
  597. // {
  598. // image = iTextSharp.text.Image.GetInstance(APP.PageDrawList[i].PageImagePath);
  599. // }
  600. // }
  601. // if (image.Height > iTextSharp.text.PageSize.A4.Height)
  602. // {
  603. // image.ScaleToFit(iTextSharp.text.PageSize.A4.Width, iTextSharp.text.PageSize.A4.Height);
  604. // }
  605. // else if (image.Width > iTextSharp.text.PageSize.A4.Width)
  606. // {
  607. // image.ScaleToFit(iTextSharp.text.PageSize.A4.Width, iTextSharp.text.PageSize.A4.Height);
  608. // }
  609. // image.Alignment = iTextSharp.text.Image.ALIGN_MIDDLE;
  610. // document.NewPage();
  611. // document.Add(image);
  612. // //iTextSharp.text.Chunk c1 = new iTextSharp.text.Chunk("Hello World");
  613. // //iTextSharp.text.Phrase p1 = new iTextSharp.text.Phrase();
  614. // //p1.Leading = 150; //行间距
  615. // //document.Add(p1);
  616. //}
  617. //Console.WriteLine("转换成功!");
  618. //document.Close();
  619. }
  620. catch (Exception ex)
  621. {
  622. MessageWindow.Show(ex.Message);
  623. Console.WriteLine("转换失败,原因:" + ex.Message);
  624. }
  625. //document.Close();
  626. ////Console.ReadKey();
  627. if (APP.W_PrintWindow == null)
  628. {
  629. APP.W_PrintWindow = new PrintWindow
  630. {
  631. //APP.W_PrintWindow.Topmost = true;
  632. Owner = this
  633. };
  634. }
  635. if (APP.PageDrawList.Count > 0 && !string.IsNullOrWhiteSpace(APP.PageDrawList[0].PageImagePath))
  636. {
  637. APP.W_PrintWindow.Initialize(APP.PageDrawList[0].PageImagePath, gridM.ActualWidth, gridM.ActualHeight);
  638. }
  639. else
  640. {
  641. APP.W_PrintWindow.Initialize("", gridM.ActualWidth, gridActHeight);
  642. }
  643. APP.W_PrintWindow.ShowDialog();
  644. //int pr = 1;
  645. //string msg = string.Empty;
  646. //string outPut = string.Empty;
  647. //LatticeFileHelper.GeneratingPDF(@"G:\101.pdf", @"G:\102.TPF",out pr, out msg, out outPut);
  648. //if(pr==0)
  649. //{
  650. // outPut = outPut.Replace("[", "").Replace("]","").Replace("\"","").Trim();
  651. // APP.OutPut = outPut.Split(',');
  652. // string defa = string.Empty;
  653. // List<string>defaList= LatticeFileHelper.GetPrinterList(out defa);
  654. // int printResult = 1;
  655. // string standardError = string.Empty;
  656. // string standardOutput = string.Empty;
  657. // LatticeFileHelper.PrinterTPFFile(@"G:\102.TPF",1, /*defa*/"导出为WPS PDF", out printResult,out standardError,out standardOutput);
  658. //}
  659. }
  660. /// <summary>
  661. /// 最小化
  662. /// </summary>
  663. /// <param name="sender"></param>
  664. /// <param name="e"></param>
  665. private void BtnShrink_Click(object sender, RoutedEventArgs e)
  666. {
  667. if (WindowState == WindowState.Minimized)
  668. {
  669. WindowState = WindowState.Normal;
  670. }
  671. else
  672. {
  673. WindowState = WindowState.Minimized;
  674. }
  675. }
  676. #endregion
  677. #region 设置
  678. /// <summary>
  679. /// 设置事件
  680. /// </summary>
  681. /// <param name="sender"></param>
  682. /// <param name="e"></param>
  683. private void BtnSetUp_Click(object sender, RoutedEventArgs e)
  684. {
  685. if (!TxbRecordingWord.Text.Equals("暂停"))
  686. {
  687. if (gridSetUp.Visibility == Visibility.Collapsed)
  688. {
  689. GridMain.Visibility = Visibility.Collapsed;
  690. gridSetUp.Visibility = Visibility.Visible;
  691. //gridUpload.Visibility = Visibility.Collapsed;
  692. GridMyVideo.Visibility = Visibility.Collapsed;
  693. txbStoragePath.Content = APP.WKData.WkPath;
  694. GridMyVideo.Visibility = Visibility.Collapsed;
  695. #region 读取用户配置
  696. //接口地址
  697. if (!File.Exists(APP.dataPath + "interfaceAddress.txt")) //若为空
  698. {
  699. txbInterfaceAddress.Text = APP.apiUrl.Replace("http://", "").Trim();
  700. }
  701. else
  702. {
  703. txbInterfaceAddress.Text = System.IO.File.ReadAllText(APP.dataPath + "interfaceAddress.txt", Encoding.Default).Replace("http://", "").Trim();
  704. }
  705. //上传地址
  706. if (!File.Exists(APP.dataPath + "imageUploadAddress.txt")) //若为空
  707. {
  708. txbImageUploadAddress.Text = APP.uploadUrl.Replace("http://", "").Replace("/", "").Trim();
  709. }
  710. else
  711. {
  712. txbImageUploadAddress.Text = System.IO.File.ReadAllText(APP.dataPath + "imageUploadAddress.txt", Encoding.Default).Replace("http://", "").Replace("/", "").Trim();
  713. }
  714. //下载地址
  715. if (!File.Exists(APP.dataPath + "pictureShowsAddress.txt")) //若为空
  716. {
  717. txbPictureShowsAddress.Text = APP.showImageUrl.Replace("http://", "").Replace("/", "").Replace("static", "").Trim();
  718. }
  719. else
  720. {
  721. txbPictureShowsAddress.Text = System.IO.File.ReadAllText(APP.dataPath + "pictureShowsAddress.txt", Encoding.Default).Replace("http://", "").Replace("/", "").Replace("static", "").Trim();
  722. }
  723. /// < !--摄像头位置 1.右上 2.左上 3.右下 4.左下-- >
  724. if ("1".Equals(APP.CameraPosition))
  725. {
  726. rbnRight.IsChecked = true;
  727. }
  728. else if ("2".Equals(APP.CameraPosition))
  729. {
  730. rbnLeft.IsChecked = true;
  731. }
  732. else if ("3".Equals(APP.CameraPosition))
  733. {
  734. rbnRightUnder.IsChecked = true;
  735. }
  736. else if ("4".Equals(APP.CameraPosition))
  737. {
  738. rbnLeftUnder.IsChecked = true;
  739. }
  740. string type = FileToolsCommon.GetConfigValue("VideoType");//<!--视频格式 1、MP4 2、FlV 3、AVI-->
  741. if ("1".Equals(type))
  742. {
  743. rbnMP4.IsChecked = true;
  744. }
  745. else if ("2".Equals(type))
  746. {
  747. rbnFLV.IsChecked = true;
  748. }
  749. else if ("3".Equals(type))
  750. {
  751. rbnAVI.IsChecked = true;
  752. }
  753. string isHide= FileToolsCommon.GetConfigValue("IsHideSRTool"); //工具栏是否隐藏
  754. if(isHide.Equals("1"))
  755. {
  756. rbnHide.IsChecked = true;
  757. }
  758. else
  759. {
  760. rbnvisi.IsChecked = true;
  761. }
  762. string isSound = FileToolsCommon.GetConfigValue("IsSound");//<!--声音 true 有 false 无-->
  763. if (isSound == "true")
  764. {
  765. rbnY.IsChecked = true;
  766. }
  767. else
  768. {
  769. rbnN.IsChecked = true;
  770. }
  771. #endregion
  772. }
  773. else
  774. {
  775. GridMain.Visibility = Visibility.Visible;
  776. gridSetUp.Visibility = Visibility.Collapsed;
  777. //gridUpload.Visibility = Visibility.Collapsed;
  778. GridMyVideo.Visibility = Visibility.Collapsed;
  779. if (APP.pageData.pagenum > 0)
  780. {
  781. gridPage.Visibility = Visibility.Visible;
  782. }
  783. DataContext = APP.pageData;
  784. }
  785. }
  786. }
  787. /// <summary>
  788. /// 设置 保存事件
  789. /// </summary>
  790. /// <param name="sender"></param>
  791. /// <param name="e"></param>
  792. private void BtnSave_Click(object sender, RoutedEventArgs e)
  793. {
  794. try
  795. {
  796. ImgRecord.Visibility = Visibility.Visible;//设置结束时可录制
  797. ImgRecordTwo.Visibility = Visibility.Collapsed;//设置结束时可录制
  798. BtnRecord.IsEnabled = true;//设置结束时可录制
  799. if (!string.IsNullOrWhiteSpace(txbInterfaceAddress.Text))
  800. {
  801. string ApplicationData = APP.dataPath + "interfaceAddress.txt";
  802. string temp = "http://" + txbInterfaceAddress.Text;
  803. System.IO.File.WriteAllText(ApplicationData, temp, Encoding.Default);
  804. }
  805. else
  806. {
  807. MessageWindow.Show("请输入接口地址");
  808. return;
  809. }
  810. if (!string.IsNullOrWhiteSpace(txbImageUploadAddress.Text))//图片上传地址
  811. {
  812. string ApplicationData = APP.dataPath + "imageUploadAddress.txt";
  813. string temp = "http://" + txbImageUploadAddress.Text + "/";
  814. System.IO.File.WriteAllText(ApplicationData, temp, Encoding.Default);
  815. }
  816. else
  817. {
  818. MessageWindow.Show("请输入上传地址");
  819. return;
  820. }
  821. if (!string.IsNullOrWhiteSpace(txbPictureShowsAddress.Text))
  822. {
  823. string ApplicationData = APP.dataPath + "pictureShowsAddress.txt";
  824. string temp = "http://" + txbPictureShowsAddress.Text + "/static/";
  825. System.IO.File.WriteAllText(ApplicationData, temp, Encoding.Default);
  826. }
  827. else
  828. {
  829. MessageWindow.Show("请输入下载地址");
  830. return;
  831. }
  832. if (!APP.apiUrl.Equals("http://" + txbInterfaceAddress.Text))
  833. {
  834. APP.apiUrl = "http://" + txbInterfaceAddress.Text;
  835. if (!txbLoginType.Text.Equals("未登录"))
  836. {
  837. LoginType();
  838. MessageWindow.Show("接口地址已修改,请重新登陆!");
  839. }
  840. }
  841. if (!APP.uploadUrl.Equals(txbImageUploadAddress.Text))
  842. {
  843. APP.uploadUrl = "http://" + txbImageUploadAddress.Text + "/";
  844. }
  845. if (!APP.showImageUrl.Equals(txbPictureShowsAddress.Text))
  846. {
  847. APP.showImageUrl = "http://" + txbPictureShowsAddress.Text + "/static/";
  848. }
  849. if (rbnMP4.IsChecked == true)
  850. {
  851. //存储文件
  852. FileToolsCommon.SetConfigValue("VideoType", "1");
  853. }
  854. else if (rbnFLV.IsChecked == true)
  855. {
  856. FileToolsCommon.SetConfigValue("VideoType", "2");
  857. }
  858. else
  859. {
  860. FileToolsCommon.SetConfigValue("VideoType", "3");
  861. }
  862. if (rbnY.IsChecked == true)
  863. {
  864. FileToolsCommon.SetConfigValue("IsSound", "true");
  865. }
  866. else
  867. {
  868. FileToolsCommon.SetConfigValue("IsSound", "false");
  869. }
  870. UpdateHideSRToolConfig();
  871. /// < !--摄像头位置 1.右上 2.左上 3.右下 4.左下-- >
  872. if (rbnRight.IsChecked == true)
  873. {
  874. FileToolsCommon.SetConfigValue("CameraPosition", "1");
  875. }
  876. else if (rbnLeft.IsChecked == true)
  877. {
  878. FileToolsCommon.SetConfigValue("CameraPosition", "2");
  879. }
  880. else if (rbnRightUnder.IsChecked == true)
  881. {
  882. FileToolsCommon.SetConfigValue("CameraPosition", "3");
  883. }
  884. else if (rbnLeftUnder.IsChecked == true)
  885. {
  886. FileToolsCommon.SetConfigValue("CameraPosition", "4");
  887. }
  888. if (rbnMP4.IsChecked == true)
  889. {
  890. FileToolsCommon.SetConfigValue("VideoType", "1");
  891. }
  892. else if (rbnFLV.IsChecked == true)
  893. {
  894. FileToolsCommon.SetConfigValue("VideoType", "2");
  895. }
  896. else if (rbnAVI.IsChecked == true)
  897. {
  898. FileToolsCommon.SetConfigValue("VideoType", "3");
  899. }
  900. APP.CameraPosition = FileToolsCommon.GetConfigValue("CameraPosition");
  901. GridMain.Visibility = Visibility.Visible;
  902. gridSetUp.Visibility = Visibility.Collapsed;
  903. imgPlayerRight.Visibility = Visibility.Collapsed;
  904. imgPlayerLeft.Visibility = Visibility.Collapsed;
  905. imgPlayerRightUnder.Visibility = Visibility.Collapsed;
  906. imgPlayerLeftUnder.Visibility = Visibility.Collapsed;
  907. if (!txbStoragePath.Content.ToString().Equals(APP.WKData.WkPath))
  908. {
  909. //存储文件
  910. FileToolsCommon.SetConfigValue("VideoSavePath", txbStoragePath.Content.ToString());
  911. MessageWindow.Show("路径已变更,下次创建微课时自动生效。");
  912. }
  913. }
  914. catch (Exception ex)
  915. {
  916. LogHelper.WriteErrLog("XHMicroLessonSystemWindow(设置保存事件报错:)" + ex.Message, ex);
  917. }
  918. }
  919. /// <summary>
  920. /// 设置 浏览事件
  921. /// </summary>
  922. /// <param name="sender"></param>
  923. /// <param name="e"></param>
  924. private void BtnBrowse_Click(object sender, RoutedEventArgs e)
  925. {
  926. //System.Diagnostics.Process.Start(APP.WKData.WkPath);
  927. string desktopPath = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
  928. Ofd = new System.Windows.Forms.FolderBrowserDialog();
  929. Result = Ofd.ShowDialog();
  930. if (Result == System.Windows.Forms.DialogResult.OK)
  931. {
  932. if (Ofd.SelectedPath != "")
  933. {
  934. txbStoragePath.Content = Ofd.SelectedPath;
  935. //string ApplicationData = ZConfig.dataPath + "fileStorageAddress.txt";
  936. //string temp = ofd.SelectedPath;
  937. //System.IO.File.WriteAllText(ApplicationData, temp, Encoding.Default);
  938. }
  939. }
  940. }
  941. /// <summary>
  942. /// 打开文件所在位置
  943. /// </summary>
  944. /// <param name="sender"></param>
  945. /// <param name="e"></param>
  946. private void btnOpen_Click(object sender, RoutedEventArgs e)
  947. {
  948. System.Diagnostics.Process.Start(APP.WKData.WkPath);
  949. }
  950. /// <summary>
  951. /// 更新隐藏录屏工具栏隐藏状态
  952. /// </summary>
  953. void UpdateHideSRToolConfig()
  954. {
  955. if(rbnHide.IsChecked == true)
  956. {
  957. //隐藏
  958. FileToolsCommon.SetConfigValue("IsHideSRTool", "1");
  959. APP.IsHideSRTool = true;
  960. }
  961. else
  962. {
  963. //显示
  964. FileToolsCommon.SetConfigValue("IsHideSRTool", "0");
  965. APP.IsHideSRTool = false;
  966. }
  967. }
  968. #endregion
  969. #region 画笔
  970. /// <summary>
  971. /// 画笔颜色事件 白色
  972. /// </summary>
  973. /// <param name="sender"></param>
  974. /// <param name="e"></param>
  975. private void BtnWhite_Click(object sender, RoutedEventArgs e)
  976. {
  977. ////创建 DrawingAttributes 类的一个实例
  978. //drawingAttributes = new DrawingAttributes();
  979. ////将 InkCanvas 的 DefaultDrawingAttributes 属性的值赋成创建的 DrawingAttributes 类的对象的引用
  980. ////InkCanvas 通过 DefaultDrawingAttributes 属性来获取墨迹的各种设置,该属性的类型为 DrawingAttributes 型
  981. //blackboard_canvas.DefaultDrawingAttributes = drawingAttributes;
  982. ////设置 DrawingAttributes 的 Color 属性设置颜色
  983. drawingAttributes.Color = Colors.White;
  984. Color = Colors.White;
  985. }
  986. /// <summary>
  987. /// 画笔颜色事件 红色
  988. /// </summary>
  989. /// <param name="sender"></param>
  990. /// <param name="e"></param>
  991. private void BtnRed_Click(object sender, RoutedEventArgs e)
  992. {
  993. //设置 DrawingAttributes 的 Color 属性设置颜色
  994. drawingAttributes.Color = Colors.Red;
  995. Color = Colors.Red;
  996. imgRed.Visibility = Visibility.Visible;
  997. imgGray.Visibility = Visibility.Collapsed;
  998. imgCyanBlue.Visibility = Visibility.Collapsed;
  999. imgYellow.Visibility = Visibility.Collapsed;
  1000. imgBlue.Visibility = Visibility.Collapsed;
  1001. }
  1002. /// <summary>
  1003. /// 画笔颜色事件 黑色
  1004. /// </summary>
  1005. /// <param name="sender"></param>
  1006. /// <param name="e"></param>
  1007. private void BtnGray_Click(object sender, RoutedEventArgs e)
  1008. {
  1009. drawingAttributes.Color = Colors.Black;
  1010. Color = Colors.Black;
  1011. imgRed.Visibility = Visibility.Collapsed;
  1012. imgGray.Visibility = Visibility.Visible;
  1013. imgCyanBlue.Visibility = Visibility.Collapsed;
  1014. imgYellow.Visibility = Visibility.Collapsed;
  1015. imgBlue.Visibility = Visibility.Collapsed;
  1016. }
  1017. /// <summary>
  1018. /// 画笔颜色事件 青色
  1019. /// </summary>
  1020. /// <param name="sender"></param>
  1021. /// <param name="e"></param>
  1022. private void BtnCyanBlue_Click(object sender, RoutedEventArgs e)
  1023. {
  1024. drawingAttributes.Color = Colors.LimeGreen;
  1025. Color = Colors.LimeGreen;
  1026. imgRed.Visibility = Visibility.Collapsed;
  1027. imgGray.Visibility = Visibility.Collapsed;
  1028. imgCyanBlue.Visibility = Visibility.Visible;
  1029. imgYellow.Visibility = Visibility.Collapsed;
  1030. imgBlue.Visibility = Visibility.Collapsed;
  1031. }
  1032. /// <summary>
  1033. /// 画笔颜色事件 黄色
  1034. /// </summary>
  1035. /// <param name="sender"></param>
  1036. /// <param name="e"></param>
  1037. private void BtnYellow_Click(object sender, RoutedEventArgs e)
  1038. {
  1039. drawingAttributes.Color = Colors.Gold;
  1040. Color = Colors.Gold;
  1041. imgRed.Visibility = Visibility.Collapsed;
  1042. imgGray.Visibility = Visibility.Collapsed;
  1043. imgCyanBlue.Visibility = Visibility.Collapsed;
  1044. imgYellow.Visibility = Visibility.Visible;
  1045. imgBlue.Visibility = Visibility.Collapsed;
  1046. }
  1047. /// <summary>
  1048. /// 画笔颜色事件 蓝色
  1049. /// </summary>
  1050. /// <param name="sender"></param>
  1051. /// <param name="e"></param>
  1052. private void BtnBlue_Click(object sender, RoutedEventArgs e)
  1053. {
  1054. drawingAttributes.Color = Colors.DeepSkyBlue;
  1055. Color = Colors.DeepSkyBlue;
  1056. imgRed.Visibility = Visibility.Collapsed;
  1057. imgGray.Visibility = Visibility.Collapsed;
  1058. imgCyanBlue.Visibility = Visibility.Collapsed;
  1059. imgYellow.Visibility = Visibility.Collapsed;
  1060. imgBlue.Visibility = Visibility.Visible;
  1061. }
  1062. /// <summary>
  1063. /// 画笔粗细事件 细
  1064. /// </summary>
  1065. /// <param name="sender"></param>
  1066. /// <param name="e"></param>
  1067. private void RbnFine_Click(object sender, RoutedEventArgs e)
  1068. {
  1069. drawingAttributes.Width = 1;
  1070. drawingAttributes.Height = 1;
  1071. PenSize = 1;
  1072. }
  1073. /// <summary>
  1074. /// 画笔粗细事件 中
  1075. /// </summary>
  1076. /// <param name="sender"></param>
  1077. /// <param name="e"></param>
  1078. private void RbnIn_Click(object sender, RoutedEventArgs e)
  1079. {
  1080. drawingAttributes.Width = 3;
  1081. drawingAttributes.Height = 3;
  1082. PenSize = 3;
  1083. }
  1084. /// <summary>
  1085. /// 画笔粗细事件 粗
  1086. /// </summary>
  1087. /// <param name="sender"></param>
  1088. /// <param name="e"></param>
  1089. private void RbnCrude_Click(object sender, RoutedEventArgs e)
  1090. {
  1091. drawingAttributes.Width = 5;
  1092. drawingAttributes.Height = 5;
  1093. PenSize = 5;
  1094. }
  1095. private void imgCanvas_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
  1096. {
  1097. mouseDown = true;
  1098. }
  1099. #endregion
  1100. #region 导入截图
  1101. /// <summary>
  1102. /// 截图事件
  1103. /// </summary>
  1104. /// <param name="sender"></param>
  1105. /// <param name="e"></param>
  1106. private void BtnScreenshot_Click(object sender, RoutedEventArgs e)
  1107. {
  1108. Record();
  1109. HideAngleBorder();
  1110. imgCanvas.Margin = new Thickness(0, 0, 0, 0);
  1111. APP.ImgPath = string.Empty;
  1112. string time = GetTimeStamp();
  1113. string desktopPath = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory) + time + ".jpg";
  1114. APP.ImgPath = desktopPath;
  1115. ImageHelper.GetScreenshot(new System.Drawing.Rectangle(0, 0, 0, 0), desktopPath, false, out BitmapImage bitmap);
  1116. k_hook.Stop();
  1117. if (WindowState == WindowState.Normal)//截图隐藏窗口
  1118. {
  1119. WindowState = WindowState.Minimized;
  1120. }
  1121. if (APP.W_JieTuWindow != null)
  1122. {
  1123. APP.W_JieTuWindow.initialization();
  1124. APP.W_JieTuWindow.Screenshot();
  1125. APP.W_JieTuWindow.InitializeKeyDownEvent();
  1126. APP.W_JieTuWindow.WindowState = WindowState.Maximized;
  1127. APP.W_JieTuWindow.Visibility = Visibility.Visible;
  1128. }
  1129. else
  1130. {
  1131. APP.W_JieTuWindow = new JieTuWindow();
  1132. APP.W_JieTuWindow.InitializeKeyDownEvent();
  1133. // 订阅事件
  1134. APP.W_JieTuWindow.ChangeTextEvent += new ChangeTextHandler(frm_ChangeTextEvent);
  1135. APP.W_JieTuWindow.click_closeJietuWindowClick += JietuWindow_click_closeJietuWindowClick;
  1136. APP.W_JieTuWindow.Show();
  1137. }
  1138. //imgCanvas.Source = new BitmapImage(new Uri(desktopPath));
  1139. }
  1140. /// <summary>
  1141. /// 获取时间戳
  1142. /// </summary>
  1143. /// <returns></returns>
  1144. public string GetTimeStamp()
  1145. {
  1146. TimeSpan ts = DateTime.Now - new DateTime(1970, 1, 1, 0, 0, 0, 0);
  1147. return Convert.ToInt64(ts.TotalSeconds).ToString();
  1148. }
  1149. /// <summary>
  1150. /// 返回一个时间戳到毫秒
  1151. /// </summary>
  1152. /// <returns></returns>
  1153. public static long Timestamp()
  1154. {
  1155. TimeSpan ts = DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0);
  1156. long timestr = Convert.ToInt64(ts.TotalMilliseconds);
  1157. return timestr;
  1158. }
  1159. public void WindowType()
  1160. {
  1161. if (WindowState == WindowState.Minimized)//截图完恢复窗口
  1162. {
  1163. Topmost = true;
  1164. WindowState = WindowState.Normal;
  1165. }
  1166. }
  1167. /// <summary>
  1168. /// 截图关闭窗口
  1169. /// </summary>
  1170. /// <param name="text"></param>
  1171. private void frm_ChangeTextEvent(string text)
  1172. {
  1173. if ("关闭窗口".Equals(text))
  1174. {
  1175. if (WindowState == WindowState.Minimized)//截图完恢复窗口
  1176. {
  1177. Topmost = true;
  1178. WindowState = WindowState.Normal;
  1179. }
  1180. InitializeKeyDownEvent();
  1181. if (!string.IsNullOrWhiteSpace(APP.ImgPath) && File.Exists(APP.ImgPath))
  1182. {
  1183. if (APP.pageData.currpage == 0)
  1184. {
  1185. APP.pageData.pagenum += 1;
  1186. APP.pageData.currpage = APP.pageData.pagenum;
  1187. myblackboard.changepage(APP.pageData.currpage - 1);
  1188. gridPage.Visibility = Visibility.Visible;//页码大于0 显示
  1189. #region 插入页码
  1190. PageData = new List<PageData>();
  1191. for (int i = 1; i <= APP.pageData.pagenum; i++)
  1192. {
  1193. PageData pd = new PageData();
  1194. pd.PageName = i.ToString();// + "页";
  1195. pd.PageCode = i;
  1196. PageData.Add(pd);
  1197. }
  1198. CbxPageList.ItemsSource = PageData;
  1199. CbxPageList.SelectedIndex = APP.pageData.currpage - 1;
  1200. #endregion
  1201. }
  1202. if (APP.PageDrawList.Count >= APP.pageData.currpage)
  1203. {
  1204. APP.PageDrawList[APP.pageData.currpage - 1].PageImagePath = APP.ImgPath;//zxycs
  1205. APP.PageDrawList[APP.pageData.currpage - 1].PdfImagePath = APP.ImgPath;
  1206. }
  1207. else
  1208. {
  1209. Model_DrawData model_DrawData = new Model_DrawData
  1210. {
  1211. PageImagePath = APP.ImgPath,
  1212. PdfImagePath = APP.ImgPath
  1213. };
  1214. APP.PageDrawList.Add(model_DrawData);
  1215. }
  1216. if (APP.PageDrawList.Count >= APP.pageData.currpage && !string.IsNullOrWhiteSpace(APP.PageDrawList[APP.pageData.currpage - 1].PageImagePath))
  1217. {
  1218. imgDocumentation.Source = null;
  1219. BitmapImage bitImg = new BitmapImage(new Uri(APP.PageDrawList[APP.pageData.currpage - 1].PageImagePath));
  1220. mouseDown = false;
  1221. APP.PageDrawList[APP.pageData.currpage - 1].ImageLocation = new TranslateTransform
  1222. {
  1223. X = 0.1,
  1224. Y = 0.1
  1225. };
  1226. APP.PageDrawList[APP.pageData.currpage - 1].Type = "截图";
  1227. APP.PageDrawList[APP.pageData.currpage - 1].IsImageLocation = false;
  1228. imgCanvas.Source = bitImg;
  1229. imgCanvas.Width = bitImg.Width;
  1230. imgCanvas.Height = bitImg.Height;
  1231. scroMain.ScrollToVerticalOffset(0);
  1232. APP.PageDrawList[APP.pageData.currpage - 1].ImageSizes = new ScaleTransform
  1233. {
  1234. CenterX = imgCanvas.Width,
  1235. CenterY = imgCanvas.Height
  1236. };
  1237. ImgPrint.Visibility = Visibility.Visible;//截图成功可打印
  1238. ImgPrintTwo.Visibility = Visibility.Collapsed;
  1239. btnPrint.IsEnabled = true;
  1240. }
  1241. }
  1242. Topmost = false;
  1243. }
  1244. }
  1245. /// <summary>
  1246. /// 截图关闭 非正常关闭截图时,截图清空
  1247. /// </summary>
  1248. private void JietuWindow_click_closeJietuWindowClick()
  1249. {
  1250. if (WindowState == WindowState.Minimized)//截图完恢复窗口
  1251. {
  1252. WindowState = WindowState.Normal;
  1253. }
  1254. APP.W_JieTuWindow = null;
  1255. }
  1256. /// 截图的图片鼠标右键事件
  1257. /// </summary>
  1258. /// <param name="sender"></param>
  1259. /// <param name="e"></param>
  1260. private void imgCanvas_MouseRightButtonDown(object sender, MouseButtonEventArgs e)
  1261. {
  1262. imgCanvas.Source = null;
  1263. APP.PageDrawList[APP.pageData.currpage - 1].PdfImagePath = null;
  1264. APP.PageDrawList[APP.pageData.currpage - 1].PageImagePath = null;
  1265. }
  1266. /// <summary>
  1267. /// 导入事件
  1268. /// </summary>
  1269. /// <param name="sender"></param>
  1270. /// <param name="e"></param>
  1271. private void BtnImport_Click(object sender, RoutedEventArgs e)
  1272. {
  1273. try
  1274. {
  1275. Record();
  1276. HideAngleBorder();
  1277. string desktopPath = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
  1278. ofd = new System.Windows.Forms.OpenFileDialog
  1279. {
  1280. //Filter = "文档|*.docx;*.doc;*.ppt;*.pptx",
  1281. //增加导入图片
  1282. Filter = "文档|*.docx;*.doc;*.ppt;*.pptx;*.pdf|图片|*.jpg;*.jpeg;*.png;*.bmp",
  1283. InitialDirectory = desktopPath,
  1284. Multiselect = false,
  1285. AddExtension = true,
  1286. DereferenceLinks = true
  1287. };
  1288. //APP.myloading.Show();
  1289. APP.BackgroundWorkerHelper.RunWorkerAsync(InvokeServering, InvokeServerCompate);
  1290. //new Thread(
  1291. // o =>
  1292. // {
  1293. // Thread.Sleep(400);
  1294. // Dispatcher.Invoke(new Action(() =>
  1295. // {
  1296. // OpenDialog();
  1297. // }
  1298. // ));
  1299. // })
  1300. //{
  1301. // IsBackground = true
  1302. //}.Start();
  1303. }
  1304. catch (Exception ex)
  1305. {
  1306. LogHelper.WriteErrLog("【导入(BtnImport_Click)" + ex.Message, ex);
  1307. }
  1308. }
  1309. /// <summary>
  1310. /// 导入-开始
  1311. /// </summary>
  1312. /// <returns></returns>
  1313. private object InvokeServering()
  1314. {
  1315. Dispatcher.Invoke(new Action(() =>
  1316. {
  1317. result = ofd.ShowDialog();
  1318. }));
  1319. if (result == System.Windows.Forms.DialogResult.OK)
  1320. {
  1321. if (ofd.FileName != "")
  1322. {
  1323. List<string> imagelist = new List<string>() { "jpg", "jpeg", "png", "bmp" };
  1324. Dispatcher.Invoke(new Action(() =>
  1325. {
  1326. APP.myloading.Show();
  1327. myblackboard.changepage(APP.pageData.pagenum);
  1328. }));
  1329. string filepath = ofd.FileName;
  1330. string filesuff = filepath.Substring(filepath.LastIndexOf(".") + 1).ToLower();
  1331. string path = ofd.SafeFileName.Replace(".ppt", "").Replace(".pptx", "").Trim();
  1332. string type = ofd.SafeFileName.Replace(".ppt", "typezsygppt").Replace(".pptx", "typezsygppt").Replace(".pdf", "typepdf").Trim();
  1333. if (type.Contains("typezsygppt"))//ppt
  1334. {
  1335. try
  1336. {
  1337. #region PPT转PDF
  1338. string pathTemp = AppDomain.CurrentDomain.BaseDirectory + "Temp\\";
  1339. path = pathTemp + path + ".pdf";
  1340. FileToolsCommon.CreateDirectory(pathTemp);
  1341. //PPT转PDF
  1342. Presentation ppt = new Presentation(filepath);
  1343. ppt.Save(path, Aspose.Slides.Export.SaveFormat.Pdf);
  1344. #endregion
  1345. #region PDF转图片
  1346. // 图片绝对路径集合
  1347. List<string> images = new List<string>();
  1348. string directoryPath = pathTemp;
  1349. //aspose许可证
  1350. //Aspose.Pdf.License l = new Aspose.Pdf.License();
  1351. //string licenseName = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Aspose.Total.Product.Family.lic");
  1352. //l.SetLicense(licenseName);
  1353. //定义Jpeg转换设备
  1354. Aspose.Pdf.Document document = new Aspose.Pdf.Document(path);
  1355. Aspose.Pdf.Devices.JpegDevice device = new Aspose.Pdf.Devices.JpegDevice();
  1356. //int quality = int.Parse(this.comboBox1.SelectedItem.ToString());
  1357. //directoryPath += quality;
  1358. Directory.CreateDirectory(directoryPath);
  1359. //默认质量为100,设置质量的好坏与处理速度不成正比,甚至是设置的质量越低反而花的时间越长,怀疑处理过程是先生成高质量的再压缩
  1360. device = new Aspose.Pdf.Devices.JpegDevice(100);
  1361. //遍历每一页转为jpg
  1362. for (int i = 1; i <= document.Pages.Count; i++)
  1363. {
  1364. long ii = Timestamp();
  1365. string filePathOutPut = Path.Combine(directoryPath, string.Format("{0}{1}.jpg", ii, i));
  1366. images.Add(filePathOutPut);
  1367. FileStream fs = new FileStream(filePathOutPut, FileMode.OpenOrCreate);
  1368. try
  1369. {
  1370. device.Process(document.Pages[i], fs);
  1371. fs.Close();
  1372. }
  1373. catch (Exception)
  1374. {
  1375. fs.Close();
  1376. File.Delete(filePathOutPut);
  1377. }
  1378. }
  1379. #endregion
  1380. Dispatcher.Invoke(new Action(() =>
  1381. {
  1382. string[] page = images.ToArray();
  1383. int num = 0;
  1384. int iStart = APP.pageData.pagenum;//导入文档的开始下标
  1385. int iEnd = page.Length + APP.pageData.pagenum;//导入文档的结束下标
  1386. for (int i = 0 + APP.pageData.pagenum; i < page.Length + APP.pageData.pagenum; i++)//给画板模型加图片路径
  1387. {
  1388. if (APP.PageDrawList != null && APP.PageDrawList.Count > i)
  1389. {
  1390. APP.PageDrawList[i].PageImagePath = page[i - APP.pageData.pagenum]; //zxycs
  1391. APP.PageDrawList[i].PdfImagePath = page[i - APP.pageData.pagenum];
  1392. APP.PageDrawList[i].PageNum = i + 1;
  1393. APP.PageDrawList[i].ImgDocumentation = true;
  1394. APP.PageDrawList[i].Type = "ppt";
  1395. }
  1396. else
  1397. {
  1398. Model_DrawData model_DrawData = new Model_DrawData
  1399. {
  1400. PageImagePath = page[i - APP.pageData.pagenum],
  1401. PdfImagePath = page[i - APP.pageData.pagenum],
  1402. PageNum = i + 1,
  1403. ImgDocumentation = true,
  1404. Type = "ppt"
  1405. };
  1406. APP.PageDrawList.Add(model_DrawData);
  1407. }
  1408. ImgPrint.Visibility = Visibility.Visible;//导入成功可打印
  1409. ImgPrintTwo.Visibility = Visibility.Collapsed;
  1410. btnPrint.IsEnabled = true;
  1411. APP.SaveDraw();
  1412. num++;
  1413. }
  1414. if (num > 0)
  1415. {
  1416. APP.pageData.currpage = APP.pageData.pagenum + 1;
  1417. APP.pageData.pagenum += num;
  1418. gridPage.Visibility = Visibility.Visible;//页码大于0 显示
  1419. }
  1420. if (APP.pageData.currpage > 0 && APP.pageData.currpage <= APP.PageDrawList.Count)
  1421. {
  1422. imgCanvas.Source = null;
  1423. ImgScreenshot.Visibility = Visibility.Collapsed;//当前页为导入时不可截图
  1424. ImgScreenshotTwo.Visibility = Visibility.Visible;
  1425. btnScreenshot.IsEnabled = false;
  1426. imgDocumentation.Source = null;
  1427. imgPPT.Source = new BitmapImage(new Uri(APP.PageDrawList[APP.pageData.currpage - 1].PageImagePath));
  1428. scroMain.ScrollToVerticalOffset(0);
  1429. for (int i = iStart; i < iEnd; i++)
  1430. {
  1431. APP.PageDrawList[i].ImageLocation = new TranslateTransform
  1432. {
  1433. X = 0.1,
  1434. Y = 0.1
  1435. };
  1436. APP.PageDrawList[i].IsImageLocation = true;
  1437. APP.PageDrawList[i].ImageSizes = new ScaleTransform
  1438. {
  1439. CenterX = imgCanvas.Width,
  1440. CenterY = imgCanvas.Height
  1441. };
  1442. }
  1443. }
  1444. else
  1445. {
  1446. imgDocumentation.Source = null;
  1447. imgCanvas.Source = null;
  1448. imgPPT.Source = null;
  1449. ///截图可用
  1450. ImgScreenshot.Visibility = Visibility.Visible;
  1451. ImgScreenshotTwo.Visibility = Visibility.Collapsed;
  1452. btnScreenshot.IsEnabled = true;
  1453. }
  1454. }));
  1455. }
  1456. catch (Exception ex)
  1457. {
  1458. Dispatcher.Invoke(new Action(() =>
  1459. {
  1460. MessageWindow.Show("无法访问文件,请检查文件是否有效或解除文件占用!");
  1461. }));
  1462. LogHelper.WriteErrLog("【打开ppt】(OpenDialog PPT)" + ex.Message, ex);
  1463. }
  1464. }
  1465. else if (type.Contains("typepdf"))
  1466. {
  1467. try
  1468. {
  1469. string pathTemp = AppDomain.CurrentDomain.BaseDirectory + "Temp\\";
  1470. #region PDF转图片
  1471. // 图片绝对路径集合
  1472. List<string> images = new List<string>();
  1473. string directoryPath = pathTemp;
  1474. //aspose许可证
  1475. //Aspose.Pdf.License l = new Aspose.Pdf.License();
  1476. //string licenseName = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Aspose.Total.Product.Family.lic");
  1477. //l.SetLicense(licenseName);
  1478. //定义Jpeg转换设备
  1479. Aspose.Pdf.Document document = new Aspose.Pdf.Document(filepath);
  1480. Aspose.Pdf.Devices.JpegDevice device = new Aspose.Pdf.Devices.JpegDevice();
  1481. //int quality = int.Parse(this.comboBox1.SelectedItem.ToString());
  1482. //directoryPath += quality;
  1483. Directory.CreateDirectory(directoryPath);
  1484. //默认质量为100,设置质量的好坏与处理速度不成正比,甚至是设置的质量越低反而花的时间越长,怀疑处理过程是先生成高质量的再压缩
  1485. device = new Aspose.Pdf.Devices.JpegDevice(100);
  1486. //遍历每一页转为jpg
  1487. for (int i = 1; i <= document.Pages.Count; i++)
  1488. {
  1489. long ii = Timestamp();
  1490. string filePathOutPut = Path.Combine(directoryPath, string.Format("{0}{1}.jpg", ii, i));
  1491. images.Add(filePathOutPut);
  1492. FileStream fs = new FileStream(filePathOutPut, FileMode.OpenOrCreate);
  1493. try
  1494. {
  1495. device.Process(document.Pages[i], fs);
  1496. fs.Close();
  1497. }
  1498. catch (Exception)
  1499. {
  1500. fs.Close();
  1501. File.Delete(filePathOutPut);
  1502. }
  1503. }
  1504. #endregion
  1505. string[] page = images.ToArray();
  1506. int num = 0;
  1507. int iStart = APP.pageData.pagenum;//导入文档的开始下标
  1508. int iEnd = page.Length + APP.pageData.pagenum;//导入文档的结束下标
  1509. Dispatcher.Invoke(new Action(() =>
  1510. {
  1511. for (int i = APP.pageData.pagenum; i < page.Length + APP.pageData.pagenum; i++)//给画板模型加图片路径
  1512. {
  1513. if (APP.PageDrawList != null && APP.PageDrawList.Count > i)
  1514. {
  1515. APP.PageDrawList[i].PageImagePath = page[i - APP.pageData.pagenum]; //zxycs
  1516. APP.PageDrawList[i].PdfImagePath = page[i - APP.pageData.pagenum];
  1517. APP.PageDrawList[i].PageNum = i + 1;
  1518. APP.PageDrawList[i].ImgDocumentation = true;
  1519. APP.PageDrawList[i].Type = "word";
  1520. }
  1521. else
  1522. {
  1523. Model_DrawData model_DrawData = new Model_DrawData
  1524. {
  1525. PageImagePath = page[i - APP.pageData.pagenum],
  1526. PdfImagePath = page[i - APP.pageData.pagenum],
  1527. PageNum = i + 1,
  1528. ImgDocumentation = true,
  1529. Type = "word"
  1530. };
  1531. APP.PageDrawList.Add(model_DrawData);
  1532. }
  1533. ImgPrint.Visibility = Visibility.Visible;//导入成功可打印
  1534. ImgPrintTwo.Visibility = Visibility.Collapsed;
  1535. btnPrint.IsEnabled = true;
  1536. APP.SaveDraw();
  1537. num++;
  1538. }
  1539. if (num > 0)
  1540. {
  1541. APP.pageData.currpage = APP.pageData.pagenum + 1;
  1542. APP.pageData.pagenum += num;
  1543. gridPage.Visibility = Visibility.Visible;//页码大于0 显示
  1544. }
  1545. if (APP.pageData.currpage > 0 && APP.pageData.currpage <= APP.PageDrawList.Count)
  1546. {
  1547. imgCanvas.Source = null;
  1548. imgPPT.Source = null;
  1549. ImgScreenshot.Visibility = Visibility.Collapsed;//当前页为导入时不可截图
  1550. ImgScreenshotTwo.Visibility = Visibility.Visible;
  1551. btnScreenshot.IsEnabled = false;
  1552. imgDocumentation.Visibility = Visibility.Visible;
  1553. imgDocumentation.Source = new BitmapImage(new Uri(APP.PageDrawList[APP.pageData.currpage - 1].PageImagePath));//给当前页面展示图片
  1554. scroMain.ScrollToVerticalOffset(0);
  1555. }
  1556. else
  1557. {
  1558. imgDocumentation.Source = null;
  1559. imgCanvas.Source = null;
  1560. imgPPT.Source = null;
  1561. ///截图可用
  1562. ImgScreenshot.Visibility = Visibility.Visible;
  1563. ImgScreenshotTwo.Visibility = Visibility.Collapsed;
  1564. btnScreenshot.IsEnabled = true;
  1565. }
  1566. }));
  1567. }
  1568. catch (Exception ex)
  1569. {
  1570. Dispatcher.Invoke(new Action(() =>
  1571. {
  1572. MessageWindow.Show(ex.Message);
  1573. }));
  1574. LogHelper.WriteErrLog("【打开pdf】(OpenDialog pdf)" + ex.Message, ex);
  1575. }
  1576. }
  1577. else if(imagelist.Contains(filesuff))///导入图片
  1578. {
  1579. string imagepath = AppDomain.CurrentDomain.BaseDirectory + "temp";
  1580. if (!Directory.Exists(imagepath))
  1581. {
  1582. Directory.CreateDirectory(imagepath);
  1583. }
  1584. TimeSpan ts = DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0);
  1585. string timestr = Convert.ToInt64(ts.TotalMilliseconds).ToString();
  1586. string filepathCopy = Path.Combine(imagepath, timestr + ofd.SafeFileName);
  1587. System.IO.File.Copy(filepath, filepathCopy);
  1588. filepath = filepathCopy;
  1589. APP.ImgPath = filepath;
  1590. Dispatcher.Invoke(new Action(() =>
  1591. {
  1592. if (APP.pageData.currpage == 0)
  1593. {
  1594. APP.pageData.pagenum += 1;
  1595. APP.pageData.currpage = APP.pageData.pagenum;
  1596. myblackboard.changepage(APP.pageData.currpage - 1);
  1597. gridPage.Visibility = Visibility.Visible;//页码大于0 显示
  1598. #region 插入页码
  1599. PageData = new List<PageData>();
  1600. for (int i = 1; i <= APP.pageData.pagenum; i++)
  1601. {
  1602. PageData pd = new PageData();
  1603. pd.PageName = i.ToString();// + "页";
  1604. pd.PageCode = i;
  1605. PageData.Add(pd);
  1606. }
  1607. CbxPageList.ItemsSource = PageData;
  1608. CbxPageList.SelectedIndex = APP.pageData.currpage - 1;
  1609. #endregion
  1610. }
  1611. else
  1612. {
  1613. APP.pageData.pagenum += 1;
  1614. APP.pageData.currpage = APP.pageData.pagenum;
  1615. myblackboard.changepage(APP.pageData.currpage - 1);
  1616. }
  1617. if (APP.PageDrawList.Count >= APP.pageData.currpage)
  1618. {
  1619. APP.PageDrawList[APP.pageData.currpage - 1].PageImagePath = APP.ImgPath;//zxycs
  1620. APP.PageDrawList[APP.pageData.currpage - 1].PdfImagePath = APP.ImgPath;
  1621. }
  1622. else
  1623. {
  1624. Model_DrawData model_DrawData = new Model_DrawData
  1625. {
  1626. PageImagePath = APP.ImgPath,
  1627. PdfImagePath = APP.ImgPath
  1628. };
  1629. APP.PageDrawList.Add(model_DrawData);
  1630. }
  1631. if (APP.PageDrawList.Count >= APP.pageData.currpage && !string.IsNullOrWhiteSpace(APP.PageDrawList[APP.pageData.currpage - 1].PageImagePath))
  1632. {
  1633. imgDocumentation.Source = null;
  1634. BitmapImage bitImg = new BitmapImage(new Uri(APP.PageDrawList[APP.pageData.currpage - 1].PageImagePath));
  1635. mouseDown = false;
  1636. APP.PageDrawList[APP.pageData.currpage - 1].ImageLocation = new TranslateTransform
  1637. {
  1638. X = 0.1,
  1639. Y = 0.1
  1640. };
  1641. APP.PageDrawList[APP.pageData.currpage - 1].Type = "截图";
  1642. APP.PageDrawList[APP.pageData.currpage - 1].IsImageLocation = false;
  1643. imgCanvas.Source = bitImg;
  1644. imgCanvas.Width = bitImg.Width;
  1645. imgCanvas.Height = bitImg.Height;
  1646. scroMain.ScrollToVerticalOffset(0);
  1647. imgCanvas.Margin = new Thickness(APP.PageDrawList[APP.pageData.currpage - 1].ImageLocation.X, APP.PageDrawList[APP.pageData.currpage - 1].ImageLocation.Y, 0, 0);
  1648. APP.PageDrawList[APP.pageData.currpage - 1].ImageSizes = new ScaleTransform
  1649. {
  1650. CenterX = imgCanvas.Width,
  1651. CenterY = imgCanvas.Height
  1652. };
  1653. ImgPrint.Visibility = Visibility.Visible;//截图成功可打印
  1654. ImgPrintTwo.Visibility = Visibility.Collapsed;
  1655. btnPrint.IsEnabled = true;
  1656. }
  1657. }));
  1658. }
  1659. else//word
  1660. {
  1661. try
  1662. {
  1663. string paths = AppDomain.CurrentDomain.BaseDirectory + "Temp\\";
  1664. string[] page = ConvertWordToImage(filepath, paths, "", 0, 0, null, 0).ToArray();
  1665. int num = 0;
  1666. Dispatcher.Invoke(new Action(() =>
  1667. {
  1668. for (int i = 0 + APP.pageData.pagenum; i < page.Length + APP.pageData.pagenum; i++)//给画板模型加图片路径
  1669. {
  1670. if (APP.PageDrawList != null && APP.PageDrawList.Count > i)
  1671. {
  1672. APP.PageDrawList[i].PageImagePath = page[i - APP.pageData.pagenum]; //zxycs
  1673. APP.PageDrawList[i].PdfImagePath = page[i - APP.pageData.pagenum];
  1674. APP.PageDrawList[i].PageNum = i + 1;
  1675. APP.PageDrawList[i].ImgDocumentation = true;
  1676. APP.PageDrawList[i].Type = "word";
  1677. }
  1678. else
  1679. {
  1680. Model_DrawData model_DrawData = new Model_DrawData
  1681. {
  1682. PageImagePath = page[i - APP.pageData.pagenum],
  1683. PdfImagePath = page[i - APP.pageData.pagenum],
  1684. PageNum = i + 1,
  1685. ImgDocumentation = true,
  1686. Type = "word"
  1687. };
  1688. APP.PageDrawList.Add(model_DrawData);
  1689. }
  1690. ImgPrint.Visibility = Visibility.Visible;//导入成功可打印
  1691. ImgPrintTwo.Visibility = Visibility.Collapsed;
  1692. btnPrint.IsEnabled = true;
  1693. APP.SaveDraw();
  1694. num++;
  1695. }
  1696. if (num > 0)
  1697. {
  1698. APP.pageData.currpage = APP.pageData.pagenum + 1;
  1699. APP.pageData.pagenum += num;
  1700. gridPage.Visibility = Visibility.Visible;//页码大于0 显示
  1701. }
  1702. if (APP.pageData.currpage > 0 && APP.pageData.currpage <= APP.PageDrawList.Count)
  1703. {
  1704. imgCanvas.Source = null;
  1705. imgPPT.Source = null;
  1706. ImgScreenshot.Visibility = Visibility.Collapsed;//当前页为导入时不可截图
  1707. ImgScreenshotTwo.Visibility = Visibility.Visible;
  1708. btnScreenshot.IsEnabled = false;
  1709. imgDocumentation.Visibility = Visibility.Visible;
  1710. imgDocumentation.Source = new BitmapImage(new Uri(APP.PageDrawList[APP.pageData.currpage - 1].PageImagePath));//给当前页面展示图片
  1711. scroMain.ScrollToVerticalOffset(0);
  1712. }
  1713. else
  1714. {
  1715. imgDocumentation.Source = null;
  1716. imgCanvas.Source = null;
  1717. imgPPT.Source = null;
  1718. ///截图可用
  1719. ImgScreenshot.Visibility = Visibility.Visible;
  1720. ImgScreenshotTwo.Visibility = Visibility.Collapsed;
  1721. btnScreenshot.IsEnabled = true;
  1722. }
  1723. }));
  1724. }
  1725. catch (Exception ex)
  1726. {
  1727. Dispatcher.Invoke(new Action(() =>
  1728. {
  1729. MessageWindow.Show("无法访问文件,请检查文件是否有效或解除文件占用!");
  1730. }));
  1731. LogHelper.WriteErrLog("【XHMicroLessonSystemWindow】(OpenDialog 导入文档)" + ex.Message, ex);
  1732. }
  1733. }
  1734. #region 插入页码
  1735. Dispatcher.Invoke(new Action(() =>
  1736. {
  1737. PageData = new List<PageData>();
  1738. for (int i = 1; i <= APP.pageData.pagenum; i++)
  1739. {
  1740. PageData pd = new PageData();
  1741. pd.PageName = i.ToString();//+ "页";
  1742. pd.PageCode = i;
  1743. PageData.Add(pd);
  1744. }
  1745. CbxPageList.ItemsSource = PageData;
  1746. CbxPageList.SelectedIndex = APP.pageData.currpage - 1;
  1747. }));
  1748. #endregion
  1749. }
  1750. }
  1751. //OpenDialog();
  1752. return "";
  1753. }
  1754. /// <summary>
  1755. /// 导入-结束
  1756. /// </summary>
  1757. /// <returns></returns>
  1758. public void InvokeServerCompate(object obj)
  1759. {
  1760. //APP.myloading.Hide();
  1761. APP.myloading.Hide();
  1762. }
  1763. /// <summary>
  1764. /// 导入文档
  1765. /// </summary>
  1766. private void OpenDialog()
  1767. {
  1768. Dispatcher.Invoke(new Action(() =>
  1769. {
  1770. result = ofd.ShowDialog();
  1771. if (result == System.Windows.Forms.DialogResult.OK)
  1772. {
  1773. if (ofd.FileName != "")
  1774. {
  1775. APP.myloading.Show();
  1776. myblackboard.changepage(APP.pageData.pagenum);
  1777. #region PPT转PDF
  1778. string filepath = ofd.FileName;
  1779. string path = ofd.SafeFileName.Replace(".ppt", "").Replace(".pptx", "").Trim();
  1780. string type = ofd.SafeFileName.Replace(".ppt", "typezsygppt").Replace(".pptx", "typezsygppt").Replace(".pdf", "typepdf").Trim();
  1781. if (type.Contains("typezsygppt"))//ppt
  1782. {
  1783. try
  1784. {
  1785. string pathTemp = AppDomain.CurrentDomain.BaseDirectory + "Temp\\";
  1786. path = pathTemp + path + ".pdf";
  1787. FileToolsCommon.CreateDirectory(pathTemp);
  1788. //PPT转PDF
  1789. Presentation ppt = new Presentation(filepath);
  1790. ppt.Save(path, Aspose.Slides.Export.SaveFormat.Pdf);
  1791. #endregion
  1792. #region PDF转图片
  1793. // 图片绝对路径集合
  1794. List<string> images = new List<string>();
  1795. string directoryPath = pathTemp;
  1796. //aspose许可证
  1797. //Aspose.Pdf.License l = new Aspose.Pdf.License();
  1798. //string licenseName = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Aspose.Total.Product.Family.lic");
  1799. //l.SetLicense(licenseName);
  1800. //定义Jpeg转换设备
  1801. Aspose.Pdf.Document document = new Aspose.Pdf.Document(path);
  1802. Aspose.Pdf.Devices.JpegDevice device = new Aspose.Pdf.Devices.JpegDevice();
  1803. //int quality = int.Parse(this.comboBox1.SelectedItem.ToString());
  1804. //directoryPath += quality;
  1805. Directory.CreateDirectory(directoryPath);
  1806. //默认质量为100,设置质量的好坏与处理速度不成正比,甚至是设置的质量越低反而花的时间越长,怀疑处理过程是先生成高质量的再压缩
  1807. device = new Aspose.Pdf.Devices.JpegDevice(100);
  1808. //遍历每一页转为jpg
  1809. for (int i = 1; i <= document.Pages.Count; i++)
  1810. {
  1811. long ii = Timestamp();
  1812. string filePathOutPut = Path.Combine(directoryPath, string.Format("{0}{1}.jpg", ii, i));
  1813. images.Add(filePathOutPut);
  1814. FileStream fs = new FileStream(filePathOutPut, FileMode.OpenOrCreate);
  1815. try
  1816. {
  1817. device.Process(document.Pages[i], fs);
  1818. fs.Close();
  1819. }
  1820. catch (Exception)
  1821. {
  1822. fs.Close();
  1823. File.Delete(filePathOutPut);
  1824. }
  1825. }
  1826. #endregion
  1827. string[] page = images.ToArray();
  1828. int num = 0;
  1829. for (int i = 0 + APP.pageData.pagenum; i < page.Length + APP.pageData.pagenum; i++)//给画板模型加图片路径
  1830. {
  1831. if (APP.PageDrawList != null && APP.PageDrawList.Count > i)
  1832. {
  1833. APP.PageDrawList[i].PageImagePath = page[i - APP.pageData.pagenum]; //zxycs
  1834. APP.PageDrawList[i].PdfImagePath = page[i - APP.pageData.pagenum];
  1835. APP.PageDrawList[i].PageNum = i + 1;
  1836. APP.PageDrawList[i].ImgDocumentation = true;
  1837. }
  1838. else
  1839. {
  1840. Model_DrawData model_DrawData = new Model_DrawData
  1841. {
  1842. PageImagePath = page[i - APP.pageData.pagenum],
  1843. PdfImagePath = page[i - APP.pageData.pagenum],
  1844. PageNum = i + 1,
  1845. ImgDocumentation = true
  1846. };
  1847. APP.PageDrawList.Add(model_DrawData);
  1848. }
  1849. ImgPrint.Visibility = Visibility.Visible;//导入成功可打印
  1850. ImgPrintTwo.Visibility = Visibility.Collapsed;
  1851. btnPrint.IsEnabled = true;
  1852. APP.SaveDraw();
  1853. num++;
  1854. }
  1855. if (num > 0)
  1856. {
  1857. APP.pageData.currpage = APP.pageData.pagenum + 1;
  1858. APP.pageData.pagenum += num;
  1859. gridPage.Visibility = Visibility.Visible;//页码大于0 显示
  1860. }
  1861. if (APP.pageData.currpage > 0 && APP.pageData.currpage < APP.PageDrawList.Count)
  1862. {
  1863. imgCanvas.Source = null;
  1864. ImgScreenshot.Visibility = Visibility.Collapsed;//当前页为导入时不可截图
  1865. ImgScreenshotTwo.Visibility = Visibility.Visible;
  1866. btnScreenshot.IsEnabled = false;
  1867. imgDocumentation.Source = new BitmapImage(new Uri(APP.PageDrawList[APP.pageData.currpage - 1].PageImagePath));//给当前页面展示图片
  1868. }
  1869. else
  1870. {
  1871. imgDocumentation.Source = null;
  1872. imgCanvas.Source = null;
  1873. ///截图可用
  1874. ImgScreenshot.Visibility = Visibility.Visible;
  1875. ImgScreenshotTwo.Visibility = Visibility.Collapsed;
  1876. btnScreenshot.IsEnabled = true;
  1877. }
  1878. APP.myloading.Hide();
  1879. }
  1880. catch (Exception ex)
  1881. {
  1882. APP.myloading.Hide();
  1883. MessageWindow.Show("无法访问文件,请检查文件是否有效或解除文件占用!");
  1884. LogHelper.WriteErrLog("【打开ppt】(OpenDialog PPT)" + ex.Message, ex);
  1885. }
  1886. }
  1887. else if (type.Contains("typepdf"))
  1888. {
  1889. string pathTemp = AppDomain.CurrentDomain.BaseDirectory + "Temp\\";
  1890. #region PDF转图片
  1891. // 图片绝对路径集合
  1892. List<string> images = new List<string>();
  1893. string directoryPath = pathTemp;
  1894. //aspose许可证
  1895. //Aspose.Pdf.License l = new Aspose.Pdf.License();
  1896. //string licenseName = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Aspose.Total.Product.Family.lic");
  1897. //l.SetLicense(licenseName);
  1898. //定义Jpeg转换设备
  1899. Aspose.Pdf.Document document = new Aspose.Pdf.Document(filepath);
  1900. Aspose.Pdf.Devices.JpegDevice device = new Aspose.Pdf.Devices.JpegDevice();
  1901. //int quality = int.Parse(this.comboBox1.SelectedItem.ToString());
  1902. //directoryPath += quality;
  1903. Directory.CreateDirectory(directoryPath);
  1904. //默认质量为100,设置质量的好坏与处理速度不成正比,甚至是设置的质量越低反而花的时间越长,怀疑处理过程是先生成高质量的再压缩
  1905. device = new Aspose.Pdf.Devices.JpegDevice(100);
  1906. //遍历每一页转为jpg
  1907. for (int i = 1; i <= document.Pages.Count; i++)
  1908. {
  1909. long ii = Timestamp();
  1910. string filePathOutPut = Path.Combine(directoryPath, string.Format("{0}{1}.jpg", ii, i));
  1911. images.Add(filePathOutPut);
  1912. FileStream fs = new FileStream(filePathOutPut, FileMode.OpenOrCreate);
  1913. try
  1914. {
  1915. device.Process(document.Pages[i], fs);
  1916. fs.Close();
  1917. }
  1918. catch (Exception)
  1919. {
  1920. fs.Close();
  1921. File.Delete(filePathOutPut);
  1922. }
  1923. }
  1924. #endregion
  1925. string[] page = images.ToArray();
  1926. int num = 0;
  1927. for (int i = 0 + APP.pageData.pagenum; i < page.Length + APP.pageData.pagenum; i++)//给画板模型加图片路径
  1928. {
  1929. if (APP.PageDrawList != null && APP.PageDrawList.Count > i)
  1930. {
  1931. APP.PageDrawList[i].PageImagePath = page[i - APP.pageData.pagenum]; //zxycs
  1932. APP.PageDrawList[i].PdfImagePath = page[i - APP.pageData.pagenum];
  1933. APP.PageDrawList[i].PageNum = i + 1;
  1934. APP.PageDrawList[i].ImgDocumentation = true;
  1935. }
  1936. else
  1937. {
  1938. Model_DrawData model_DrawData = new Model_DrawData
  1939. {
  1940. PageImagePath = page[i - APP.pageData.pagenum],
  1941. PdfImagePath = page[i - APP.pageData.pagenum],
  1942. PageNum = i + 1,
  1943. ImgDocumentation = true
  1944. };
  1945. APP.PageDrawList.Add(model_DrawData);
  1946. }
  1947. ImgPrint.Visibility = Visibility.Visible;//导入成功可打印
  1948. ImgPrintTwo.Visibility = Visibility.Collapsed;
  1949. btnPrint.IsEnabled = true;
  1950. APP.SaveDraw();
  1951. num++;
  1952. }
  1953. if (num > 0)
  1954. {
  1955. APP.pageData.currpage = APP.pageData.pagenum + 1;
  1956. APP.pageData.pagenum += num;
  1957. gridPage.Visibility = Visibility.Visible;//页码大于0 显示
  1958. }
  1959. if (APP.pageData.currpage > 0 && APP.pageData.currpage < APP.PageDrawList.Count)
  1960. {
  1961. imgCanvas.Source = null;
  1962. ImgScreenshot.Visibility = Visibility.Collapsed;//当前页为导入时不可截图
  1963. ImgScreenshotTwo.Visibility = Visibility.Visible;
  1964. btnScreenshot.IsEnabled = false;
  1965. imgDocumentation.Source = new BitmapImage(new Uri(APP.PageDrawList[APP.pageData.currpage - 1].PageImagePath));//给当前页面展示图片
  1966. }
  1967. else
  1968. {
  1969. imgDocumentation.Source = null;
  1970. imgCanvas.Source = null;
  1971. ///截图可用
  1972. ImgScreenshot.Visibility = Visibility.Visible;
  1973. ImgScreenshotTwo.Visibility = Visibility.Collapsed;
  1974. btnScreenshot.IsEnabled = true;
  1975. }
  1976. APP.myloading.Hide();
  1977. }
  1978. else//word
  1979. {
  1980. try
  1981. {
  1982. string paths = AppDomain.CurrentDomain.BaseDirectory + "Temp\\";
  1983. string[] page = ConvertWordToImage(filepath, paths, "", 0, 0, null, 0).ToArray();
  1984. int num = 0;
  1985. for (int i = 0 + APP.pageData.pagenum; i < page.Length + APP.pageData.pagenum; i++)//给画板模型加图片路径
  1986. {
  1987. if (APP.PageDrawList != null && APP.PageDrawList.Count > i)
  1988. {
  1989. APP.PageDrawList[i].PageImagePath = page[i - APP.pageData.pagenum]; //zxycs
  1990. APP.PageDrawList[i].PdfImagePath = page[i - APP.pageData.pagenum];
  1991. APP.PageDrawList[i].PageNum = i + 1;
  1992. APP.PageDrawList[i].ImgDocumentation = true;
  1993. }
  1994. else
  1995. {
  1996. Model_DrawData model_DrawData = new Model_DrawData
  1997. {
  1998. PageImagePath = page[i - APP.pageData.pagenum],
  1999. PdfImagePath = page[i - APP.pageData.pagenum],
  2000. PageNum = i + 1,
  2001. ImgDocumentation = true
  2002. };
  2003. APP.PageDrawList.Add(model_DrawData);
  2004. }
  2005. ImgPrint.Visibility = Visibility.Visible;//导入成功可打印
  2006. ImgPrintTwo.Visibility = Visibility.Collapsed;
  2007. btnPrint.IsEnabled = true;
  2008. APP.SaveDraw();
  2009. num++;
  2010. }
  2011. if (num > 0)
  2012. {
  2013. APP.pageData.currpage = APP.pageData.pagenum + 1;
  2014. APP.pageData.pagenum += num;
  2015. gridPage.Visibility = Visibility.Visible;//页码大于0 显示
  2016. }
  2017. if (APP.pageData.currpage > 0 && APP.pageData.currpage < APP.PageDrawList.Count)
  2018. {
  2019. imgCanvas.Source = null;
  2020. ImgScreenshot.Visibility = Visibility.Collapsed;//当前页为导入时不可截图
  2021. ImgScreenshotTwo.Visibility = Visibility.Visible;
  2022. btnScreenshot.IsEnabled = false;
  2023. imgDocumentation.Visibility = Visibility.Visible;
  2024. imgDocumentation.Source = new BitmapImage(new Uri(APP.PageDrawList[APP.pageData.currpage - 1].PageImagePath));//给当前页面展示图片
  2025. }
  2026. else
  2027. {
  2028. imgDocumentation.Source = null;
  2029. imgCanvas.Source = null;
  2030. ///截图可用
  2031. ImgScreenshot.Visibility = Visibility.Visible;
  2032. ImgScreenshotTwo.Visibility = Visibility.Collapsed;
  2033. btnScreenshot.IsEnabled = true;
  2034. }
  2035. APP.myloading.Hide();
  2036. }
  2037. catch (Exception ex)
  2038. {
  2039. APP.myloading.Hide();
  2040. LogHelper.WriteErrLog("【XHMicroLessonSystemWindow】(OpenDialog 导入文档)" + ex.Message, ex);
  2041. }
  2042. }
  2043. }
  2044. }
  2045. }
  2046. ));
  2047. }
  2048. #region 导入转换图片
  2049. /// <summary>
  2050. /// 生成图片
  2051. /// </summary>
  2052. /// <param name="_path">图片地址</param>
  2053. /// <param name="_saveimg">保存位置</param>
  2054. /// <param name="_rectangle">图片位置</param>
  2055. /// <param name="errmsg">错误消息</param>
  2056. /// <returns></returns>
  2057. private bool MergerImg(string _path, string _saveimg, RectangleF _rectangle, out string errmsg)
  2058. {
  2059. errmsg = null;
  2060. try
  2061. {
  2062. Bitmap bitmap = null;
  2063. //创建要显示的图片对象,根据参数的个数设置宽度
  2064. Bitmap backgroudImg = new Bitmap((int)gridM.ActualWidth, (int)gridM.ActualHeight);
  2065. Graphics g = Graphics.FromImage(backgroudImg);
  2066. //清除画布,背景设置为白色
  2067. g.Clear(System.Drawing.Color.White);
  2068. if (!string.IsNullOrWhiteSpace(_path))
  2069. {
  2070. bitmap = ImageHelper.ReadBitmapFile(_path);
  2071. g.DrawImage(bitmap, _rectangle);
  2072. }
  2073. backgroudImg.Save(_saveimg);
  2074. g.Dispose();
  2075. backgroudImg.Dispose();
  2076. if (bitmap != null)
  2077. {
  2078. bitmap.Dispose();
  2079. }
  2080. GC.Collect();
  2081. return true;
  2082. }
  2083. catch (Exception ex)
  2084. {
  2085. errmsg = ex.Message;
  2086. LogHelper.WriteErrLog("【截图合成】(MergerImg)图片合成失败:" + ex.Message, ex);
  2087. return false;
  2088. }
  2089. }
  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) + "_" + APP.num.ToString() + "." + imageFormat.ToString(), imageSaveOptions);
  2129. images.Add(System.IO.Path.Combine(imageOutputPath, imageName) + "_" + APP.num.ToString() + "." + imageFormat.ToString());
  2130. APP.num++;
  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 SaveFormat GetSaveFormat(ImageFormat imageFormat)
  2150. {
  2151. SaveFormat sf;// = SaveFormat.Unknown;
  2152. if (imageFormat.Equals(ImageFormat.Png))
  2153. {
  2154. sf = SaveFormat.Png;
  2155. }
  2156. else if (imageFormat.Equals(ImageFormat.Jpeg))
  2157. {
  2158. sf = SaveFormat.Jpeg;
  2159. }
  2160. else if (imageFormat.Equals(ImageFormat.Tiff))
  2161. {
  2162. sf = SaveFormat.Tiff;
  2163. }
  2164. else if (imageFormat.Equals(ImageFormat.Bmp))
  2165. {
  2166. sf = SaveFormat.Bmp;
  2167. }
  2168. else
  2169. {
  2170. sf = 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. if (APP.pageData.pagenum > 0)
  2212. {
  2213. gridPage.Visibility = Visibility.Visible;
  2214. }
  2215. DataContext = APP.pageData;
  2216. }
  2217. else
  2218. {
  2219. gridSetUp.Visibility = Visibility.Collapsed;
  2220. gridPage.Visibility = Visibility.Collapsed;
  2221. GridMyVideo.Visibility = Visibility.Visible;
  2222. GridMain.Visibility = Visibility.Collapsed;
  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. #endregion
  2833. /// <summary>
  2834. /// 初始化加载上传页面数据
  2835. /// </summary>
  2836. private void LoadUploadInitData()
  2837. {
  2838. APP.myloading.Show();
  2839. //加载视频列表
  2840. LoadingVideoList();
  2841. if (model_VideoList.Count > 0)
  2842. {
  2843. lblVideoMess.Visibility = Visibility.Hidden;
  2844. BtnVideoUpPage.Visibility = Visibility.Visible;
  2845. lblVideoPageNum.Visibility = Visibility.Visible;
  2846. BtnVideoDownPage.Visibility = Visibility.Visible;
  2847. //根据页面大小获取每页显示的数量 H300W250
  2848. int videoRow = (int)((GridMyVideo.ActualHeight - 50) / 300);
  2849. int videColumn = (int)(GridMyVideo.ActualWidth / 250);
  2850. PageShowNum = (videoRow == 0 ? 1 : videoRow) * (videColumn == 0 ? 1 : videColumn);
  2851. //获取总页数
  2852. TotalPage = model_VideoList.Count / PageShowNum + (model_VideoList.Count % PageShowNum > 0 ? 1 : 0);
  2853. //如果当前页大于总页数 总页数为当前页
  2854. if (TotalPage < CurrentPage)
  2855. {
  2856. CurrentPage = TotalPage;
  2857. }
  2858. //横向间隔
  2859. IntervalX = (GridMyVideo.ActualWidth - (videColumn * 250)) / (videColumn + 1);
  2860. IntervalY = (GridMyVideo.ActualHeight - 50 - (videoRow * 300)) / (videoRow + 1);
  2861. LoadCurrentPageData();
  2862. }
  2863. else
  2864. {
  2865. lblVideoMess.Visibility = Visibility.Visible;
  2866. BtnVideoUpPage.Visibility = Visibility.Hidden;
  2867. lblVideoPageNum.Visibility = Visibility.Hidden;
  2868. BtnVideoDownPage.Visibility = Visibility.Hidden;
  2869. //隐藏显示的控件
  2870. if (VideoControlList.Count > 0)
  2871. {
  2872. foreach (Uc_VideoItem item in VideoControlList)
  2873. {
  2874. if (item.Visibility != Visibility.Hidden)
  2875. {
  2876. item.Visibility = Visibility.Hidden;
  2877. }
  2878. }
  2879. }
  2880. }
  2881. APP.myloading.Hide();
  2882. }
  2883. /// <summary>
  2884. /// 加载当前页数据
  2885. /// </summary>
  2886. private void LoadCurrentPageData()
  2887. {
  2888. lblVideoPageNum.Content = CurrentPage + "/" + TotalPage;
  2889. //隐藏显示的控件
  2890. if (VideoControlList.Count > 0)
  2891. {
  2892. foreach (Uc_VideoItem item in VideoControlList)
  2893. {
  2894. if (item.Visibility != Visibility.Hidden)
  2895. {
  2896. item.Visibility = Visibility.Hidden;
  2897. }
  2898. }
  2899. }
  2900. double W = IntervalX;//每次增加250
  2901. double H = IntervalY;//每次增加300
  2902. //加载控件
  2903. for (int i = 0; i < PageShowNum; i++)
  2904. {
  2905. int DataIndex = (CurrentPage - 1) * PageShowNum + i;
  2906. if (DataIndex == model_VideoList.Count)
  2907. {
  2908. return;
  2909. }
  2910. Uc_VideoItem videoItem;
  2911. if (VideoControlList.Exists(x => x.Tag.ToString() == model_VideoList[DataIndex].FileGuid))
  2912. {
  2913. videoItem = VideoControlList.Find(x => x.Tag.ToString() == model_VideoList[DataIndex].FileGuid);
  2914. }
  2915. else
  2916. {
  2917. if (!FileToolsCommon.IsExistFile(model_VideoList[DataIndex].ThumbnailPath))
  2918. {
  2919. continue;
  2920. }
  2921. videoItem = new Uc_VideoItem(model_VideoList[DataIndex])
  2922. {
  2923. Tag = model_VideoList[DataIndex].FileGuid
  2924. };
  2925. videoItem.Click_refreshVideoList += LoadUploadInitData;
  2926. videoItem.Click_UploadLogin += Login;
  2927. videoItem.Width = 250;
  2928. videoItem.Height = 300;
  2929. videoItem.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
  2930. videoItem.VerticalAlignment = System.Windows.VerticalAlignment.Top;
  2931. GridMyVideo.Children.Add(videoItem);
  2932. VideoControlList.Add(videoItem);
  2933. }
  2934. videoItem.Margin = new Thickness(W, H, 0, 0);
  2935. videoItem.Visibility = Visibility.Visible;
  2936. if (W + 250 + 250 > GridMyVideo.ActualWidth)
  2937. {
  2938. W = IntervalX;
  2939. H += 300 + IntervalY;
  2940. }
  2941. else
  2942. {
  2943. W += 250 + IntervalX;
  2944. }
  2945. //Uc_VideoItem videoItem = new Uc_VideoItem();
  2946. //return;
  2947. }
  2948. }
  2949. #region 分页
  2950. /// <summary>
  2951. /// 上一页
  2952. /// </summary>
  2953. /// <param name="sender"></param>
  2954. /// <param name="e"></param>
  2955. private void BtnVideoUpPage_Click(object sender, RoutedEventArgs e)
  2956. {
  2957. if (CurrentPage > 1)
  2958. {
  2959. CurrentPage--;
  2960. LoadCurrentPageData();
  2961. }
  2962. }
  2963. /// <summary>
  2964. /// 下一页
  2965. /// </summary>
  2966. /// <param name="sender"></param>
  2967. /// <param name="e"></param>
  2968. private void BtnVideoDownPage_Click(object sender, RoutedEventArgs e)
  2969. {
  2970. if (CurrentPage < TotalPage)
  2971. {
  2972. CurrentPage++;
  2973. LoadCurrentPageData();
  2974. }
  2975. }
  2976. #endregion
  2977. #endregion
  2978. #region 录制窗口
  2979. #region 变量
  2980. /// <summary>
  2981. /// 视频保存路径
  2982. /// </summary>
  2983. //string RecordingPath;
  2984. /// <summary>
  2985. /// 图片保存路径
  2986. /// </summary>
  2987. private string ImgPath;
  2988. /// <summary>
  2989. /// 音频保存路径名
  2990. /// </summary>
  2991. private string AudioPathName;
  2992. /// <summary>
  2993. /// 视频保存路径名
  2994. /// </summary>
  2995. private string VideoSavePathName;
  2996. /// <summary>
  2997. /// 视频合成路径名
  2998. /// </summary>
  2999. private string VideoSynthesisPathName;
  3000. /// <summary>
  3001. /// 暂停录制
  3002. /// </summary>
  3003. private bool IsSuspendR = true;
  3004. /// <summary>
  3005. /// 录制是否已停止
  3006. /// </summary>
  3007. private bool IsFirstR = true;
  3008. /// <summary>
  3009. /// 图片
  3010. /// </summary>
  3011. private List<string> RsImgName = null;
  3012. /// <summary>
  3013. /// 是否开始截图计数
  3014. /// </summary>
  3015. private bool IsStartCount = false;
  3016. /// <summary>
  3017. /// 是否录制了音频
  3018. /// </summary>
  3019. private bool IsRecordAudio = false;
  3020. /// <summary>
  3021. /// 截图定时器
  3022. /// </summary>
  3023. private System.Threading.Timer timer;
  3024. /// <summary>
  3025. /// 录制计时
  3026. /// </summary>
  3027. private DateTime SRTime = DateTime.Now;
  3028. /// <summary>
  3029. /// 录制大小
  3030. /// </summary>
  3031. private int gridActWidth = 1276;
  3032. /// <summary>
  3033. /// 录制大小
  3034. /// </summary>
  3035. private int gridActHeight = 898;
  3036. #endregion
  3037. #region 录屏
  3038. /// <summary>
  3039. /// 录屏事件
  3040. /// </summary>
  3041. /// <param name="sender"></param>
  3042. /// <param name="e"></param>
  3043. private void BtnScreenRecording_Click(object sender, RoutedEventArgs e)
  3044. {
  3045. Record();
  3046. if (!APP.CheckScreenCapturerRecorder())
  3047. {
  3048. MessageWindow.Show("使用此功能需安装环境,请在确定后依次点击“OK-Next>-Next>Install”完成安装!");
  3049. APP.InstallScreenCapturerRecorder();
  3050. return;
  3051. }
  3052. #region 限制只允许录制一个录屏 废弃
  3053. //string RecordScreenPathName = APP.WKData.WkPath + APP.WKData.WkName + "_录屏." + ((Enum_VideoType)int.Parse(FileToolsCommon.GetConfigValue("VideoType"))).ToString();
  3054. //if (FileToolsCommon.IsExistFile(RecordScreenPathName))
  3055. //{
  3056. // MessageBoxResult dr = MessageWindow.Show("已存在录屏,是否覆盖?", "提示", MessageBoxButton.OKCancel);
  3057. // if (dr == MessageBoxResult.OK)
  3058. // {
  3059. // try
  3060. // {
  3061. // FileToolsCommon.DeleteFile(RecordScreenPathName);
  3062. // APP.VideoList.RemoveAll(x => x.VideoPath == RecordScreenPathName);
  3063. // }
  3064. // catch (Exception ex)
  3065. // {
  3066. // LogHelper.WriteErrLog("【录屏】(BtnRecordingScreen_Click)无法移除视频," + ex.Message, ex);
  3067. // }
  3068. // }
  3069. // else
  3070. // {
  3071. // return;
  3072. // }
  3073. //}
  3074. #endregion
  3075. k_hook.Stop();
  3076. if (APP.W_ScreenRecordingToolbarWindow == null)
  3077. {
  3078. APP.W_ScreenRecordingToolbarWindow = new ScreenRecordingToolbarWindow
  3079. {
  3080. Topmost = true
  3081. };
  3082. APP.W_ScreenRecordingToolbarWindow.Initialize();
  3083. }
  3084. else
  3085. {
  3086. APP.W_ScreenRecordingToolbarWindow.Initialize();
  3087. }
  3088. APP.W_ScreenRecordingToolbarWindow.Click_stopRecordingScreen += W_ScreenRecordingToolbarWindow_Click_stopRecordingScreen;
  3089. //显示在右下角
  3090. APP.W_ScreenRecordingToolbarWindow.WindowStartupLocation = WindowStartupLocation.Manual;
  3091. Graphics graphics = Graphics.FromHwnd(IntPtr.Zero);
  3092. float DIP = graphics.DpiX;
  3093. float DIPY = graphics.DpiY;
  3094. APP.W_ScreenRecordingToolbarWindow.Left = PrimaryScreen.WorkingArea.Width / (DIP / 96) - APP.W_ScreenRecordingToolbarWindow.Width+10 ;
  3095. APP.W_ScreenRecordingToolbarWindow.Top = PrimaryScreen.WorkingArea.Height / (DIP / 96) - APP.W_ScreenRecordingToolbarWindow.Height - 30;
  3096. APP.W_ScreenRecordingToolbarWindow.Topmost = true;
  3097. APP.W_ScreenRecordingToolbarWindow.Show();
  3098. Hide();
  3099. }
  3100. /// <summary>
  3101. /// 保存录屏中
  3102. /// </summary>
  3103. private void W_ScreenRecordingToolbarWindow_Click_stopRecordingScreen()
  3104. {
  3105. txbTime.Text = "";
  3106. txbTime.Visibility = Visibility.Hidden;
  3107. txbType.Visibility = Visibility.Visible;
  3108. txbType.Text = "保存中";
  3109. btnScreenRecording.IsEnabled = false;
  3110. new Thread(new ThreadStart(new Action(() =>
  3111. {
  3112. while (FileToolsCommon.IsExistDirectory(APP.WKData.WkPath + "temprs/"))
  3113. {
  3114. Thread.Sleep(100);
  3115. }
  3116. Thread.Sleep(100);
  3117. Dispatcher.Invoke(() =>
  3118. {
  3119. btnScreenRecording.IsEnabled = true;
  3120. txbType.Visibility = Visibility.Hidden;
  3121. //TxbRecordScreenWord.Text = "录屏";
  3122. });
  3123. }))).Start();
  3124. }
  3125. #endregion
  3126. private bool IsPressButton = false;
  3127. /// <summary>
  3128. /// 录制窗口内容
  3129. /// </summary>
  3130. /// <param name="sender"></param>
  3131. /// <param name="e"></param>
  3132. private void BtnRecord_Click(object sender, RoutedEventArgs e)
  3133. {
  3134. #region 防止连击
  3135. if (IsPressButton)
  3136. {
  3137. return;
  3138. }
  3139. else
  3140. {
  3141. IsPressButton = true;
  3142. new Thread(new ThreadStart(new Action(() =>
  3143. {
  3144. Thread.Sleep(500);
  3145. IsPressButton = false;
  3146. }))).Start();
  3147. }
  3148. #endregion
  3149. Record();
  3150. if (!APP.CheckScreenCapturerRecorder())
  3151. {
  3152. MessageWindow.Show("使用此功能需安装环境,请在确定后依次点击“OK-Next>-Next>Install”完成安装!");
  3153. APP.InstallScreenCapturerRecorder();
  3154. return;
  3155. }
  3156. if (APP.pageData.currpage > 0)
  3157. {
  3158. blackboard_canvas.Visibility = Visibility.Visible;
  3159. }
  3160. else
  3161. {
  3162. MessageWindow.Show("请先导入文档或截图!");
  3163. return;
  3164. }
  3165. if (RectImgBorder.Visibility != Visibility.Hidden)
  3166. {
  3167. HideAngleBorder();
  3168. }
  3169. //btnStop.IsEnabled = true;//停止录制按钮可点击
  3170. StartRecord();
  3171. }
  3172. /// <summary>
  3173. /// 停止录制窗口内容
  3174. /// </summary>
  3175. /// <param name="sender"></param>
  3176. /// <param name="e"></param>
  3177. private void BtnStop_Click(object sender, RoutedEventArgs e)
  3178. {
  3179. #region 防止连击
  3180. if (IsPressButton)
  3181. {
  3182. return;
  3183. }
  3184. else
  3185. {
  3186. IsPressButton = true;
  3187. new Thread(new ThreadStart(new Action(() =>
  3188. {
  3189. Thread.Sleep(500);
  3190. IsPressButton = false;
  3191. }))).Start();
  3192. }
  3193. #endregion
  3194. blackboard_canvas.Visibility = Visibility.Collapsed;
  3195. EndRecord();
  3196. //鼠标模式
  3197. deviceMouse();
  3198. }
  3199. /// <summary>
  3200. /// 设置录屏文件地址
  3201. /// </summary>
  3202. private void SetUpVideoPathName()
  3203. {
  3204. }
  3205. /// <summary>
  3206. /// 开始录制和暂停录制
  3207. /// </summary>
  3208. private void StartRecord()
  3209. {
  3210. if (IsSuspendR)
  3211. {
  3212. if (IsFirstR)//是否第一次录制 初始化录制
  3213. {
  3214. #region 检测麦克风扬声器是否可用
  3215. string AudioPath = FileToolsCommon.GetFileAbsolutePath("/temp/audio/");
  3216. FileToolsCommon.CreateDirectory(AudioPath);
  3217. string audioSpeakerPath = AudioPath + "adoS" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".m";
  3218. string audioMicrophonePath = AudioPath + "adoM" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".m";
  3219. try
  3220. {
  3221. FileToolsCommon.DeleteFile(audioSpeakerPath);
  3222. FileToolsCommon.DeleteFile(audioMicrophonePath);
  3223. }
  3224. catch (Exception)
  3225. {
  3226. }
  3227. //扬声器
  3228. if (APP.FFmpeg.StartRecordSpeakerAudio(audioSpeakerPath))
  3229. {
  3230. APP.FFmpeg.StopRecordAudio(2);
  3231. //Thread.Sleep(500);
  3232. //麦克风
  3233. if (APP.FFmpeg.StartRecordAudio(audioMicrophonePath))
  3234. {
  3235. }
  3236. else
  3237. {
  3238. //无法录制麦克风
  3239. MessageBoxResult Res = MessageWindow.Show("当前电脑无法录制麦克风,是否继续?", "消息提示", MessageBoxButton.OKCancel);
  3240. if (Res == MessageBoxResult.Cancel)
  3241. {
  3242. return;
  3243. }
  3244. }
  3245. APP.FFmpeg.StopRecordAudio(1);
  3246. }
  3247. else
  3248. {
  3249. //无法录制扬声器音频
  3250. MessageBoxResult Res = MessageWindow.Show("当前电脑无法录制音频,是否继续?", "消息提示", MessageBoxButton.OKCancel);
  3251. if (Res == MessageBoxResult.Cancel)
  3252. {
  3253. return;
  3254. }
  3255. }
  3256. #endregion
  3257. //电子版切换笔模式
  3258. deviceHand();
  3259. txbTime.Visibility = Visibility.Visible;
  3260. VideoInfo = new Model_Video
  3261. {
  3262. VideoType = (Enum_VideoType)int.Parse(FileToolsCommon.GetConfigValue("VideoType")),
  3263. WkType = Enum_WKVidetype.RecordingLessons
  3264. };
  3265. ImgPath = APP.WKData.WkPath + "temp/Image/";
  3266. AudioPathName = APP.WKData.WkPath + "temp/audio/";
  3267. FileToolsCommon.DeleteDirectory(APP.WKData.WkPath + "temp/");
  3268. FileToolsCommon.CreateDirectory(APP.WKData.WkPath);
  3269. FileToolsCommon.CreateDirectory(ImgPath);
  3270. FileToolsCommon.CreateDirectory(AudioPathName);
  3271. AudioPathName += APP.WKData.WkName + ".MP3";
  3272. VideoSavePathName = APP.WKData.WkPath + APP.WKData.WkName + "_录制." + VideoInfo.VideoType.ToString();
  3273. VideoSynthesisPathName = APP.WKData.WkPath + APP.WKData.WkName + "_录制Syn." + VideoInfo.VideoType.ToString();
  3274. int num = 1;
  3275. while (FileToolsCommon.IsExistFile(VideoSavePathName))
  3276. {
  3277. VideoSavePathName = APP.WKData.WkPath + APP.WKData.WkName + "_录制_" + num + "." + VideoInfo.VideoType.ToString();
  3278. VideoSynthesisPathName = APP.WKData.WkPath + APP.WKData.WkName + "_录制Syn_" + num + "." + VideoInfo.VideoType.ToString();
  3279. num++;
  3280. }
  3281. #region 设置录屏唯一 废弃
  3282. //if (FileToolsCommon.IsExistFile(VideoSavePathName))
  3283. //{
  3284. // MessageBoxResult dr = MessageWindow.Show("课程已录制,是否覆盖?", "提示", MessageBoxButton.OKCancel);
  3285. // if (dr == MessageBoxResult.OK)
  3286. // {
  3287. // try
  3288. // {
  3289. // FileToolsCommon.DeleteFile(VideoSavePathName);
  3290. // APP.VideoList.RemoveAll(x => x.VideoPath == VideoSavePathName);
  3291. // }
  3292. // catch (Exception ex)
  3293. // {
  3294. // LogHelper.WriteErrLog("【录制】(StartRecord)无法移除视频," + ex.Message, ex);
  3295. // }
  3296. // }
  3297. // else
  3298. // {
  3299. // return;
  3300. // }
  3301. //}
  3302. #endregion
  3303. #region 禁用按钮
  3304. ImgPrint.Visibility = Visibility.Collapsed;//录制中不可打印
  3305. ImgPrintTwo.Visibility = Visibility.Visible;
  3306. btnPrint.IsEnabled = false;
  3307. ImgScreenshot.Visibility = Visibility.Collapsed;//录制中不可截图
  3308. ImgScreenshotTwo.Visibility = Visibility.Visible;
  3309. btnScreenshot.IsEnabled = false;
  3310. ImgImport.Visibility = Visibility.Collapsed;//录制中不可导入文档
  3311. ImgImportTwo.Visibility = Visibility.Visible;
  3312. btnImport.IsEnabled = false;
  3313. ImgScreenRecording.Visibility = Visibility.Collapsed;//录制中不可录屏
  3314. ImgScreenRecordingTwo.Visibility = Visibility.Visible;
  3315. btnScreenRecording.IsEnabled = false;
  3316. ImgUpload.Visibility = Visibility.Collapsed;//录制中不可上传
  3317. ImgUploadTwo.Visibility = Visibility.Visible;
  3318. btnUpload.IsEnabled = false;
  3319. ImgSetUp.Visibility = Visibility.Collapsed;//录制中不可设置
  3320. ImgSetUpTwo.Visibility = Visibility.Visible;
  3321. btnSetUp.IsEnabled = false;
  3322. btnLoginType.IsEnabled = false;
  3323. blackboard_canvas.Visibility = Visibility.Visible;//zxyceshi
  3324. //myblackboard = new BlackboardNew(blackboard_canvas);
  3325. //DataContext = APP.pageData;
  3326. //drawingAttributes = new DrawingAttributes();
  3327. ////将 InkCanvas 的 DefaultDrawingAttributes 属性的值赋成创建的 DrawingAttributes 类的对象的引用
  3328. ////InkCanvas 通过 DefaultDrawingAttributes 属性来获取墨迹的各种设置,该属性的类型为 DrawingAttributes 型
  3329. //blackboard_canvas.DefaultDrawingAttributes = drawingAttributes;
  3330. //blackboard_canvas.UseCustomCursor = true;
  3331. //drawingAttributes.FitToCurve = true;
  3332. //drawingAttributes.IgnorePressure = false;
  3333. //drawingAttributes.Width = PenSize;
  3334. //drawingAttributes.Height = PenSize;
  3335. //drawingAttributes.Color = Color;
  3336. //blackboard_canvas.Cursor = System.Windows.Input.Cursors.Pen;
  3337. #endregion
  3338. #region 设置录制大小
  3339. //gridActWidth = (int)GridMain.ActualWidth==0?1276: (int)GridMain.ActualWidth;
  3340. //gridActHeight = (int)GridMain.ActualHeight==0?898: (int)GridMain.ActualHeight;
  3341. gridActWidth = (int)(GridMain.ActualWidth * (PrimaryScreen.DpiX / 96f));
  3342. gridActHeight = (int)(GridMain.ActualHeight * (PrimaryScreen.DpiY / 96f));
  3343. gridActWidth = gridActWidth % 2 > 0 ? gridActWidth - 1 : gridActWidth;
  3344. gridActHeight = gridActHeight % 2 > 0 ? gridActHeight - 1 : gridActHeight;
  3345. #endregion
  3346. #region 录像倒计时
  3347. if (APP.W_CountdownWindow == null)
  3348. {
  3349. APP.W_CountdownWindow = new CountdownWindow();
  3350. APP.W_CountdownWindow.Initialize();
  3351. //APP.W_CountdownWindow.Topmost = true;
  3352. }
  3353. else
  3354. {
  3355. APP.W_CountdownWindow.Initialize();
  3356. //APP.W_CountdownWindow.Topmost = true;
  3357. }
  3358. APP.W_CountdownWindow.Show();
  3359. #endregion
  3360. IsFirstR = false;
  3361. RsImgName = new List<string>();
  3362. SRTime = Convert.ToDateTime("2020-01-01 00:00:00");
  3363. txbTime.Visibility = Visibility.Visible;
  3364. ///启动截图
  3365. timer = new System.Threading.Timer(new TimerCallback(Timer_Elapsed), null, 0, 20);
  3366. //{
  3367. // AutoReset = true//设置是否执行System.Timers.Timer.Elapsed事件
  3368. //};//设置执行一次(false)还是一直执行(true)
  3369. //timer.Elapsed += new System.Timers.ElapsedEventHandler(Timer_Elapsed);
  3370. //timer.Enabled = true; //启动计时器
  3371. }
  3372. //继续录制
  3373. IsSuspendR = false;
  3374. //BtnRecording.Content = "暂停录制";
  3375. ImgRecord.Source = new BitmapImage(new Uri("pack://application:,,,/Images/microLessonSystem_23.png"));
  3376. TxbRecordingWord.Text = "暂停";
  3377. #region 4秒内不可点击
  3378. //new Thread(new ThreadStart(new Action(() =>
  3379. //{
  3380. // Dispatcher.Invoke(() =>
  3381. // {
  3382. // BtnRecord.IsEnabled = false;
  3383. // btnStop.IsEnabled = false;
  3384. // ImgStop.Visibility = Visibility.Visible;
  3385. // ImgStopTwo.Visibility = Visibility.Collapsed;
  3386. // });
  3387. //}))).Start();
  3388. new Thread(new ThreadStart(new Action(() =>
  3389. {
  3390. //Thread.Sleep(4000);
  3391. Dispatcher.Invoke(() =>
  3392. {
  3393. BtnRecord.IsEnabled = true;
  3394. btnStop.IsEnabled = true;
  3395. ImgStop.Visibility = Visibility.Collapsed;
  3396. ImgStopTwo.Visibility = Visibility.Visible;
  3397. });
  3398. }))).Start();
  3399. #endregion
  3400. try
  3401. {
  3402. new Thread(new ThreadStart(new Action(() =>
  3403. {
  3404. Thread.Sleep(1000);
  3405. IsRecordAudio = APP.FFmpeg.StartRecordingAudio(AudioPathName, out string ErrMessage);
  3406. Thread.Sleep(1000);
  3407. Dispatcher.Invoke(() =>
  3408. {
  3409. if (!IsRecordAudio)
  3410. {
  3411. MessageWindow.Show(ErrMessage);
  3412. }
  3413. Recorddt = DateTime.Now;
  3414. IsStartCount = true;
  3415. //Stack();
  3416. //timer.Start();
  3417. });
  3418. }))).Start();
  3419. }
  3420. catch (Exception ex)
  3421. {
  3422. MessageWindow.Show(ex.Message);
  3423. }
  3424. }
  3425. else
  3426. {
  3427. //暂停
  3428. IsSuspendR = true;
  3429. ImgRecord.Source = new BitmapImage(new Uri("pack://application:,,,/Images/microLessonSystem_14.png"));
  3430. ImgStop.Visibility = Visibility.Collapsed;
  3431. ImgStopTwo.Visibility = Visibility.Visible;
  3432. TxbRecordingWord.Text = "继续";
  3433. //TimeOut();
  3434. #region 2秒内不可点击
  3435. new Thread(new ThreadStart(new Action(() =>
  3436. {
  3437. Dispatcher.Invoke(() =>
  3438. {
  3439. BtnRecord.IsEnabled = false;
  3440. btnStop.IsEnabled = false;
  3441. });
  3442. Thread.Sleep(2000);
  3443. Dispatcher.Invoke(() =>
  3444. {
  3445. BtnRecord.IsEnabled = true;
  3446. btnStop.IsEnabled = true;
  3447. });
  3448. }))).Start();
  3449. #endregion
  3450. try
  3451. {
  3452. APP.FFmpeg.SuspendFFmpeg();
  3453. new Thread(new ThreadStart(new Action(() =>
  3454. {
  3455. while (APP.FFmpeg.myProcess != null)
  3456. {
  3457. Thread.Sleep(100);
  3458. }
  3459. IsStartCount = false;
  3460. }))).Start();
  3461. }
  3462. catch (Exception ex)
  3463. {
  3464. MessageWindow.Show(ex.Message);
  3465. }
  3466. }
  3467. }
  3468. /// <summary>
  3469. /// 记录上次截图时间
  3470. /// </summary>
  3471. private DateTime Recorddt = DateTime.Now;
  3472. /// <summary>
  3473. /// 录制保存图片计时器
  3474. /// </summary>
  3475. /// <param name="sender"></param>
  3476. private void Timer_Elapsed(object sender)
  3477. {
  3478. if (IsStartCount)
  3479. {
  3480. DateTime dt = DateTime.Now;
  3481. TimeSpan ts = dt.Subtract(Recorddt);//时间差
  3482. double tsmi = ts.TotalMilliseconds;
  3483. if (tsmi > 200.0)
  3484. {
  3485. Recorddt = Recorddt.AddMilliseconds(200);
  3486. Thread thread = new Thread(RecordSaveImage);
  3487. //开启线程
  3488. thread.Start();
  3489. }
  3490. }
  3491. }
  3492. /// <summary>
  3493. /// 录制保存图片
  3494. /// </summary>
  3495. private void RecordSaveImage()
  3496. {
  3497. try
  3498. {
  3499. if (IsStartCount)
  3500. {
  3501. string FilePathName = ImgPath + RsImgName.Count + ".png";
  3502. RsImgName.Add(FilePathName);
  3503. #region 设置大小
  3504. double RsW = (int)(GridMain.ActualWidth * (PrimaryScreen.DpiX / 96f));
  3505. double RsH = (int)(GridMain.ActualHeight * (PrimaryScreen.DpiY / 96f));
  3506. if (RsW > 1266)
  3507. {
  3508. double Proportion = RsH / RsW;
  3509. RsW = 1266;
  3510. RsH = RsW * Proportion;
  3511. RsH = ((int)RsH) % 2 > 0 ? (int)RsH - 1 : (int)RsH;
  3512. //RsH = 898;
  3513. }
  3514. #endregion
  3515. //System.Windows.Application.Current.Dispatcher.Invoke(DispatcherPriority.Send, new ThreadStart(delegate
  3516. //{
  3517. //}));
  3518. Dispatcher.Invoke(() =>
  3519. {
  3520. //保存图片
  3521. ImageHelper.SaveUI(GridMain, FilePathName, gridActWidth, gridActHeight, (int)RsW, (int)RsH);
  3522. //ImageHelper.SaveUIToImage(GridMain, FilePathName, gridActWidth, gridActHeight, (int)RsW, (int)RsH);
  3523. //ImageHelper.SaveUIToImage(GridMain, FilePathName, (int)(GridMain.ActualWidth * (PrimaryScreen.DpiX / 96f)), (int)(GridMain.ActualHeight * (PrimaryScreen.DpiY / 96f)), 0, 0);
  3524. //ImageHelper.SaveUIToImage(GridMain, FilePathName, (int)(ActualWidth * (PrimaryScreen.DpiX / 96f)), (int)(ActualHeight * (PrimaryScreen.DpiY / 96f)), (int)RsW, (int)RsH);
  3525. //ImageHelper.SaveUIToImage(GridMain, FilePathName, (int)(ActualWidth * (PrimaryScreen.DpiX / 96f)), (int)(ActualHeight * (PrimaryScreen.DpiY / 96f)), 1281, 1026);
  3526. SRTime = SRTime.AddMilliseconds(200);
  3527. if (txbTime.Visibility == Visibility.Hidden)
  3528. {
  3529. txbTime.Visibility = Visibility.Visible;
  3530. }
  3531. if (SRTime.Hour > 0)
  3532. {
  3533. //Dispatcher.Invoke(() =>
  3534. //{
  3535. txbTime.Text = SRTime.ToString("HH:mm:ss");
  3536. //});
  3537. }
  3538. else
  3539. {
  3540. //Dispatcher.Invoke(() =>
  3541. //{
  3542. txbTime.Text = SRTime.ToString("mm:ss");
  3543. //});
  3544. }
  3545. });
  3546. }
  3547. }
  3548. catch (Exception ex)
  3549. {
  3550. LogHelper.WriteErrLog("【录制】(Timer_Elapsed)生成图片错误:" + ex.Message, ex);
  3551. }
  3552. }
  3553. /// <summary>
  3554. /// 停止录制并生成录制文件
  3555. /// </summary>
  3556. private void EndRecord()
  3557. {
  3558. if (!IsFirstR)
  3559. {
  3560. #region 恢复被禁用的按钮
  3561. ImgPrint.Visibility = Visibility.Visible;
  3562. ImgPrintTwo.Visibility = Visibility.Collapsed;
  3563. btnPrint.IsEnabled = true;
  3564. ImgScreenshot.Visibility = Visibility.Visible;
  3565. ImgScreenshotTwo.Visibility = Visibility.Collapsed;
  3566. btnScreenshot.IsEnabled = true;
  3567. ImgImport.Visibility = Visibility.Visible;
  3568. ImgImportTwo.Visibility = Visibility.Collapsed;
  3569. btnImport.IsEnabled = true;
  3570. ImgScreenRecording.Visibility = Visibility.Visible;
  3571. ImgScreenRecordingTwo.Visibility = Visibility.Collapsed;
  3572. btnScreenRecording.IsEnabled = true;
  3573. ImgUpload.Visibility = Visibility.Visible;
  3574. ImgUploadTwo.Visibility = Visibility.Collapsed;
  3575. btnUpload.IsEnabled = true;
  3576. ImgSetUp.Visibility = Visibility.Visible;
  3577. ImgSetUpTwo.Visibility = Visibility.Collapsed;
  3578. btnSetUp.IsEnabled = true;
  3579. btnLoginType.IsEnabled = true;
  3580. //btnStop.IsEnabled = false;//停止录制按钮不可点击
  3581. #endregion
  3582. IsSuspendR = true;
  3583. ImgRecord.Source = new BitmapImage(new Uri("pack://application:,,,/Images/microLessonSystem_14.png"));
  3584. ImgStop.Visibility = Visibility.Visible;
  3585. ImgStopTwo.Visibility = Visibility.Collapsed;
  3586. //TimeOut();
  3587. try
  3588. {
  3589. #region 清空画板数据
  3590. APP.pageData.currpage = 0;
  3591. APP.pageData.pagenum = 0;
  3592. myblackboard.clear();
  3593. //myblackboard = new BlackboardNew(blackboard_canvas);
  3594. //DataContext = APP.pageData;
  3595. //drawingAttributes = new DrawingAttributes();
  3596. ////将 InkCanvas 的 DefaultDrawingAttributes 属性的值赋成创建的 DrawingAttributes 类的对象的引用
  3597. ////InkCanvas 通过 DefaultDrawingAttributes 属性来获取墨迹的各种设置,该属性的类型为 DrawingAttributes 型
  3598. //blackboard_canvas.DefaultDrawingAttributes = drawingAttributes;
  3599. //blackboard_canvas.UseCustomCursor = true;
  3600. //drawingAttributes.FitToCurve = true;
  3601. //drawingAttributes.IgnorePressure = false;
  3602. //drawingAttributes.Width = PenSize;
  3603. //drawingAttributes.Height = PenSize;
  3604. //drawingAttributes.Color = Color;
  3605. //blackboard_canvas.Cursor = System.Windows.Input.Cursors.Pen;
  3606. APP.PageDrawList.Clear();
  3607. imgCanvas.Source = null;
  3608. imgDocumentation.Source = null;
  3609. imgPPT.Source = null;
  3610. gridPage.Visibility = Visibility.Collapsed;
  3611. #endregion
  3612. //根据录制时间长度确定是否保存
  3613. if (SRTime.Hour > 0 || SRTime.Minute > 0 || SRTime.Second > 3)
  3614. {
  3615. #region 2秒内不可点击
  3616. new Thread(new ThreadStart(new Action(() =>
  3617. {
  3618. Dispatcher.Invoke(() =>
  3619. {
  3620. BtnRecord.IsEnabled = false;
  3621. btnStop.IsEnabled = false;
  3622. btnScreenRecording.IsEnabled = false;
  3623. });
  3624. }))).Start();
  3625. #endregion
  3626. //缩略图
  3627. string ThumbnailPath = FileToolsCommon.GetDirectoryName(VideoSavePathName) + "ThumbnailPath/";
  3628. FileToolsCommon.CreateDirectory(ThumbnailPath);
  3629. //缩略图存储位置
  3630. string ThumbnailPathName = ThumbnailPath + FileToolsCommon.GetIOFileName(VideoSavePathName).Replace(".", "") + ".JPG";
  3631. APP.FFmpeg.StopFFmpeg(AudioPathName);
  3632. new Thread(new ThreadStart(new Action(() =>
  3633. {
  3634. IsStartCount = false;
  3635. //停止截图
  3636. while (APP.FFmpeg.myProcess != null)
  3637. {
  3638. Thread.Sleep(100);
  3639. }
  3640. Dispatcher.Invoke(() =>
  3641. {
  3642. timer.Change(-1, 0);
  3643. timer.Dispose();
  3644. //End();
  3645. txbTime.Text = "";
  3646. txbTime.Visibility = Visibility.Hidden;
  3647. txbType.Visibility = Visibility.Visible;
  3648. txbType.Text = "保存中";
  3649. });
  3650. //}))).Start();
  3651. //new Thread(new ThreadStart(new Action(() =>
  3652. //{
  3653. //判断音频是否存在 判断音频临时文件夹是否存在
  3654. if (IsRecordAudio)
  3655. {
  3656. if (!FileToolsCommon.IsExistFile(AudioPathName))
  3657. {
  3658. Thread.Sleep(100);
  3659. }
  3660. if (FileToolsCommon.IsExistDirectory(FileToolsCommon.GetDirectoryName(AudioPathName) + "temp/"))
  3661. {
  3662. Thread.Sleep(100);
  3663. }
  3664. }
  3665. else
  3666. {
  3667. //没有录制音频
  3668. AudioPathName = null;
  3669. }
  3670. //合成视频
  3671. bool SynRes = APP.FFmpeg.SynthesisVideo(ImgPath, AudioPathName, VideoSynthesisPathName, 5, gridActWidth, gridActHeight, out string ErrMessage);
  3672. //}))).Start();
  3673. //new Thread(new ThreadStart(new Action(() =>
  3674. //{
  3675. if (!SynRes)
  3676. {
  3677. Dispatcher.Invoke(() =>
  3678. {
  3679. //MessageWindow.Show("视频录制失败,无法保存此视频!");
  3680. MessageWindow.Show("录制失败," + ErrMessage);
  3681. BtnRecord.IsEnabled = true;
  3682. btnStop.IsEnabled = true;
  3683. btnScreenRecording.IsEnabled = true;
  3684. TxbRecordingWord.Text = "录制";
  3685. txbType.Text = "";
  3686. });
  3687. return;
  3688. }
  3689. Dispatcher.Invoke(() =>
  3690. {
  3691. txbType.Text = "转码中";
  3692. });
  3693. while (!FileToolsCommon.IsExistFile(VideoSynthesisPathName))
  3694. {
  3695. Thread.Sleep(100);
  3696. }
  3697. while (FileToolsCommon.IsExistDirectory(FileToolsCommon.GetDirectoryName(VideoSynthesisPathName) + "temp/"))
  3698. {
  3699. Thread.Sleep(100);
  3700. }
  3701. FileToolsCommon.DeleteFile(ThumbnailPathName);
  3702. VideoInfo.RSTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  3703. Thread.Sleep(500);
  3704. //VideoInfo.VideoSize = FileToolsCommon.GetFileSizeByMB(VideoSavePathName).ToString() + " MB";
  3705. VideoInfo.VideoPath = VideoSavePathName;
  3706. VideoInfo.ThumbnailPath = ThumbnailPathName;
  3707. //生成缩略图
  3708. bool ThuRes = APP.FFmpeg.GenerateThumbnails(VideoSynthesisPathName, ThumbnailPathName, 200, 130);
  3709. Thread.Sleep(500);
  3710. //if (ThuRes)
  3711. //{
  3712. // Bitmap bmp = ImageHelper.ReadBitmapFile(ThumbnailPathName);
  3713. // if (bmp != null)
  3714. // {
  3715. // imgW = bmp.Width + (bmp.Width % 2 > 0 ? 1 : 0);
  3716. // imgH = bmp.Height + (bmp.Height % 2 > 0 ? 1 : 0);
  3717. // }
  3718. //}
  3719. APP.FFmpeg.VideoTranscode(VideoSynthesisPathName, VideoSavePathName, gridActWidth, gridActHeight);
  3720. VideoInfo.FileGuid = Guid.NewGuid().ToString();
  3721. VideoInfo.IsUpload = false;
  3722. VideoInfo.Uploaded = 0;
  3723. //VideoInfo.Savefolder = APP.UserInfo.Schoolid + "/resource";
  3724. APP.VideoList.Add(VideoInfo);
  3725. //保存数据
  3726. APP.SaveWkData();
  3727. IsFirstR = true;
  3728. Dispatcher.Invoke(() =>
  3729. {
  3730. BtnRecord.IsEnabled = true;
  3731. btnStop.IsEnabled = true;
  3732. btnScreenRecording.IsEnabled = true;
  3733. TxbRecordingWord.Text = "录制";
  3734. txbType.Text = "";
  3735. });
  3736. }))).Start();
  3737. }
  3738. else
  3739. {
  3740. APP.FFmpeg.SuspendFFmpeg();
  3741. IsStartCount = false;
  3742. timer.Change(-1, 0);
  3743. timer.Dispose();
  3744. IsFirstR = true;
  3745. BtnRecord.IsEnabled = true;
  3746. btnStop.IsEnabled = true;
  3747. btnScreenRecording.IsEnabled = true;
  3748. TxbRecordingWord.Text = "录制";
  3749. txbType.Text = "";
  3750. MessageWindow.Show("录制时间过短,请重新录制!");
  3751. Dispatcher.Invoke(() =>
  3752. {
  3753. txbTime.Text = "";
  3754. txbTime.Visibility = Visibility.Hidden;
  3755. });
  3756. }
  3757. //List<Model_Video> VideoList
  3758. }
  3759. catch (Exception ex)
  3760. {
  3761. MessageWindow.Show(ex.Message);
  3762. }
  3763. }
  3764. }
  3765. #endregion
  3766. #region 登陆
  3767. /// <summary>
  3768. /// 登陆事件
  3769. /// </summary>
  3770. /// <param name="sender"></param>
  3771. /// <param name="e"></param>
  3772. private void BtnLoginType_Click(object sender, RoutedEventArgs e)
  3773. {
  3774. if ("未登录".Equals(txbLoginType.Text))
  3775. {
  3776. Login();
  3777. }
  3778. else
  3779. {
  3780. MessageBoxResult dr = MessageWindow.Show("确定退出登陆?", "提示", MessageBoxButton.OKCancel);
  3781. if (dr == MessageBoxResult.OK)
  3782. {
  3783. LoginType();
  3784. Login();
  3785. }
  3786. }
  3787. }
  3788. /// <summary>
  3789. /// 登陆
  3790. /// </summary>
  3791. private void Login()
  3792. {
  3793. if (APP.W_LoginWindow == null)
  3794. {
  3795. APP.W_LoginWindow = new LoginWindow
  3796. {
  3797. WindowStartupLocation = WindowStartupLocation.CenterOwner,
  3798. Owner = this
  3799. };
  3800. }
  3801. else
  3802. {
  3803. APP.W_LoginWindow.Initialize();
  3804. }
  3805. APP.W_LoginWindow.ShowDialog();
  3806. if (APP.IsLoginType)
  3807. {
  3808. txbLoginType.Text = APP.UserInfo.Username;
  3809. //ImgUpload.Visibility = Visibility.Visible;
  3810. //ImgUploadTwo.Visibility = Visibility.Collapsed;
  3811. }
  3812. else
  3813. {
  3814. txbLoginType.Text = "未登录";
  3815. //ImgUpload.Visibility = Visibility.Collapsed;
  3816. //ImgUploadTwo.Visibility = Visibility.Visible;
  3817. }
  3818. }
  3819. /// <summary>
  3820. /// 状态更改为未登陆
  3821. /// </summary>
  3822. private void LoginType()
  3823. {
  3824. APP.IsLoginType = false;
  3825. txbLoginType.Text = "未登录";
  3826. APP.UserInfo = new Model_UserInfo();
  3827. //ImgUpload.Visibility = Visibility.Collapsed;
  3828. //ImgUploadTwo.Visibility = Visibility.Visible;
  3829. }
  3830. #endregion
  3831. #region 分页
  3832. /// 上一页
  3833. /// </summary>
  3834. /// <param name="sender"></param>
  3835. /// <param name="e"></param>
  3836. private void last_button_Click(object sender, RoutedEventArgs e)
  3837. {
  3838. if (APP.pageData.currpage > 1)
  3839. {
  3840. mouseDown = false;
  3841. HideAngleBorder();
  3842. //隐藏跳转
  3843. //txbCurrpage.Visibility = Visibility.Visible;
  3844. //txtJump.Visibility = Visibility.Hidden;
  3845. //BtnJumpPage.Visibility = Visibility.Hidden;
  3846. //if(!APP.PageDrawList[APP.pageData.currpage - 1].IsImageLocation)
  3847. //{
  3848. // ImgWG();
  3849. //}
  3850. APP.pageData.currpage -= 1;
  3851. JumpPageClick();
  3852. }
  3853. }
  3854. /// <summary>
  3855. /// 下一页
  3856. /// </summary>
  3857. /// <param name="sender"></param>
  3858. /// <param name="e"></param>
  3859. private void next_btn_Click(object sender, RoutedEventArgs e)
  3860. {
  3861. if (APP.pageData.currpage < APP.pageData.pagenum)
  3862. {
  3863. mouseDown = false;
  3864. HideAngleBorder();
  3865. //隐藏跳转
  3866. //txbCurrpage.Visibility = Visibility.Visible;
  3867. //txtJump.Visibility = Visibility.Hidden;
  3868. //BtnJumpPage.Visibility = Visibility.Hidden;
  3869. //if (!APP.PageDrawList[APP.pageData.currpage - 1].IsImageLocation)
  3870. //{
  3871. // ImgWG();
  3872. //}
  3873. APP.pageData.currpage += 1;
  3874. JumpPageClick();
  3875. }
  3876. }
  3877. /// <summary>
  3878. /// 跳转
  3879. /// </summary>
  3880. void JumpPageClick()
  3881. {
  3882. myblackboard.changepage(APP.pageData.currpage - 1);
  3883. scroMain.ScrollToVerticalOffset(0);
  3884. if (btnImport.IsEnabled == true)
  3885. {
  3886. ///截图可用
  3887. ImgScreenshot.Visibility = Visibility.Visible;
  3888. ImgScreenshotTwo.Visibility = Visibility.Collapsed;
  3889. btnScreenshot.IsEnabled = true;
  3890. }
  3891. if (APP.pageData.currpage <= APP.PageDrawList.Count)
  3892. {
  3893. if (APP.PageDrawList[APP.pageData.currpage - 1].ImageLocation != null)
  3894. {
  3895. APP.PageDrawList[APP.pageData.currpage - 1].IsImageLocation = true;
  3896. }
  3897. if (!string.IsNullOrWhiteSpace(txbCurrpage.Text) && APP.pageData.currpage <= APP.PageDrawList.Count && APP.pageData.currpage > 0 && !string.IsNullOrWhiteSpace(APP.PageDrawList[APP.pageData.currpage - 1].PageImagePath))
  3898. {
  3899. if (APP.PageDrawList[APP.pageData.currpage - 1].ImgDocumentation)
  3900. {
  3901. if ("ppt".Equals(APP.PageDrawList[APP.pageData.currpage - 1].Type))
  3902. {
  3903. imgCanvas.Source = null;
  3904. imgDocumentation.Source = null;
  3905. imgPPT.Source = new BitmapImage(new Uri(APP.PageDrawList[APP.pageData.currpage - 1].PageImagePath));
  3906. ImgScreenshot.Visibility = Visibility.Collapsed;//当前页为导入时不可截图
  3907. ImgScreenshotTwo.Visibility = Visibility.Visible;
  3908. btnScreenshot.IsEnabled = false;
  3909. }
  3910. else
  3911. {
  3912. imgPPT.Source = null;
  3913. imgCanvas.Source = null;
  3914. imgDocumentation.Source = new BitmapImage(new Uri(APP.PageDrawList[APP.pageData.currpage - 1].PageImagePath));
  3915. ImgScreenshot.Visibility = Visibility.Collapsed;//当前页为导入时不可截图
  3916. ImgScreenshotTwo.Visibility = Visibility.Visible;
  3917. btnScreenshot.IsEnabled = false;
  3918. }
  3919. //imgCanvas.Source = null;
  3920. //imgDocumentation.Source = new BitmapImage(new Uri(APP.PageDrawList[APP.pageData.currpage - 1].PageImagePath));
  3921. //ImgScreenshot.Visibility = Visibility.Collapsed;//当前页为导入时不可截图
  3922. //ImgScreenshotTwo.Visibility = Visibility.Visible;
  3923. //btnScreenshot.IsEnabled = false;
  3924. }
  3925. else
  3926. {
  3927. imgPPT.Source = null;
  3928. imgDocumentation.Source = null;
  3929. imgCanvas.Source = new BitmapImage(new Uri(APP.PageDrawList[APP.pageData.currpage - 1].PageImagePath));
  3930. APP.PageDrawList[APP.pageData.currpage - 1].IsImageLocation = false;
  3931. if (APP.PageDrawList[APP.pageData.currpage - 1].ImageLocation != null && APP.PageDrawList[APP.pageData.currpage - 1].ImageLocation.X > 0)
  3932. {
  3933. //var group = IMG.FindResource("Imageview") as TransformGroup;
  3934. //#region 高低 缩放比例
  3935. //if (APP.PageDrawList[APP.pageData.currpage - 1].ImageSize != null)
  3936. //{
  3937. // var transform1 = group.Children[0] as ScaleTransform;
  3938. // transform1.ScaleX = APP.PageDrawList[APP.pageData.currpage - 1].ImageSize.ScaleX;
  3939. // transform1.ScaleY = APP.PageDrawList[APP.pageData.currpage - 1].ImageSize.ScaleY;
  3940. // imgCanvas.Width = APP.PageDrawList[APP.pageData.currpage - 1].ImageSizes.CenterX;
  3941. // imgCanvas.Height = APP.PageDrawList[APP.pageData.currpage - 1].ImageSizes.CenterY;
  3942. //}
  3943. //#endregion
  3944. //#region 坐标XY轴
  3945. //var transform = group.Children[1] as TranslateTransform;
  3946. //transform.X = APP.PageDrawList[APP.pageData.currpage - 1].ImageLocation.X;
  3947. //transform.Y = APP.PageDrawList[APP.pageData.currpage - 1].ImageLocation.Y;
  3948. //#endregion
  3949. mouseDown = false;
  3950. ImgXY();
  3951. }
  3952. }
  3953. }
  3954. else
  3955. {
  3956. imgPPT.Source = null;
  3957. imgCanvas.Source = null;
  3958. imgDocumentation.Source = null;
  3959. }
  3960. #region 修改跳转页码
  3961. CbxPageList.SelectedIndex = APP.pageData.currpage - 1;
  3962. #endregion
  3963. }
  3964. }
  3965. private void ImgXY()
  3966. {
  3967. imgCanvas.Width = APP.PageDrawList[APP.pageData.currpage - 1].ImageSizes.CenterX;
  3968. imgCanvas.Height = APP.PageDrawList[APP.pageData.currpage - 1].ImageSizes.CenterY;
  3969. imgCanvas.Margin = new Thickness(APP.PageDrawList[APP.pageData.currpage - 1].ImageLocation.X, APP.PageDrawList[APP.pageData.currpage - 1].ImageLocation.Y, 0, 0);
  3970. //imgCanvas.Margin.Left= APP.PageDrawList[APP.pageData.currpage - 1].ImageLocation.X;
  3971. //transform.Y = APP.PageDrawList[APP.pageData.currpage - 1].ImageLocation.Y;
  3972. }
  3973. private void ImgWG()
  3974. {
  3975. mouseDown = false;
  3976. APP.PageDrawList[APP.pageData.currpage - 1].ImageLocation = new TranslateTransform
  3977. {
  3978. X = imgCanvas.Margin.Left,
  3979. Y = imgCanvas.Margin.Top
  3980. };
  3981. APP.PageDrawList[APP.pageData.currpage - 1].ImageSizes = new ScaleTransform
  3982. {
  3983. CenterX = imgCanvas.ActualWidth,
  3984. CenterY = imgCanvas.ActualHeight
  3985. };
  3986. }
  3987. #endregion
  3988. #region 图像缩放,移动
  3989. private bool mouseDown;
  3990. private System.Windows.Point mouseXY;
  3991. private void IMG1_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
  3992. {
  3993. ContentControl img = sender as ContentControl;
  3994. if (img == null)
  3995. {
  3996. return;
  3997. }
  3998. img.CaptureMouse();
  3999. mouseDown = true;
  4000. mouseXY = e.GetPosition(img);
  4001. //Console.WriteLine("mouseXY.X = " + mouseXY.X + "; mouseXY.Y = " + mouseXY.Y);
  4002. }
  4003. private void IMG1_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
  4004. {
  4005. ContentControl img = sender as ContentControl;
  4006. if (img == null)
  4007. {
  4008. return;
  4009. }
  4010. img.ReleaseMouseCapture();
  4011. mouseDown = false;
  4012. }
  4013. private void IMG1_MouseMove(object sender, System.Windows.Input.MouseEventArgs e)
  4014. {
  4015. ContentControl img = sender as ContentControl;
  4016. if (img == null)
  4017. {
  4018. return;
  4019. }
  4020. if (mouseDown)
  4021. {
  4022. Domousemove(img, e);
  4023. }
  4024. }
  4025. /// <summary>
  4026. /// x y轴
  4027. /// </summary>
  4028. /// <param name="img"></param>
  4029. /// <param name="e"></param>
  4030. private void Domousemove(ContentControl img, System.Windows.Input.MouseEventArgs e)
  4031. {
  4032. if (e.LeftButton != MouseButtonState.Pressed)
  4033. {
  4034. return;
  4035. }
  4036. if (APP.PageDrawList[APP.pageData.currpage - 1].ImageLocation != null && APP.PageDrawList[APP.pageData.currpage - 1].IsImageLocation)
  4037. {
  4038. return;
  4039. }
  4040. TransformGroup group = IMG.FindResource("Imageview") as TransformGroup;
  4041. TranslateTransform transform = group.Children[1] as TranslateTransform;
  4042. System.Windows.Point position = e.GetPosition(img);
  4043. transform.X -= mouseXY.X - position.X;
  4044. transform.Y -= mouseXY.Y - position.Y;
  4045. mouseXY = position;
  4046. APP.PageDrawList[APP.pageData.currpage - 1].ImageLocation = new TranslateTransform
  4047. {
  4048. X = transform.X,
  4049. Y = transform.Y
  4050. };
  4051. //APP.PageDrawList[APP.pageData.currpage - 1].IsImageLocation = false;
  4052. }
  4053. private void IMG1_MouseWheel(object sender, MouseWheelEventArgs e)
  4054. {
  4055. ContentControl img = sender as ContentControl;
  4056. if (img == null)
  4057. {
  4058. return;
  4059. }
  4060. System.Windows.Point point = e.GetPosition(img);
  4061. //Console.WriteLine("point.X = " + point.X + "; point.Y=" + point.Y);
  4062. System.Windows.Point PicLocate = e.GetPosition(imgCanvas);
  4063. //Console.WriteLine("PicEmap.X = " + PicLocate.X + "; PicEmap.Y=" + PicLocate.Y);
  4064. TransformGroup group = IMG.FindResource("Imageview") as TransformGroup;
  4065. double delta = e.Delta * 0.001;
  4066. DowheelZoom(group, point, delta);
  4067. }
  4068. private void DowheelZoom(TransformGroup group, System.Windows.Point point, double delta)
  4069. {
  4070. System.Windows.Point pointToContent = group.Inverse.Transform(point);
  4071. ScaleTransform transform = group.Children[0] as ScaleTransform;
  4072. if (transform.ScaleX + delta < 0.1)
  4073. {
  4074. return;
  4075. }
  4076. transform.ScaleX += delta;
  4077. transform.ScaleY += delta;
  4078. TranslateTransform transform1 = group.Children[1] as TranslateTransform;
  4079. transform1.X = -1 * ((pointToContent.X * transform.ScaleX) - point.X);
  4080. transform1.Y = -1 * ((pointToContent.Y * transform.ScaleY) - point.Y);
  4081. //LogHelper.WriteInfoLog("【img宽高】" + imgCanvas.ActualWidth.ToString() + ":"
  4082. // + imgCanvas.ActualHeight.ToString() + "百分比:" + transform.ScaleX.ToString() + ":" + transform.ScaleY.ToString()
  4083. // );
  4084. //Console.WriteLine("transform.ScaleX = " + transform.ScaleX + "; transform.ScaleY = " + transform.ScaleY);
  4085. //APP.PageDrawList[APP.pageData.currpage - 1].ImageSize = new ScaleTransform();
  4086. //APP.PageDrawList[APP.pageData.currpage - 1].ImageSize.ScaleX = transform.ScaleX;
  4087. //APP.PageDrawList[APP.pageData.currpage - 1].ImageSize.ScaleY = transform.ScaleY;
  4088. APP.PageDrawList[APP.pageData.currpage - 1].ImageLocation = new TranslateTransform
  4089. {
  4090. X = transform1.X,
  4091. Y = transform1.Y
  4092. };
  4093. APP.PageDrawList[APP.pageData.currpage - 1].ImageSizes = new ScaleTransform
  4094. {
  4095. CenterX = imgCanvas.ActualWidth,
  4096. CenterY = imgCanvas.ActualHeight
  4097. };
  4098. APP.PageDrawList[APP.pageData.currpage - 1].IsImageLocation = false;
  4099. }
  4100. #endregion
  4101. #region 点阵笔相关
  4102. #region 值初始化
  4103. // 不同尺寸点阵纸点阵宽高尺寸计算方法为:纸张物理尺寸(毫米)/0.3 *8,详见 开发必读.pdf 文档
  4104. /// <summary>
  4105. /// A4点阵纸点阵宽度
  4106. /// </summary>
  4107. private const int A4_WIDTH = 5600;
  4108. /// <summary>
  4109. /// A4点阵纸点阵高度
  4110. /// </summary>
  4111. private const int A4_HEIGHT = 7920;
  4112. ///// <summary>
  4113. ///// 画板
  4114. ///// </summary>
  4115. //private Graphics graphics;
  4116. /// <summary>
  4117. /// 笔画坐标数组
  4118. /// </summary>
  4119. private List<System.Drawing.Point> stroke;
  4120. /// <summary>
  4121. /// 笔序列号
  4122. /// </summary>
  4123. private string penSerial;
  4124. /// <summary>
  4125. /// 笔是否在点
  4126. /// </summary>
  4127. private bool isPenDown;
  4128. //当前点阵地址
  4129. private string currentPageSerial = string.Empty;
  4130. //不同点阵地址对应的笔迹绘制图片,用于实现在不同点阵地址书写切换时,显示书写内容自动切换
  4131. //本例图片放在内存中存储,对于大量或者需要在多个点阵地址对应图片进行切换演示,建议将图片存储到文件,以免内存溢出
  4132. private Dictionary<string, System.Drawing.Image> pagesDic = new Dictionary<string, System.Drawing.Image>();
  4133. #endregion
  4134. public void InitPen()
  4135. {
  4136. stroke = new List<System.Drawing.Point>();
  4137. //获取点阵笔实例,并绑定点阵笔事件
  4138. //将授权文件内容传入,获取点阵笔对象实例
  4139. APP.digitalPen = DigitalPenHID.GetInstance(certificates.MyLicense.Bytes);
  4140. //绑定笔连接事件
  4141. APP.digitalPen.PenConnected += OnPenConnect;
  4142. //绑定笔断开事件
  4143. APP.digitalPen.PenDisconnect += OnPenDisconnect;
  4144. //绑定笔书写输出坐标事件
  4145. APP.digitalPen.PenCoordinate += OnPenCoordinate;
  4146. //绑定抬笔事件
  4147. APP.digitalPen.PenUp += OnPenUp;
  4148. //绑定落笔事件
  4149. APP.digitalPen.PenDown += OnPenDown;
  4150. APP.digitalPen.PenBatteryCapacity += OnBatteryCapacity;
  4151. APP.digitalPen.PenMemoryFillLevel += OnMemoryFillLevel;
  4152. //完成初始化点阵笔,开始与点阵笔通信
  4153. ERROR_CODE ER = APP.digitalPen.Start();
  4154. ////绑定笔在新的点阵地址页面书写事件
  4155. //APP.digitalPen.PenNewPage += APP.digitalPen_OnPenNewPage;
  4156. ////绑定笔信息事件
  4157. //APP.digitalPen.PenInfo += APP.digitalPen_OnPenInfo;
  4158. //启动接收笔数据,完成初始化工作
  4159. ERROR_CODE rc = APP.digitalPen.Start();
  4160. //判断是否成功
  4161. if (ER != ERROR_CODE.ERROR_OK)
  4162. {
  4163. MessageWindow.Show("初始化失败,授权过期,返回值:" + ER.ToString());
  4164. }
  4165. }
  4166. /// <summary>
  4167. /// 落笔
  4168. /// </summary>
  4169. /// <param name="time">时间戳,1970年1月1日到现在的总毫秒数</param>
  4170. /// <param name="penSerial">点阵笔序列号</param>
  4171. /// <param name="penType">点阵笔型号编号</param>
  4172. private void OnPenDown(ulong time, string penSerial, int penType)
  4173. {
  4174. if (CheckAccess())
  4175. {
  4176. Action<ulong, string, int> action = new Action<ulong, string, int>(OnPenDown);
  4177. Dispatcher.Invoke(action, new object[] { time, penSerial, penType });
  4178. }
  4179. else
  4180. {
  4181. //labPenSerial.Text = penSerial;
  4182. //labPenStatus.Text = "PenDown";
  4183. isPenDown = true;
  4184. //Dispatcher.Invoke(new Action(() =>
  4185. //{
  4186. // for (int i = 0; i < APP.PageDrawList.Count; i++)
  4187. // {
  4188. // if (APP.PageDrawList[i].PageCode == penSerial)
  4189. // {
  4190. // if (i < APP.pageData.pagenum)
  4191. // {
  4192. // if (i < APP.pageData.currpage)
  4193. // {
  4194. // int num = APP.pageData.currpage - i;
  4195. // APP.pageData.currpage -= num;
  4196. // myblackboard.changepage(APP.pageData.currpage - 1);
  4197. // if (APP.PageDrawList.Count > 0)
  4198. // {
  4199. // if (!string.IsNullOrWhiteSpace(txbCurrpage.Text) && APP.pageData.currpage <= APP.PageDrawList.Count && APP.pageData.currpage > 0 && !string.IsNullOrWhiteSpace(APP.PageDrawList[APP.pageData.currpage - 1].PageImagePath))
  4200. // {
  4201. // //imgCanvas.Source = new BitmapImage(new Uri(APP.Paths[APP.pageData.currpage - 1]));//cs
  4202. // imgCanvas.Source = new BitmapImage(new Uri(APP.PageDrawList[APP.pageData.currpage - 1].PageImagePath));
  4203. // }
  4204. // else
  4205. // {
  4206. // imgCanvas.Source = null;
  4207. // }
  4208. // }
  4209. // }
  4210. // else
  4211. // {
  4212. // int num = i - APP.pageData.currpage;
  4213. // APP.pageData.currpage += num;
  4214. // myblackboard.changepage(APP.pageData.currpage - 1);
  4215. // if (APP.PageDrawList.Count > 0)
  4216. // {
  4217. // if (!string.IsNullOrWhiteSpace(txbCurrpage.Text) && APP.pageData.currpage <= APP.PageDrawList.Count && !string.IsNullOrWhiteSpace(APP.PageDrawList[APP.pageData.currpage - 1].PageImagePath))
  4218. // {
  4219. // //imgCanvas.Source = new BitmapImage(new Uri(APP.Paths[APP.pageData.currpage-1]));
  4220. // imgCanvas.Source = new BitmapImage(new Uri(APP.PageDrawList[APP.pageData.currpage - 1].PageImagePath));
  4221. // }
  4222. // else
  4223. // {
  4224. // imgCanvas.Source = null;
  4225. // }
  4226. // }
  4227. // }
  4228. // }
  4229. // return;
  4230. // }
  4231. // }
  4232. // //myblackboard.changepages(0, 0, true);
  4233. // //myblackboard.changepaget(0, 0, true, blackboard_canvas);
  4234. //}));
  4235. }
  4236. //myblackboard.changepages(0, 0, true);
  4237. }
  4238. /// <summary>
  4239. /// 抬笔
  4240. /// </summary>
  4241. /// <param name="time">时间戳,1970年1月1日到现在的总毫秒数</param>
  4242. /// <param name="penSerial">点阵笔序列号</param>
  4243. /// <param name="penType">点阵笔型号编号</param>
  4244. private void OnPenUp(ulong time, string penSerial, int penType)
  4245. {
  4246. if (CheckAccess())
  4247. {
  4248. Action<ulong, string, int> action = new Action<ulong, string, int>(OnPenUp);
  4249. Dispatcher.Invoke(action, new object[] { time, penSerial, penType });
  4250. }
  4251. else
  4252. {
  4253. isPenDown = false;
  4254. APP.PenSerial = penSerial;
  4255. //int leftPoints = stroke.Count % 3;
  4256. //if (0 != leftPoints)
  4257. //{
  4258. // int from = stroke.Count - leftPoints - 1;
  4259. // if (from < 0)
  4260. // from = 0;
  4261. // int to = stroke.Count - 1;
  4262. // DrawCoordinates(from, to);
  4263. //}
  4264. stroke.Clear();
  4265. }
  4266. if (APP.pageData.currpage > 0)
  4267. {
  4268. Dispatcher.Invoke(new Action(() =>
  4269. {
  4270. myblackboard.changepages(0, 0, true, Color, PenSize, APP.pageData.currpage - 1,0);
  4271. }));
  4272. }
  4273. }
  4274. /// <summary>
  4275. /// 笔断开
  4276. /// </summary>
  4277. /// <param name="time">时间戳,1970年1月1日到现在的总毫秒数</param>
  4278. /// <param name="penSerial">点阵笔序列号</param>
  4279. /// <param name="penType">点阵笔型号编号</param>
  4280. private void OnPenDisconnect(ulong time, string penSerial, int penType)
  4281. {
  4282. if (CheckAccess())
  4283. {
  4284. Action<ulong, string, int> action = new Action<ulong, string, int>(OnPenDisconnect);
  4285. Dispatcher.Invoke(action, new object[] { time, penSerial, penType });
  4286. }
  4287. else
  4288. {
  4289. APP.PenSerial = penSerial;
  4290. APP.PenStatus = false;
  4291. UpdateDevStatus();
  4292. //Dispatcher.Invoke(new Action(() =>
  4293. //{
  4294. // txbNotConnected.Text = "未连接";
  4295. // txbNotConnecteds.Text = "未连接";
  4296. //}));
  4297. }
  4298. }
  4299. /// <summary>
  4300. /// 笔连接
  4301. /// </summary>
  4302. /// <param name="time">时间戳,1970年1月1日到现在的总毫秒数</param>
  4303. /// <param name="penSerial">点阵笔序列号</param>
  4304. /// <param name="penType">点阵笔型号编号</param>
  4305. private void OnPenConnect(ulong time, string penSerial, int penType)
  4306. {
  4307. if (CheckAccess())
  4308. {
  4309. Action<ulong, string, int> action = new Action<ulong, string, int>(OnPenConnect);
  4310. Dispatcher.Invoke(action, new object[] { time, penSerial, penType });
  4311. }
  4312. else
  4313. {
  4314. APP.PenSerial = penSerial;
  4315. APP.PenStatus = true;
  4316. this.penSerial = penSerial;
  4317. //连接后,在获取笔数据前,可以清除笔内的历史数据
  4318. //APP.digitalPen.ClearMemory(penSerial);
  4319. //开始接收笔数据
  4320. APP.digitalPen.GetPenData(penSerial);
  4321. UpdateDevStatus();
  4322. //Dispatcher.Invoke(new Action(() =>
  4323. //{
  4324. // txbNotConnected.Text = "已连接";
  4325. // txbNotConnecteds.Text = "已连接";
  4326. //}));
  4327. }
  4328. }
  4329. /// <summary>
  4330. /// 电池电量
  4331. /// </summary>
  4332. /// <param name="time"></param>
  4333. /// <param name="penSerial"></param>
  4334. /// <param name="penType"></param>
  4335. /// <param name="capacity"></param>
  4336. private void OnBatteryCapacity(ulong time, string penSerial, int penType, byte capacity)
  4337. {
  4338. if (CheckAccess())
  4339. {
  4340. Action<ulong, string, int, byte> action = new Action<ulong, string, int, byte>(OnBatteryCapacity);
  4341. Dispatcher.Invoke(action, new object[] { time, penSerial, penType, capacity });
  4342. }
  4343. else
  4344. {
  4345. //System.Windows.MessageWindow.Show("电池电量:" + capacity.ToString());
  4346. }
  4347. }
  4348. /// <summary>
  4349. /// 已用存储
  4350. /// </summary>
  4351. /// <param name="time"></param>
  4352. /// <param name="penSerial"></param>
  4353. /// <param name="penType"></param>
  4354. /// <param name="fillLevel"></param>
  4355. private void OnMemoryFillLevel(ulong time, string penSerial, int penType, byte fillLevel)
  4356. {
  4357. if (CheckAccess())
  4358. {
  4359. Action<ulong, string, int, byte> action = new Action<ulong, string, int, byte>(OnMemoryFillLevel);
  4360. Dispatcher.Invoke(action, new object[] { time, penSerial, penType, fillLevel });
  4361. }
  4362. else
  4363. {
  4364. //System.Windows.MessageWindow.Show("存储:" + fillLevel.ToString());
  4365. }
  4366. }
  4367. /// <summary>
  4368. /// 笔书写,收到坐标
  4369. /// </summary>
  4370. /// <param name="time">时间戳,1970年1月1日到现在的总毫秒数</param>
  4371. /// <param name="penSerial">点阵笔序列号</param>
  4372. /// <param name="penType">点阵笔型号编号</param>
  4373. /// <param name="pageSerial">点阵地址</param>
  4374. /// <param name="cx">x坐标</param>
  4375. /// <param name="cy">y坐标</param>
  4376. /// <param name="force">压力值</param>
  4377. private void OnPenCoordinate(ulong time, string penSerial, int penType, string pageSerial, int cx, int cy, byte force)
  4378. {
  4379. if (CheckAccess())
  4380. {
  4381. Action<ulong, string, int, string, int, int, byte> ac = new Action<ulong, string, int, string, int, int, byte>(OnPenCoordinate);
  4382. Dispatcher.Invoke(ac, new object[] { time, pageSerial, penType, pageSerial, cx, cy, force });
  4383. }
  4384. else
  4385. {
  4386. //判断是否是落笔后输出的坐标,在设置悬浮模式下,落笔前的悬浮坐标不绘制
  4387. if (!isPenDown)
  4388. {
  4389. return;
  4390. }
  4391. stroke.Add(new System.Drawing.Point(cx, cy));
  4392. double PropW = blackboard_canvas.ActualWidth / A4_WIDTH;
  4393. double PropH = blackboard_canvas.ActualHeight / A4_HEIGHT;
  4394. //点
  4395. double testX = cx * PropW;
  4396. double testY = cy * PropH;
  4397. //pageSerial //点阵IP地址 与打印的页面关联
  4398. if (APP.pageData.currpage > 0)
  4399. {
  4400. Dispatcher.Invoke(new Action(() =>
  4401. {
  4402. float Pressure = force / 100f;
  4403. //myblackboard.changepages(testX, testY,false);
  4404. myblackboard.changepages(testX, testY, false, Color, PenSize, APP.pageData.currpage - 1, Pressure);
  4405. #region 设置滚动条位置
  4406. //点在显示页面上方
  4407. if (testY < scroMain.VerticalOffset)
  4408. {
  4409. //滚动条当前位置
  4410. double RollCurrentLocation = scroMain.VerticalOffset;
  4411. //向上滚动至以点为中心需要滚动的距离
  4412. double UpRoll = (RollCurrentLocation - testY) + (scroMain.ActualHeight / 2);
  4413. //如果小于0则等于0
  4414. double RollLocation = RollCurrentLocation - UpRoll;
  4415. if (RollLocation < 0)
  4416. {
  4417. RollLocation = 0;
  4418. }
  4419. ////滚动条实际偏移量
  4420. //double RollOffset = RollCurrentLocation - RollLocation;
  4421. scroMain.ScrollToVerticalOffset(RollLocation);
  4422. }
  4423. //点在显示页面下方
  4424. if (testY > scroMain.VerticalOffset + scroMain.ActualHeight)
  4425. {
  4426. //滚动条当前位置
  4427. double RollCurrentLocation = scroMain.VerticalOffset;
  4428. //向下滚动至以点为中心需要滚动的距离
  4429. double DownRoll = (testY - RollCurrentLocation) - (scroMain.ActualHeight / 2);
  4430. //如果小于0则等于0
  4431. double RollLocation = RollCurrentLocation + DownRoll;
  4432. //滚动条最大滚动值
  4433. double ScrollbarMaxNum = gridM.ActualHeight - scroMain.ActualHeight;
  4434. if (RollLocation > ScrollbarMaxNum)
  4435. {
  4436. RollLocation = ScrollbarMaxNum;
  4437. }
  4438. ////滚动条实际偏移量
  4439. //double RollOffset = RollLocation-RollCurrentLocation;
  4440. scroMain.ScrollToVerticalOffset(RollLocation);
  4441. }
  4442. #endregion
  4443. //gridM.Height //A4高度
  4444. //scroMain.VerticalOffset;//获取滚动条位置
  4445. //scroMain.ActualHeight//A4纸显示高度
  4446. //scroMain.ScrollToHorizontalOffset()//设置滚动条位置
  4447. //Mouse.GetPosition(this)
  4448. if (testX > 0 && testY > 0)
  4449. {
  4450. //System.Windows.Point getP = blackboard_canvas.PointToScreen(new System.Windows.Point(testX, testY));
  4451. System.Windows.Point getP = scroMain.PointToScreen(new System.Windows.Point(testX, testY - scroMain.VerticalOffset));
  4452. SetCursorPos((int)getP.X, (int)getP.Y);
  4453. }
  4454. }));
  4455. }
  4456. ////每3个点画一条曲线
  4457. //if (stroke.Count % 3 == 0)
  4458. //{
  4459. // int from = stroke.Count - 3 - 1;
  4460. // if (from < 0)
  4461. // from = 0;
  4462. // int to = stroke.Count - 1;
  4463. // DrawCoordinates(from, to);
  4464. //}
  4465. }
  4466. }
  4467. /// <summary>
  4468. /// 停止笔
  4469. /// </summary>
  4470. public void StopDigitalPen()
  4471. {
  4472. //停止,释放资源
  4473. APP.digitalPen.Stop();
  4474. }
  4475. /// <summary>
  4476. /// 清空笔内存储
  4477. /// </summary>
  4478. public void ClearPenStorage()
  4479. {
  4480. if (!string.IsNullOrEmpty(penSerial))
  4481. {
  4482. APP.digitalPen.ClearMemory(penSerial);
  4483. }
  4484. }
  4485. /// <summary>
  4486. /// 获取剩余电量
  4487. /// </summary>
  4488. public void GetPenElectricityQuantity()
  4489. {
  4490. if (!string.IsNullOrEmpty(penSerial))
  4491. {
  4492. APP.digitalPen.GetBatteryCapacity(penSerial);
  4493. }
  4494. }
  4495. /// <summary>
  4496. /// 获取存储空间
  4497. /// </summary>
  4498. public void GetUsedStorage()
  4499. {
  4500. if (!string.IsNullOrEmpty(penSerial))
  4501. {
  4502. APP.digitalPen.GetMemoryFillLevel(penSerial);
  4503. }
  4504. }
  4505. /// <summary>
  4506. /// 开启悬浮
  4507. /// </summary>
  4508. public void 开启悬浮()
  4509. {
  4510. if (!string.IsNullOrEmpty(penSerial))
  4511. {
  4512. APP.digitalPen.SetPenHoverMode(true, penSerial);
  4513. }
  4514. }
  4515. /// <summary>
  4516. /// 关闭悬浮
  4517. /// </summary>
  4518. public void 关闭悬浮()
  4519. {
  4520. if (!string.IsNullOrEmpty(penSerial))
  4521. {
  4522. APP.digitalPen.SetPenHoverMode(false, penSerial);
  4523. }
  4524. }
  4525. /// <summary>
  4526. /// 引用user32.dll动态链接库(windows api),
  4527. /// 使用库中定义 API:SetCursorPos
  4528. /// 设置光标位置
  4529. /// </summary>
  4530. [System.Runtime.InteropServices.DllImport("user32.dll")]
  4531. private static extern int SetCursorPos(int x, int y);
  4532. #endregion
  4533. #region 写字板模式
  4534. #region 值初始化
  4535. [System.Runtime.InteropServices.DllImport("kernel32.dll", CharSet = System.Runtime.InteropServices.CharSet.Auto)]
  4536. public static extern void OutputDebugString(string message);
  4537. public bool usbIsConnected = false;
  4538. //Angle angle = Angle._270;
  4539. eDeviceType deviceType = eDeviceType.Unknow;
  4540. /// <summary>
  4541. /// 点缩放比例
  4542. /// </summary>
  4543. private double m_nCompress = 0;
  4544. private double m_nCompress_x = 0;
  4545. private double m_nCompress_y = 0;
  4546. /// <summary>
  4547. /// 0:画布根据板子适配
  4548. /// 1:板子根据画布适配
  4549. /// </summary>
  4550. private int type = 1;//默认画笔根据板子适配
  4551. bool bScreenO = false;//判断是否是横屏,默认横屏,true:横屏幕;false:竖屏
  4552. Drawing drawing;
  4553. //List<RobotPoint> plist = new List<RobotPoint>();
  4554. //画布宽高
  4555. //private int m_nDeviceW = 21000;
  4556. //private int m_nDeviceH = 29700;
  4557. private int m_nDeviceW = 22600;
  4558. private int m_nDeviceH = 16650;
  4559. private RobotpenGateway.robotpenController.returnPointData date = null;
  4560. private int nResource = 0;
  4561. private ReportRate RR = ReportRate.R_200;
  4562. string Mac = string.Empty;
  4563. int Recog_create = 0;
  4564. int Recog_adddate = 0;
  4565. int Recog_start = 0;
  4566. public bool isOpen = true;
  4567. //PrintType ptype = PrintType.NoMarkCode_FB2;
  4568. //int pageData = 0;
  4569. bool AreSynchronized = false;
  4570. /// <summary>
  4571. /// 笔模式
  4572. /// </summary>
  4573. bool IsPen = false;
  4574. #endregion
  4575. #region 罗博智慧笔
  4576. /// <summary>
  4577. /// 笔模式
  4578. /// </summary>
  4579. private void deviceHand()
  4580. {
  4581. if (deviceType == eDeviceType.T8B_D2 || deviceType == eDeviceType.T8Y || deviceType == eDeviceType.T8S_LQ)
  4582. {
  4583. robotpenController.GetInstance().setDeviceMode(eDeviceMode.DEVICE_HAND);
  4584. }
  4585. else
  4586. {
  4587. IsPen = true;
  4588. //获取当前设备模式,根据模式切换鼠标和笔
  4589. robotpenController.GetInstance()._Send(cmdId.SearchMode);
  4590. }
  4591. }
  4592. /// <summary>
  4593. /// 鼠标模式
  4594. /// </summary>
  4595. private void deviceMouse()
  4596. {
  4597. if (deviceType == eDeviceType.T8B_D2 || deviceType == eDeviceType.T8Y || deviceType == eDeviceType.T8S_LQ)
  4598. {
  4599. robotpenController.GetInstance().setDeviceMode(eDeviceMode.DEVICE_MOUSE);
  4600. }
  4601. else
  4602. {
  4603. IsPen = false;
  4604. //获取当前设备模式,根据模式切换鼠标和笔
  4605. robotpenController.GetInstance()._Send(cmdId.SearchMode);
  4606. }
  4607. }
  4608. private void Form1_searchModeEvt(int modeType)
  4609. {
  4610. if (modeType == 1)
  4611. {
  4612. //当前为笔模式时 切换回鼠标模式
  4613. if(!IsPen)
  4614. {
  4615. robotpenController.GetInstance()._Send(cmdId.SwitchMode);
  4616. }
  4617. }
  4618. else
  4619. {
  4620. //当前为鼠标模式 切换为笔模式
  4621. if(isOpen)
  4622. {
  4623. robotpenController.GetInstance()._Send(cmdId.SwitchMode);
  4624. }
  4625. }
  4626. }
  4627. private void Form1_switchModeEvt(int modeType)
  4628. {
  4629. if (modeType == 1)
  4630. {
  4631. //当前为笔模式时 切换回鼠标模式
  4632. if (!IsPen)
  4633. {
  4634. robotpenController.GetInstance()._Send(cmdId.SwitchMode);
  4635. }
  4636. }
  4637. else
  4638. {
  4639. //当前为鼠标模式 切换为笔模式
  4640. if (isOpen)
  4641. {
  4642. robotpenController.GetInstance()._Send(cmdId.SwitchMode);
  4643. }
  4644. }
  4645. }
  4646. //初始化笔服务
  4647. private void InitlbPen()
  4648. {
  4649. try
  4650. {
  4651. robotpenController.GetInstance()._ConnectInitialize(eDeviceType.Gateway, IntPtr.Zero);
  4652. robotpenController.GetInstance().deviceChangeEvt += new robotpenController.DeviceChange(Form1_deviceChangeEvt);
  4653. robotpenController.GetInstance().searchModeEvt += Form1_searchModeEvt;
  4654. robotpenController.GetInstance().switchModeEvt += Form1_switchModeEvt;
  4655. //robotpenController.GetInstance().deviceChangeEvt += new robotpenController.DeviceChange(Form1_deviceChangeEvt);
  4656. //robotpenController.GetInstance().gatewatVersionEvt += Form1_gatewatVersionEvt;
  4657. //robotpenController.GetInstance().nodeStatusEvt += Form1_nodeStatusEvt;
  4658. //// 所有设备均注册该页码显示消息 目前只有T9设备才会有页码识别功能, 客户代码可以根据设备来判断是否消费该事件
  4659. //robotpenController.GetInstance().showPageEvt += new robotpenController.ShowPage(Form1_showPageEvt);
  4660. // T8A 按键消息 为了适应其他demo也能响应, 所以任何demo都消费此事件, 客户代码可根据设备类型判断是否消费此事件
  4661. robotpenController.GetInstance().keyPressEvt += new robotpenController.KeyPress(Form1_keyPressEvt);
  4662. //robotpenController.GetInstance().PageSensorCallback_Evt += Rbtnet__PageSensorEvt_;
  4663. date = new RobotpenGateway.robotpenController.returnPointData(Form1_bigDataReportEvt1);
  4664. robotpenController.GetInstance().initDeletgate(ref date);
  4665. CheckUsbConnect();
  4666. ////robotpenController.GetInstance().returnOptimizePointDataEvt += new robotpenController.returnOptimizePointData(Form1_returnOptimizePointDataEvt);
  4667. //robotpenController.GetInstance().startSyncNoteDataEvt += new robotpenController.startSyncNoteData(Form1_startSyncNoteDataEvt);
  4668. //robotpenController.GetInstance().startSyncNoteData_kzEvt += Form1_startSyncNoteData_kzEvt;
  4669. //robotpenController.GetInstance().syncNoteDataEvt += new robotpenController.syncNoteData(Form1_syncNoteDataEvt);
  4670. //robotpenController.GetInstance().endSyncNoteDataEvt += new robotpenController.endSyncNoteData(Form1_endSyncNoteDataEvt);
  4671. //robotpenController.GetInstance().getOfflineNoteDataEvt += new robotpenController.getOfflineNoteData(Form1_getOfflineNoteDataEvt);
  4672. }
  4673. catch (Exception ex)
  4674. {
  4675. }
  4676. }
  4677. /// <summary>
  4678. /// 委托实例函数,用于异步修改listview显示的USB连接设备信息
  4679. /// </summary>
  4680. private void SetListView()
  4681. {
  4682. if (usbIsConnected)
  4683. {
  4684. robotpenController.GetInstance()._CloseConnect();
  4685. }
  4686. CheckUsbConnect();
  4687. }
  4688. /// <summary>
  4689. /// 设备插拔消息,更新listview
  4690. /// </summary>
  4691. /// <param name="bStatus"></param>
  4692. /// <param name="uPid"></param>
  4693. void Form1_deviceChangeEvt(bool bStatus, ushort uPid)
  4694. {
  4695. //throw new NotImplementedException();
  4696. //Console.WriteLine();
  4697. if (APP.IsOutputInfoLog)
  4698. {
  4699. LogHelper.WriteInfoLog(string.Format("设备状态{0} PID = {1}", bStatus, uPid));
  4700. }
  4701. SetListView();
  4702. }
  4703. /// <summary>
  4704. ///
  4705. /// </summary>
  4706. /// /// <param name="bIndex"></param>
  4707. /// <param name="bPenStatus"></param>
  4708. /// <param name="bx"></param>
  4709. /// <param name="by"></param>
  4710. /// <param name="bPress"></param>
  4711. private void Form1_bigDataReportEvt1(byte bIndex, byte bPenStatus, short bx, short by, short bPress)
  4712. {
  4713. //17是按下,16是抬起
  4714. if (bPenStatus == 16|| bPenStatus==0)
  4715. {
  4716. stroke.Clear();
  4717. if (APP.pageData.currpage > 0)
  4718. {
  4719. Dispatcher.Invoke(new Action(() =>
  4720. {
  4721. myblackboard.changepages(0, 0, true, Color, PenSize, APP.pageData.currpage - 1, 0);
  4722. }));
  4723. }
  4724. }
  4725. ////按下
  4726. //if (bPenStatus == 17)
  4727. //{
  4728. //}
  4729. if(APP.IsOutputInfoLog)
  4730. {
  4731. LogHelper.WriteInfoLog(string.Format(@"x={0},y={1},s={2},p={3}", bx, by, bPenStatus, bPress));
  4732. }
  4733. stroke.Add(new System.Drawing.Point(by, bx));
  4734. double PropW = blackboard_canvas.ActualWidth / m_nDeviceH;
  4735. double PropH = blackboard_canvas.ActualHeight / m_nDeviceW;
  4736. //点
  4737. double testY = (m_nDeviceW - bx) * PropH;
  4738. double testX = by * PropW;
  4739. //pageSerial //点阵IP地址 与打印的页面关联
  4740. if (APP.pageData.currpage > 0)
  4741. {
  4742. Dispatcher.Invoke(new Action(() =>
  4743. {
  4744. float Pressure = bPress / 100f;
  4745. //myblackboard.changepages(testX, testY,false);
  4746. if (bPress > 0)
  4747. {
  4748. myblackboard.changepages(testX, testY, false, Color, PenSize, APP.pageData.currpage - 1, Pressure);
  4749. }
  4750. #region 设置滚动条位置
  4751. //点在显示页面上方
  4752. if (testY < scroMain.VerticalOffset)
  4753. {
  4754. //滚动条当前位置
  4755. double RollCurrentLocation = scroMain.VerticalOffset;
  4756. //向上滚动至以点为中心需要滚动的距离
  4757. double UpRoll = (RollCurrentLocation - testY) + (scroMain.ActualHeight / 2);
  4758. //如果小于0则等于0
  4759. double RollLocation = RollCurrentLocation - UpRoll;
  4760. if (RollLocation < 0)
  4761. {
  4762. RollLocation = 0;
  4763. }
  4764. ////滚动条实际偏移量
  4765. //double RollOffset = RollCurrentLocation - RollLocation;
  4766. scroMain.ScrollToVerticalOffset(RollLocation);
  4767. }
  4768. //点在显示页面下方
  4769. if (testY > scroMain.VerticalOffset + scroMain.ActualHeight)
  4770. {
  4771. //滚动条当前位置
  4772. double RollCurrentLocation = scroMain.VerticalOffset;
  4773. //向下滚动至以点为中心需要滚动的距离
  4774. double DownRoll = (testY - RollCurrentLocation) - (scroMain.ActualHeight / 2);
  4775. //如果小于0则等于0
  4776. double RollLocation = RollCurrentLocation + DownRoll;
  4777. //滚动条最大滚动值
  4778. double ScrollbarMaxNum = gridM.ActualHeight - scroMain.ActualHeight;
  4779. if (RollLocation > ScrollbarMaxNum)
  4780. {
  4781. RollLocation = ScrollbarMaxNum;
  4782. }
  4783. ////滚动条实际偏移量
  4784. //double RollOffset = RollLocation-RollCurrentLocation;
  4785. scroMain.ScrollToVerticalOffset(RollLocation);
  4786. }
  4787. #endregion
  4788. if (testX > 0 && testY > 0)
  4789. {
  4790. //System.Windows.Point getP = blackboard_canvas.PointToScreen(new System.Windows.Point(testX, testY));
  4791. System.Windows.Point getP = scroMain.PointToScreen(new System.Windows.Point(testX, testY - scroMain.VerticalOffset));
  4792. SetCursorPos((int)getP.X, (int)getP.Y);
  4793. }
  4794. }));
  4795. }
  4796. }
  4797. /// <summary>
  4798. /// 判断是否有设备连接
  4799. /// </summary>
  4800. public void CheckUsbConnect()
  4801. {
  4802. usbIsConnected = false;
  4803. Thread.Sleep(200);
  4804. int nDeviceCount = robotpenController.GetInstance()._GetDeviceCount();
  4805. if (nDeviceCount > 0)
  4806. {
  4807. //this.listView1.BeginUpdate();
  4808. for (int i = 0; i < nDeviceCount; ++i)
  4809. {
  4810. ushort npid = 0;
  4811. ushort nvid = 0;
  4812. string strDeviceName = string.Empty;
  4813. eDeviceType dtype = eDeviceType.Unknow;
  4814. if (robotpenController.GetInstance()._GetAvailableDevice(i, ref npid, ref nvid, ref strDeviceName, ref dtype))
  4815. {
  4816. if (!usbIsConnected)
  4817. {
  4818. usbIsConnected = true;
  4819. deviceType = dtype;
  4820. robotpenController.GetInstance()._ConnectInitialize(deviceType, IntPtr.Zero);
  4821. int nRes = robotpenController.GetInstance()._ConnectOpen();
  4822. if (nRes != 0)
  4823. {
  4824. //LogHelper.WriteInfoLog(string.Format(@"x={0},y={1},s={2},p={3}", bx, by, bPenStatus, bPress));
  4825. LogHelper.WriteErrLog("设备自动连接失败,请重新插拔设备或尝试手动连接!",null);
  4826. usbIsConnected = false;
  4827. break;
  4828. }
  4829. //robotpenController.GetInstance()._Send(cmdId.SwitchMode);
  4830. robotpenController.GetInstance()._Send(cmdId.GetConfig);
  4831. APP.BoardStatus = true;
  4832. UpdateDevStatus();
  4833. //Dispatcher.Invoke(new Action(() =>
  4834. //{
  4835. // txbNotConnected.Text = "手写板";
  4836. // txbNotConnecteds.Text = "手写板";
  4837. //}));
  4838. }
  4839. }
  4840. }
  4841. }
  4842. else
  4843. {
  4844. APP.BoardStatus = false;
  4845. UpdateDevStatus();
  4846. }
  4847. }
  4848. /// <summary>
  4849. /// 按键回调函数
  4850. /// </summary>
  4851. /// <param name="Value"></param>
  4852. private void Form1_keyPressEvt(eKeyPress Value)
  4853. {
  4854. Dispatcher.Invoke(new Action(() =>
  4855. {
  4856. switch (Value)
  4857. {
  4858. case eKeyPress.CLICK:
  4859. break;
  4860. case eKeyPress.DBCLICK:
  4861. break;
  4862. case eKeyPress.PAGEUP:
  4863. last_button_Click(null, null);
  4864. break;
  4865. case eKeyPress.PAGEDOWN:
  4866. next_btn_Click(null, null);
  4867. break;
  4868. case eKeyPress.CREATEPAGE://关机键
  4869. break;
  4870. case eKeyPress.KEY_A:
  4871. break;
  4872. case eKeyPress.KEY_B:
  4873. break;
  4874. case eKeyPress.KEY_C:
  4875. break;
  4876. case eKeyPress.KEY_D:
  4877. break;
  4878. case eKeyPress.KEY_E:
  4879. break;
  4880. case eKeyPress.KEY_F:
  4881. break;
  4882. case eKeyPress.KEY_UP:
  4883. last_button_Click(null, null);
  4884. break;
  4885. case eKeyPress.KEY_DOWN:
  4886. next_btn_Click(null, null);
  4887. break;
  4888. case eKeyPress.KEY_YES:
  4889. break;
  4890. case eKeyPress.KEY_NO:
  4891. break;
  4892. case eKeyPress.KEY_CANCEL:
  4893. break;
  4894. case eKeyPress.KEY_OK:
  4895. break;
  4896. case eKeyPress.PAGEUPCLICK://上一页
  4897. last_button_Click(null, null);
  4898. break;
  4899. case eKeyPress.PAGEUPDBCLICK://双击上一页
  4900. break;
  4901. case eKeyPress.PAGEUPPRESS://长按上一页
  4902. break;
  4903. case eKeyPress.PAGEDOWNCLICK://下一页
  4904. next_btn_Click(null, null);
  4905. break;
  4906. case eKeyPress.PAGEDOWNDBCLICK://双击下一页
  4907. break;
  4908. case eKeyPress.PAGEDOWNPRESS://长按下一页
  4909. break;
  4910. }
  4911. }));
  4912. }
  4913. #endregion
  4914. /// <summary>
  4915. /// 更新设备状态显示
  4916. /// </summary>
  4917. void UpdateDevStatus()
  4918. {
  4919. if (APP.BoardStatus && APP.PenStatus)
  4920. {
  4921. Dispatcher.Invoke(new Action(() =>
  4922. {
  4923. txbNotConnected.Text = "笔/板";
  4924. txbNotConnecteds.Text = "笔/板";
  4925. }));
  4926. }
  4927. else if(APP.BoardStatus)
  4928. {
  4929. Dispatcher.Invoke(new Action(() =>
  4930. {
  4931. txbNotConnected.Text = "手写板";
  4932. txbNotConnecteds.Text = "手写板";
  4933. }));
  4934. }
  4935. else if (APP.PenStatus)
  4936. {
  4937. Dispatcher.Invoke(new Action(() =>
  4938. {
  4939. txbNotConnected.Text = "智能笔";
  4940. txbNotConnecteds.Text = "智能笔";
  4941. }));
  4942. }
  4943. else
  4944. {
  4945. Dispatcher.Invoke(new Action(() =>
  4946. {
  4947. txbNotConnected.Text = "未连接";
  4948. txbNotConnecteds.Text = "未连接";
  4949. }));
  4950. }
  4951. }
  4952. #endregion
  4953. #region 图片拉伸移动
  4954. private System.Windows.Point initialPoint;
  4955. /// <summary>
  4956. /// 隐藏图片四个点和线
  4957. /// </summary>
  4958. private void HideAngleBorder()
  4959. {
  4960. RectLeftUp.Visibility = Visibility.Hidden;
  4961. RectRightUp.Visibility = Visibility.Hidden;
  4962. RectLeftDown.Visibility = Visibility.Hidden;
  4963. RectRightDown.Visibility = Visibility.Hidden;
  4964. RectImgBorder.Visibility = Visibility.Hidden;
  4965. }
  4966. private void ShowAngleBorder()
  4967. {
  4968. PointLocation();
  4969. RectLeftUp.Visibility = Visibility.Visible;
  4970. RectRightUp.Visibility = Visibility.Visible;
  4971. RectLeftDown.Visibility = Visibility.Visible;
  4972. RectRightDown.Visibility = Visibility.Visible;
  4973. RectImgBorder.Visibility = Visibility.Visible;
  4974. }
  4975. /// <summary>
  4976. /// 确定四个点和边框的位置大小
  4977. /// </summary>
  4978. private void PointLocation()
  4979. {
  4980. RectImgBorder.Width = imgCanvas.ActualWidth + 10.0;
  4981. RectImgBorder.Height = imgCanvas.ActualHeight + 10.0;
  4982. RectImgBorder.Margin = new Thickness(imgCanvas.Margin.Left - 5.0, imgCanvas.Margin.Top - 5.0, 0, 0);
  4983. Canvas.SetLeft(RectLeftUp, imgCanvas.Margin.Left - 10.0);
  4984. Canvas.SetTop(RectLeftUp, imgCanvas.Margin.Top - 10.0);
  4985. Canvas.SetLeft(RectRightUp, imgCanvas.Margin.Left + imgCanvas.ActualWidth - 10.0);
  4986. Canvas.SetTop(RectRightUp, imgCanvas.Margin.Top - 10.0);
  4987. Canvas.SetLeft(RectLeftDown, imgCanvas.Margin.Left - 10.0);
  4988. Canvas.SetTop(RectLeftDown, imgCanvas.Margin.Top + imgCanvas.ActualHeight - 10.0);
  4989. Canvas.SetLeft(RectRightDown, imgCanvas.Margin.Left + imgCanvas.ActualWidth - 10.0);
  4990. Canvas.SetTop(RectRightDown, imgCanvas.Margin.Top + imgCanvas.ActualHeight - 10.0);
  4991. }
  4992. private void PicEMap_MouseDown(object sender, MouseButtonEventArgs e)
  4993. {
  4994. System.Windows.Point point = e.GetPosition(imgCanvas);
  4995. initialPoint = point;
  4996. //Console.WriteLine("PicEmap.X = " + point.X + "; PicEmap.Y = " + point.Y);
  4997. //if ((point.X - 304) * (point.X - 304) + (point.Y - 86) * (point.Y - 86) < 100)
  4998. //{
  4999. // Console.WriteLine("在范围内");
  5000. //}
  5001. HideAngleBorder();
  5002. }
  5003. private void imgCanvas_MouseMove(object sender, System.Windows.Input.MouseEventArgs e)
  5004. {
  5005. if (e.LeftButton == MouseButtonState.Pressed && mouseDown)
  5006. {
  5007. System.Windows.Point point = e.GetPosition(imgCanvas);
  5008. imgCanvas.Margin = new Thickness(imgCanvas.Margin.Left + (point.X - initialPoint.X), imgCanvas.Margin.Top + (point.Y - initialPoint.Y), 0, 0);
  5009. APP.PageDrawList[APP.pageData.currpage - 1].ImageLocation = new TranslateTransform
  5010. {
  5011. X = imgCanvas.Margin.Left,
  5012. Y = imgCanvas.Margin.Top
  5013. };
  5014. APP.PageDrawList[APP.pageData.currpage - 1].ImageSizes = new ScaleTransform
  5015. {
  5016. CenterX = imgCanvas.ActualWidth,
  5017. CenterY = imgCanvas.ActualHeight
  5018. };
  5019. APP.PageDrawList[APP.pageData.currpage - 1].IsImageLocation = false;
  5020. }
  5021. }
  5022. private void imgCanvas_MouseUp(object sender, MouseButtonEventArgs e)
  5023. {
  5024. if (mouseDown)
  5025. {
  5026. ShowAngleBorder();
  5027. }
  5028. }
  5029. private System.Drawing.PointF imgRightDown;
  5030. /// <summary>
  5031. /// 设置控件最上层
  5032. /// </summary>
  5033. /// <param name="element"></param>
  5034. public void BringToFront(Thumb element)//图片置于最顶层显示
  5035. {
  5036. if (element == null)
  5037. {
  5038. return;
  5039. }
  5040. Canvas parent = element.Parent as Canvas;
  5041. if (parent == null)
  5042. {
  5043. return;
  5044. }
  5045. int maxZ = parent.Children.OfType<UIElement>()//linq语句,取Zindex的最大值
  5046. .Where(x => x != element)
  5047. .Select(x => Canvas.GetZIndex(x))
  5048. .Max();
  5049. Canvas.SetZIndex(element, maxZ + 1);
  5050. }
  5051. private void RectRightUp_DragStarted(object sender, System.Windows.Controls.Primitives.DragStartedEventArgs e)
  5052. {
  5053. try
  5054. {
  5055. Thumb thu = (Thumb)sender;
  5056. BringToFront(thu);
  5057. imgRightDown = new System.Drawing.PointF((float)(imgCanvas.Margin.Left + imgCanvas.ActualWidth), (float)(imgCanvas.Margin.Top + imgCanvas.ActualHeight));
  5058. HideAngleBorder();
  5059. switch (thu.Name)
  5060. {
  5061. case "RectLeftUp":
  5062. RectLeftUp.Visibility = Visibility.Visible;
  5063. break;
  5064. case "RectRightUp":
  5065. RectRightUp.Visibility = Visibility.Visible;
  5066. break;
  5067. case "RectLeftDown":
  5068. RectLeftDown.Visibility = Visibility.Visible;
  5069. break;
  5070. case "RectRightDown":
  5071. RectRightDown.Visibility = Visibility.Visible;
  5072. break;
  5073. default:
  5074. break;
  5075. }
  5076. }
  5077. catch (Exception ex)
  5078. {
  5079. MessageWindow.Show(ex.Message);
  5080. }
  5081. }
  5082. private void RectRightUp_DragDelta(object sender, System.Windows.Controls.Primitives.DragDeltaEventArgs e)
  5083. {
  5084. try
  5085. {
  5086. if (mouseDown)
  5087. {
  5088. Thumb thu = (Thumb)sender;
  5089. #region 判断是否超出 暂无
  5090. double plul = Canvas.GetLeft(RectLeftUp);
  5091. double plut = Canvas.GetTop(RectLeftUp);
  5092. double prdl = Canvas.GetLeft(RectRightDown);
  5093. double prdt = Canvas.GetTop(RectRightDown);
  5094. #endregion
  5095. //Canvas.SetLeft(thu, Canvas.GetLeft(thu) + e.HorizontalChange);
  5096. //Canvas.SetTop(thu, Canvas.GetTop(thu) + e.VerticalChange);
  5097. double imgW = 0;
  5098. double imgH = 0;
  5099. double imgX = 0;
  5100. double imgY = 0;
  5101. switch (thu.Name)
  5102. {
  5103. case "RectLeftUp":
  5104. #region 左上
  5105. imgW = imgRightDown.X - (Mouse.GetPosition(gridM).X);
  5106. imgH = imgRightDown.Y - (Mouse.GetPosition(gridM).Y);
  5107. imgX = 0;
  5108. imgY = 0;
  5109. if (imgW < 50)
  5110. {
  5111. imgCanvas.Width = 50;
  5112. imgX = imgCanvas.Margin.Left;
  5113. Canvas.SetLeft(thu, Canvas.GetLeft(RectRightDown) - 50);
  5114. }
  5115. else
  5116. {
  5117. imgCanvas.Width = imgW;
  5118. imgX = Mouse.GetPosition(gridM).X;
  5119. Canvas.SetLeft(thu, Canvas.GetLeft(thu) + e.HorizontalChange);
  5120. }
  5121. if (imgH < 50)
  5122. {
  5123. imgCanvas.Height = 50;
  5124. imgY = imgCanvas.Margin.Top;
  5125. Canvas.SetTop(thu, Canvas.GetTop(RectRightDown) - 50);
  5126. }
  5127. else
  5128. {
  5129. imgCanvas.Height = imgH;
  5130. imgY = Mouse.GetPosition(gridM).Y;
  5131. Canvas.SetTop(thu, Canvas.GetTop(thu) + e.VerticalChange);
  5132. }
  5133. imgCanvas.Margin = new Thickness(imgX, imgY, 0, 0);
  5134. #endregion
  5135. //imgCanvas.Width = imgRightDown.X - (Mouse.GetPosition(gridM).X);
  5136. //imgCanvas.Height = imgRightDown.Y - (Mouse.GetPosition(gridM).Y);
  5137. //imgCanvas.Margin = new Thickness(Mouse.GetPosition(gridM).X, Mouse.GetPosition(gridM).Y, 0, 0);
  5138. break;
  5139. case "RectRightUp":
  5140. #region 右上
  5141. imgW = Mouse.GetPosition(gridM).X - imgCanvas.Margin.Left;
  5142. imgH = imgRightDown.Y - (Mouse.GetPosition(gridM).Y);
  5143. imgX = 0;
  5144. imgY = 0;
  5145. if (imgW < 50)
  5146. {
  5147. imgCanvas.Width = 50;
  5148. imgX = imgCanvas.Margin.Left;
  5149. Canvas.SetLeft(thu, Canvas.GetLeft(RectLeftUp) + 50);
  5150. }
  5151. else
  5152. {
  5153. imgCanvas.Width = imgW;
  5154. imgX = imgCanvas.Margin.Left;
  5155. Canvas.SetLeft(thu, Canvas.GetLeft(thu) + e.HorizontalChange);
  5156. }
  5157. if (imgH < 50)
  5158. {
  5159. imgCanvas.Height = 50;
  5160. imgY = imgCanvas.Margin.Top;
  5161. Canvas.SetTop(thu, Canvas.GetTop(RectRightDown) - 50);
  5162. }
  5163. else
  5164. {
  5165. imgCanvas.Height = imgH;
  5166. imgY = Mouse.GetPosition(gridM).Y;
  5167. Canvas.SetTop(thu, Canvas.GetTop(thu) + e.VerticalChange);
  5168. }
  5169. imgCanvas.Margin = new Thickness(imgX, imgY, 0, 0);
  5170. //imgCanvas.Width = Mouse.GetPosition(gridM).X - imgCanvas.Margin.Left;
  5171. //imgCanvas.Height = imgRightDown.Y - (Mouse.GetPosition(gridM).Y);
  5172. //imgCanvas.Margin = new Thickness(imgCanvas.Margin.Left, Mouse.GetPosition(gridM).Y, 0, 0);
  5173. #endregion
  5174. break;
  5175. case "RectLeftDown":
  5176. #region 左下
  5177. imgW = imgRightDown.X - (Mouse.GetPosition(gridM).X);
  5178. imgH = Mouse.GetPosition(gridM).Y - imgCanvas.Margin.Top;
  5179. imgX = 0;
  5180. imgY = 0;
  5181. if (imgW < 50)
  5182. {
  5183. imgCanvas.Width = 50;
  5184. imgX = imgCanvas.Margin.Left;
  5185. Canvas.SetLeft(thu, Canvas.GetLeft(RectRightDown) - 50);
  5186. }
  5187. else
  5188. {
  5189. imgCanvas.Width = imgW;
  5190. imgX = Mouse.GetPosition(gridM).X;
  5191. Canvas.SetLeft(thu, Canvas.GetLeft(thu) + e.HorizontalChange);
  5192. }
  5193. if (imgH < 50)
  5194. {
  5195. imgCanvas.Height = 50;
  5196. imgY = imgCanvas.Margin.Top;
  5197. Canvas.SetTop(thu, Canvas.GetTop(RectLeftUp) + 50);
  5198. }
  5199. else
  5200. {
  5201. imgCanvas.Height = imgH;
  5202. imgY = imgCanvas.Margin.Top;
  5203. Canvas.SetTop(thu, Canvas.GetTop(thu) + e.VerticalChange);
  5204. }
  5205. imgCanvas.Margin = new Thickness(imgX, imgY, 0, 0);
  5206. //imgCanvas.Width = imgRightDown.X - (Mouse.GetPosition(gridM).X);
  5207. //imgCanvas.Height = Mouse.GetPosition(gridM).Y - imgCanvas.Margin.Top;
  5208. //imgCanvas.Margin = new Thickness(Mouse.GetPosition(gridM).X, imgCanvas.Margin.Top, 0, 0);
  5209. #endregion
  5210. break;
  5211. case "RectRightDown":
  5212. #region 右下
  5213. imgW = Mouse.GetPosition(gridM).X - imgCanvas.Margin.Left;
  5214. imgH = Mouse.GetPosition(gridM).Y - imgCanvas.Margin.Top;
  5215. if (imgW < 50)
  5216. {
  5217. imgCanvas.Width = 50;
  5218. Canvas.SetLeft(thu, Canvas.GetLeft(RectLeftUp) + 50);
  5219. }
  5220. else
  5221. {
  5222. imgCanvas.Width = imgW;
  5223. Canvas.SetLeft(thu, Canvas.GetLeft(thu) + e.HorizontalChange);
  5224. }
  5225. if (imgH < 50)
  5226. {
  5227. imgCanvas.Height = 50;
  5228. Canvas.SetTop(thu, Canvas.GetTop(RectLeftUp) + 50);
  5229. }
  5230. else
  5231. {
  5232. imgCanvas.Height = imgH;
  5233. Canvas.SetTop(thu, Canvas.GetTop(thu) + e.VerticalChange);
  5234. }
  5235. //imgCanvas.Margin = new Thickness(imgX, imgY, 0, 0);
  5236. //imgCanvas.Width += e.HorizontalChange;
  5237. //imgCanvas.Height += e.VerticalChange;
  5238. #endregion
  5239. break;
  5240. default:
  5241. break;
  5242. }
  5243. APP.PageDrawList[APP.pageData.currpage - 1].ImageLocation = new TranslateTransform
  5244. {
  5245. X = imgCanvas.Margin.Left,
  5246. Y = imgCanvas.Margin.Top
  5247. };
  5248. APP.PageDrawList[APP.pageData.currpage - 1].ImageSizes = new ScaleTransform
  5249. {
  5250. CenterX = imgCanvas.ActualWidth,
  5251. CenterY = imgCanvas.ActualHeight
  5252. };
  5253. APP.PageDrawList[APP.pageData.currpage - 1].IsImageLocation = false;
  5254. }
  5255. //lbl1.Content = imgCanvas.Margin.Left + "," + imgCanvas.Margin.Top;
  5256. //lbl2.Content = (imgCanvas.Margin.Left+ imgCanvas.Width) +"," + imgCanvas.Margin.Top;
  5257. //lbl3.Content = imgCanvas.Margin.Left + "," + (imgCanvas.Margin.Top+ imgCanvas.Height);
  5258. //lbl4.Content= (imgCanvas.Margin.Left + imgCanvas.Width )+ "," + (imgCanvas.Margin.Top + imgCanvas.Height);
  5259. }
  5260. catch (Exception)
  5261. {
  5262. MessageWindow.Show("图片过小!");
  5263. }
  5264. }
  5265. private void RectRightUp_DragCompleted(object sender, System.Windows.Controls.Primitives.DragCompletedEventArgs e)
  5266. {
  5267. ShowAngleBorder();
  5268. }
  5269. /// <summary>
  5270. /// 点击标题栏 隐藏截图的四个点和线
  5271. /// </summary>
  5272. /// <param name="sender"></param>
  5273. /// <param name="e"></param>
  5274. private void Grid_MouseDown(object sender, MouseButtonEventArgs e)
  5275. {
  5276. HideAngleBorder();
  5277. }
  5278. /// <summary>
  5279. /// 鼠标左键点击事件
  5280. /// </summary>
  5281. /// <param name="sender"></param>
  5282. /// <param name="e"></param>
  5283. private void Window_MouseLeftButtonDown_1(object sender, MouseButtonEventArgs e)
  5284. {
  5285. if (RectImgBorder.Visibility != Visibility.Hidden)
  5286. {
  5287. HideAngleBorder();
  5288. }
  5289. }
  5290. #endregion
  5291. #region 方法
  5292. /// <summary>
  5293. /// 录屏 录制 截图 导入文档 增加 主页面显示
  5294. /// </summary>
  5295. private void Record()
  5296. {
  5297. GridMain.Visibility = Visibility.Visible;
  5298. gridSetUp.Visibility = Visibility.Collapsed;
  5299. //gridUpload.Visibility = Visibility.Collapsed;
  5300. GridMyVideo.Visibility = Visibility.Collapsed;
  5301. if (APP.pageData.pagenum > 0)
  5302. {
  5303. gridPage.Visibility = Visibility.Visible;
  5304. }
  5305. DataContext = APP.pageData;
  5306. }
  5307. /// <summary>
  5308. /// 设置页面显示
  5309. /// </summary>
  5310. private void SetUp()
  5311. {
  5312. }
  5313. #endregion
  5314. #region 跳转
  5315. /// <summary>
  5316. /// 跳转
  5317. /// </summary>
  5318. /// <param name="sender"></param>
  5319. /// <param name="e"></param>
  5320. private void CbxPageList_SelectionChanged(object sender, SelectionChangedEventArgs e)
  5321. {
  5322. #region 安全
  5323. if(CbxPageList.SelectedValue==null)
  5324. {
  5325. return;
  5326. }
  5327. if (APP.pageData.currpage == int.Parse(CbxPageList.SelectedValue.ToString()))
  5328. {
  5329. return;
  5330. }
  5331. #endregion
  5332. int JumpPage = 0;
  5333. try
  5334. {
  5335. JumpPage = int.Parse(CbxPageList.SelectedValue.ToString());
  5336. }
  5337. catch (Exception)
  5338. {
  5339. MessageWindow.Show("操作有误!请输入有效的页码!");
  5340. return;
  5341. }
  5342. if (JumpPage < 1)
  5343. {
  5344. JumpPage = 1;
  5345. }
  5346. if (JumpPage > int.Parse(txbTotalpage.Text))
  5347. {
  5348. JumpPage = int.Parse(txbTotalpage.Text);
  5349. }
  5350. #region 跳转
  5351. APP.pageData.currpage = JumpPage;
  5352. JumpPageClick();
  5353. #endregion
  5354. }
  5355. #endregion
  5356. #region 原跳转
  5357. /// <summary>
  5358. /// 跳转页
  5359. /// </summary>
  5360. /// <param name="sender"></param>
  5361. /// <param name="e"></param>
  5362. private void txbCurrpage_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
  5363. {
  5364. if (e.ClickCount == 2)
  5365. {
  5366. try
  5367. {
  5368. if (int.Parse(txbCurrpage.Text) > 0)
  5369. {
  5370. //txtJump.Text = txbCurrpage.Text;
  5371. //txbCurrpage.Visibility = Visibility.Hidden;
  5372. //txtJump.Visibility = Visibility.Visible;
  5373. //BtnJumpPage.Visibility = Visibility.Visible;
  5374. //txtJump.Focus();
  5375. //txtJump.SelectAll();
  5376. }
  5377. }
  5378. catch (Exception)
  5379. {
  5380. }
  5381. }
  5382. }
  5383. /// <summary>
  5384. /// 确定跳转
  5385. /// </summary>
  5386. /// <param name="sender"></param>
  5387. /// <param name="e"></param>
  5388. private void BtnJumpPage_Click(object sender, RoutedEventArgs e)
  5389. {
  5390. int JumpPage = 0;
  5391. //try
  5392. //{
  5393. // JumpPage = int.Parse(txtJump.Text);
  5394. //}
  5395. //catch (Exception ex)
  5396. //{
  5397. // MessageWindow.Show("操作有误!请输入有效的页码!");
  5398. // return;
  5399. //}
  5400. if (JumpPage < 1)
  5401. {
  5402. JumpPage = 1;
  5403. }
  5404. if (JumpPage > int.Parse(txbTotalpage.Text))
  5405. {
  5406. JumpPage = int.Parse(txbTotalpage.Text);
  5407. }
  5408. #region 跳转
  5409. APP.pageData.currpage = JumpPage;
  5410. JumpPageClick();
  5411. #endregion
  5412. //txbCurrpage.Visibility = Visibility.Visible;
  5413. //txtJump.Visibility = Visibility.Hidden;
  5414. //BtnJumpPage.Visibility = Visibility.Hidden;
  5415. }
  5416. /// <summary>
  5417. /// 只允许输入数字
  5418. /// </summary>
  5419. /// <param name="sender"></param>
  5420. /// <param name="e"></param>
  5421. private void txtJump_PreviewTextInput(object sender, TextCompositionEventArgs e)
  5422. {
  5423. Regex re = new Regex("[^0-9.-]+");
  5424. e.Handled = re.IsMatch(e.Text);
  5425. }
  5426. private void txtJump_KeyDown(object sender, System.Windows.Input.KeyEventArgs e)
  5427. {
  5428. if (e.Key == Key.Enter)
  5429. {
  5430. BtnJumpPage_Click(null, null);
  5431. }
  5432. }
  5433. #endregion
  5434. }
  5435. public class PageData
  5436. {
  5437. public int PageCode { get; set; }
  5438. public string PageName { get; set; }
  5439. }
  5440. public enum ReportRate
  5441. {
  5442. R_200,
  5443. R_160,
  5444. R_120,
  5445. R_80,
  5446. R_40
  5447. }
  5448. public class RobotPoint
  5449. {
  5450. public int bIndex { get; set; }
  5451. public int bPenStatus { get; set; }
  5452. public float bx { get; set; }
  5453. public float by { get; set; }
  5454. public float bPress { get; set; }
  5455. public float bWidth { get; set; }
  5456. public float bSpeed { get; set; }
  5457. public bool isOptimize { get; set; }
  5458. }
  5459. }