星火微课系统客户端
Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

XHMicroLessonSystemWindow.xaml.cs 214KB

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