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

vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215
  1. using Aspose.Words;
  2. using Aspose.Words.Saving;
  3. using Common.system;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Drawing.Imaging;
  7. using System.IO;
  8. using System.Threading;
  9. using System.Windows;
  10. using System.Windows.Forms;
  11. using System.Windows.Ink;
  12. using System.Windows.Input;
  13. using System.Windows.Media;
  14. using System.Windows.Media.Imaging;
  15. using XHWK.Model;
  16. using System.Windows.Controls;
  17. using ComeCapture;
  18. using Aspose.Slides;
  19. using static Common.system.PdfTrunImage;
  20. using TStudyDigitalPen.HID;
  21. using System.Drawing;
  22. using XHWK.WKTool.DAL;
  23. using System.Text;
  24. using System.Collections.Specialized;
  25. using XHWK.WKTool.Config;
  26. using System.Windows.Threading;
  27. using System.Diagnostics;
  28. namespace XHWK.WKTool
  29. {
  30. /// <summary>
  31. /// 主页面
  32. /// </summary>
  33. public partial class XHMicroLessonSystemWindow : Window
  34. {
  35. #region 字段
  36. /// <summary>
  37. /// 文件目录窗口
  38. /// </summary>
  39. //private CountdownWindow FileDirectoryWindows = null;
  40. private FolderBrowserDialog Ofd;
  41. private DialogResult Result;
  42. public readonly BlackboardNew myblackboard;
  43. private System.Windows.Forms.DialogResult result;
  44. private System.Windows.Forms.OpenFileDialog ofd;
  45. //声明一个 DrawingAttributes 类型的变量
  46. DrawingAttributes drawingAttributes;
  47. Model_Video VideoInfo = null;
  48. //定义事件
  49. public event ChangeTextHandler ChangeTextEvent;
  50. //定义委托
  51. public delegate void ChangeTextHandler(string text);
  52. /// <summary>
  53. /// 图片
  54. /// </summary>
  55. string[] ImgPDFPath = new string[300];
  56. /// <summary>
  57. /// 当前颜色
  58. /// </summary>
  59. private System.Windows.Media.Color Color = System.Windows.Media.Colors.Red;
  60. /// <summary>
  61. /// 笔迹粗细
  62. /// </summary>
  63. private int PenSize = 2;
  64. private DispatcherTimer t = null;
  65. /// <summary>
  66. /// 计时器状态
  67. /// </summary>
  68. private enum State
  69. {
  70. Start,
  71. Pause,
  72. End
  73. }
  74. /// <summary>
  75. /// 状态
  76. /// </summary>
  77. private State _state = State.End;
  78. /// <summary>
  79. /// 计时用
  80. /// </summary>
  81. private TimeSpan _timeSpan = new TimeSpan(0, 0, 0, 0, 0);
  82. #region 上传
  83. /// <summary>
  84. /// 视频模型
  85. /// </summary>
  86. List<Model_Video> model_VideoList = null;
  87. /// <summary>
  88. /// 数据列表
  89. /// </summary>
  90. internal FileDirectoryData pageData = new FileDirectoryData();
  91. /// <summary>
  92. /// 下标
  93. /// </summary>
  94. private int Subscript = 0;
  95. /// <summary>
  96. /// 是否是修改状态
  97. /// </summary>
  98. private bool IsModify = false;
  99. #endregion
  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. InitializeComponent();
  109. this.ResizeMode = System.Windows.ResizeMode.CanMinimize;
  110. btnPrint.IsEnabled = false;
  111. myblackboard = new BlackboardNew(blackboard_canvas);
  112. APP.pageData.pagenum = 0;
  113. APP.pageData.currpage = 0;
  114. DataContext = APP.pageData;
  115. //APP.SaveDraw();//画板模型第一页初始化
  116. APP.PageDrawList = new List<Model_DrawData>();
  117. Model_DrawData model_DrawData = new Model_DrawData();
  118. model_DrawData.PageNum = APP.pageData.currpage;
  119. APP.PageDrawList.Add(model_DrawData);
  120. txbv.Text = "v"+ZConfig.versionName;
  121. txbStoragePath.Content = FileToolsCommon.GetConfigValue("VideoType");
  122. if (FileToolsCommon.GetConfigValue("IsSound").Equals("true"))
  123. {
  124. rbnY.IsChecked = true;
  125. }
  126. else
  127. {
  128. rbnN.IsChecked = true;
  129. }
  130. txbStoragePath.Content = FileToolsCommon.GetConfigValue("VideoSavePath");
  131. Initialize();
  132. InitPen();
  133. }
  134. /// <summary>
  135. /// 初始化
  136. /// </summary>
  137. public void Initialize()
  138. {
  139. #region 数据初始化
  140. APP.pageData.pagenum = 0;
  141. APP.pageData.currpage = APP.pageData.pagenum;
  142. btnStop.IsEnabled = false;//停止录制按钮不可点击
  143. #endregion
  144. APP.CameraPosition = FileToolsCommon.GetConfigValue("CameraPosition");
  145. //创建 DrawingAttributes 类的一个实例
  146. drawingAttributes = new DrawingAttributes();
  147. //将 InkCanvas 的 DefaultDrawingAttributes 属性的值赋成创建的 DrawingAttributes 类的对象的引用
  148. //InkCanvas 通过 DefaultDrawingAttributes 属性来获取墨迹的各种设置,该属性的类型为 DrawingAttributes 型
  149. blackboard_canvas.DefaultDrawingAttributes = drawingAttributes;
  150. blackboard_canvas.UseCustomCursor = true;
  151. drawingAttributes.FitToCurve = true;
  152. drawingAttributes.IgnorePressure = false;
  153. drawingAttributes.Width = PenSize;
  154. drawingAttributes.Height = PenSize;
  155. drawingAttributes.Color = Color;
  156. blackboard_canvas.Cursor = System.Windows.Input.Cursors.Pen;
  157. //wfhCamera.Visibility = Visibility.Hidden;
  158. ImgPDFPath = null;
  159. ImgPDFPath = new string[300];
  160. }
  161. /// <summary>
  162. /// 开始
  163. /// </summary>
  164. /// <param name="sender"></param>
  165. /// <param name="e"></param>
  166. private void Stack()
  167. {
  168. _state = State.Start;
  169. }
  170. /// <summary>
  171. /// 暂停
  172. /// </summary>
  173. private void TimeOut()
  174. {
  175. _state = State.Pause;
  176. }
  177. /// <summary>
  178. /// 结束
  179. /// </summary>
  180. /// <param name="sender"></param>
  181. /// <param name="e"></param>
  182. private void End()
  183. {
  184. _state = State.End;
  185. }
  186. /// <summary>
  187. /// 时钟回调
  188. /// </summary>
  189. /// <param name="sender"></param>
  190. /// <param name="e"></param>
  191. private void OnTimer(object sender, EventArgs e)
  192. {
  193. switch (_state)
  194. {
  195. case State.Start:
  196. {
  197. _timeSpan += new TimeSpan(0, 0, 0, 1);
  198. }
  199. break;
  200. case State.Pause:
  201. {
  202. }
  203. break;
  204. case State.End:
  205. {
  206. _timeSpan = new TimeSpan();
  207. //_timeSpan = new TimeSpan(0, 23, 12, 45, 54);
  208. }
  209. break;
  210. }
  211. string time = string.Format("{0:D2}:{1:D2}",/* _timeSpan.Hours,*/ _timeSpan.Minutes, _timeSpan.Seconds);
  212. txbTime.Text = time;
  213. //txbTime.Text = time;
  214. }
  215. /// <summary>
  216. /// 修改布局
  217. /// </summary>
  218. public void SetUpLayout()
  219. {
  220. //宽高比1276,1040
  221. //double AspectRatio = 1276.0 / 1040.0;
  222. ////System.Drawing.Size des = PrimaryScreen.DESKTOP;
  223. //System.Drawing.Size workingArea = PrimaryScreen.WorkingArea;
  224. //this.Height = workingArea.Height;
  225. }
  226. #endregion
  227. #region 事件
  228. /// <summary>
  229. /// 窗体移动
  230. /// </summary>
  231. /// <param name="sender"></param>
  232. /// <param name="e"></param>
  233. private void Window_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
  234. {
  235. DragMove();
  236. }
  237. #region 摄像头
  238. System.Timers.Timer times;
  239. List<string> RbnOpen;
  240. bool IsRbnOpen = false;
  241. /// <summary>
  242. /// 摄像头打开事件
  243. /// </summary>
  244. /// <param name="sender"></param>
  245. /// <param name="e"></param>
  246. private void RbnOpen_Click(object sender, RoutedEventArgs e)
  247. {
  248. //UCCamera win = new UCCamera();
  249. ////win.Topmost = true;
  250. //win.ShowDialog();
  251. //wfhCamera.Visibility = Visibility.Visible;
  252. //CameraHelper.IsDisplay = true;
  253. //CameraHelper.SourcePlayer = player;
  254. CameraHelper.UpdateCameraDevices();
  255. if (CameraHelper.CameraDevices.Count > 0)
  256. {
  257. CameraHelper.SetCameraDevice(0);
  258. RbnOpen = new List<string>();
  259. times = new System.Timers.Timer(300);//设置执行一次(false)还是一直执行(true)
  260. times.AutoReset = true;//设置是否执行System.Timers.Timer.Elapsed事件
  261. times.Elapsed += new System.Timers.ElapsedEventHandler(Times_Elapsed);
  262. times.Enabled = true; //启动计时器
  263. IsRbnOpen = true;
  264. string imgPath = FileToolsCommon.GetFileAbsolutePath("Temp/imgplayer");
  265. FileToolsCommon.CreateDirectory(imgPath);
  266. }
  267. }
  268. int I = 9999;
  269. private void Times_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
  270. {
  271. if (IsRbnOpen)
  272. {
  273. try
  274. {
  275. Dispatcher.Invoke(() =>
  276. {
  277. if (I > 10010)
  278. {
  279. long time = Timestamp();
  280. string imgPath = FileToolsCommon.GetFileAbsolutePath("Temp/imgplayer");
  281. //string FilePathName = ImgPath + RsImgName.Count + ".png";
  282. string path = CameraHelper.CaptureImage(imgPath, time.ToString());
  283. if (!string.IsNullOrWhiteSpace(path))
  284. {
  285. RbnOpen.Add(path);
  286. imgPlayerRight.Visibility = Visibility.Visible;
  287. /// < !--摄像头位置 1.右上 2.左上 3.右下 4.左下-- >
  288. if ("1".Equals(APP.CameraPosition))
  289. {
  290. imgPlayerRight.Visibility = Visibility.Visible;
  291. imgPlayerLeft.Visibility = Visibility.Collapsed;
  292. imgPlayerRightUnder.Visibility = Visibility.Collapsed;
  293. imgPlayerLeftUnder.Visibility = Visibility.Collapsed;
  294. imgPlayerRight.Source = new BitmapImage(new Uri(path));
  295. }
  296. else if ("2".Equals(APP.CameraPosition))
  297. {
  298. imgPlayerRight.Visibility = Visibility.Collapsed;
  299. imgPlayerLeft.Visibility = Visibility.Visible;
  300. imgPlayerRightUnder.Visibility = Visibility.Collapsed;
  301. imgPlayerLeftUnder.Visibility = Visibility.Collapsed;
  302. imgPlayerLeft.Source = new BitmapImage(new Uri(path));
  303. }
  304. else if ("3".Equals(APP.CameraPosition))
  305. {
  306. imgPlayerRight.Visibility = Visibility.Collapsed;
  307. imgPlayerLeft.Visibility = Visibility.Collapsed;
  308. imgPlayerRightUnder.Visibility = Visibility.Visible;
  309. imgPlayerLeftUnder.Visibility = Visibility.Collapsed;
  310. imgPlayerRightUnder.Source = new BitmapImage(new Uri(path));
  311. }
  312. else if ("4".Equals(APP.CameraPosition))
  313. {
  314. imgPlayerRight.Visibility = Visibility.Collapsed;
  315. imgPlayerLeft.Visibility = Visibility.Collapsed;
  316. imgPlayerRightUnder.Visibility = Visibility.Collapsed;
  317. imgPlayerLeftUnder.Visibility = Visibility.Visible;
  318. imgPlayerLeftUnder.Source = new BitmapImage(new Uri(path));
  319. }
  320. else
  321. {
  322. imgPlayerLeft.Visibility = Visibility.Collapsed;
  323. imgPlayerRightUnder.Visibility = Visibility.Collapsed;
  324. imgPlayerLeftUnder.Visibility = Visibility.Collapsed;
  325. imgPlayerRight.Source = new BitmapImage(new Uri(path));
  326. }
  327. }
  328. }
  329. I++;
  330. });
  331. }
  332. catch (Exception ex)
  333. {
  334. LogHelper.WriteErrLog("【摄像】(Times_Elapsed)生成图片错误:" + ex.Message, ex);
  335. }
  336. }
  337. }
  338. /// <summary>
  339. /// 摄像头关闭事件
  340. /// </summary>
  341. /// <param name="sender"></param>
  342. /// <param name="e"></param>
  343. private void RbnTurnOff_Click(object sender, RoutedEventArgs e)
  344. {
  345. IsRbnOpen = false;
  346. imgPlayerRight.Visibility = Visibility.Collapsed;
  347. imgPlayerLeft.Visibility = Visibility.Collapsed;
  348. imgPlayerRightUnder.Visibility = Visibility.Collapsed;
  349. imgPlayerLeftUnder.Visibility = Visibility.Collapsed;
  350. CameraHelper.CloseDevice();
  351. I = 9999;
  352. }
  353. #endregion
  354. #endregion
  355. /// <summary>
  356. /// 录屏事件
  357. /// </summary>
  358. /// <param name="sender"></param>
  359. /// <param name="e"></param>
  360. private void BtnScreenRecording_Click(object sender, RoutedEventArgs e)
  361. {
  362. if (!APP.CheckScreenCapturerRecorder())
  363. {
  364. MessageWindow.Show("使用此功能需安装环境,请在确定后依次点击“OK-Next>-Next>Install”完成安装!");
  365. APP.InstallScreenCapturerRecorder();
  366. return;
  367. }
  368. #region 限制只允许录制一个录屏 废弃
  369. //string RecordScreenPathName = APP.WKData.WkPath + APP.WKData.WkName + "_录屏." + ((Enum_VideoType)int.Parse(FileToolsCommon.GetConfigValue("VideoType"))).ToString();
  370. //if (FileToolsCommon.IsExistFile(RecordScreenPathName))
  371. //{
  372. // MessageBoxResult dr = MessageWindow.Show("已存在录屏,是否覆盖?", "提示", MessageBoxButton.OKCancel);
  373. // if (dr == MessageBoxResult.OK)
  374. // {
  375. // try
  376. // {
  377. // FileToolsCommon.DeleteFile(RecordScreenPathName);
  378. // APP.VideoList.RemoveAll(x => x.VideoPath == RecordScreenPathName);
  379. // }
  380. // catch (Exception ex)
  381. // {
  382. // LogHelper.WriteErrLog("【录屏】(BtnRecordingScreen_Click)无法移除视频," + ex.Message, ex);
  383. // }
  384. // }
  385. // else
  386. // {
  387. // return;
  388. // }
  389. //}
  390. #endregion
  391. if (APP.W_ScreenRecordingToolbarWindow == null)
  392. {
  393. APP.W_ScreenRecordingToolbarWindow = new ScreenRecordingToolbarWindow
  394. {
  395. Topmost = true
  396. };
  397. APP.W_ScreenRecordingToolbarWindow.Initialize();
  398. }
  399. else
  400. {
  401. APP.W_ScreenRecordingToolbarWindow.Initialize();
  402. }
  403. APP.W_ScreenRecordingToolbarWindow.Click_stopRecordingScreen += W_ScreenRecordingToolbarWindow_Click_stopRecordingScreen;
  404. //显示在右下角
  405. APP.W_ScreenRecordingToolbarWindow.WindowStartupLocation = WindowStartupLocation.Manual;
  406. APP.W_ScreenRecordingToolbarWindow.Left = PrimaryScreen.DESKTOP.Width - APP.W_ScreenRecordingToolbarWindow.Width - 60;
  407. APP.W_ScreenRecordingToolbarWindow.Top = PrimaryScreen.DESKTOP.Height - APP.W_ScreenRecordingToolbarWindow.Height - 30;
  408. APP.W_ScreenRecordingToolbarWindow.Topmost = true;
  409. APP.W_ScreenRecordingToolbarWindow.Show();
  410. Hide();
  411. }
  412. /// <summary>
  413. /// 保存录屏中
  414. /// </summary>
  415. private void W_ScreenRecordingToolbarWindow_Click_stopRecordingScreen()
  416. {
  417. TxbRecordScreenWord.Text = "保存中";//
  418. btnScreenRecording.IsEnabled = false;
  419. new Thread(new ThreadStart(new Action(() =>
  420. {
  421. while (FileToolsCommon.IsExistDirectory(APP.WKData.WkPath + "temprs/"))
  422. {
  423. Thread.Sleep(100);
  424. }
  425. Dispatcher.Invoke(() =>
  426. {
  427. btnScreenRecording.IsEnabled = true;
  428. TxbRecordScreenWord.Text = "录屏";
  429. });
  430. }))).Start();
  431. }
  432. /// <summary>
  433. /// 上传事件
  434. /// </summary>
  435. /// <param name="sender"></param>
  436. /// <param name="e"></param>
  437. private void BtnUpload_Click(object sender, RoutedEventArgs e)
  438. {
  439. if (APP.IsLoginType == false)
  440. {
  441. Login();
  442. return;
  443. }
  444. if(gridUpload.Visibility == Visibility.Visible)
  445. {
  446. gridUpload.Visibility = Visibility.Collapsed;
  447. GridMain.Visibility = Visibility.Visible;
  448. ImgRecord.Visibility = Visibility.Visible;//上传结束时可录制
  449. ImgRecordTwo.Visibility = Visibility.Collapsed;//上传结束时可录制
  450. BtnRecord.IsEnabled = true;//设置结束时可录制
  451. if (APP.pageData.pagenum>0)
  452. {
  453. gridPage.Visibility = Visibility.Visible;
  454. }
  455. DataContext = APP.pageData;
  456. }
  457. else
  458. {
  459. gridPage.Visibility = Visibility.Collapsed;
  460. gridUpload.Visibility = Visibility.Visible;
  461. GridMain.Visibility = Visibility.Collapsed;
  462. ImgRecord.Visibility = Visibility.Collapsed;//上传时不可录制
  463. ImgRecordTwo.Visibility = Visibility.Visible;//上传时不可录制
  464. BtnRecord.IsEnabled = false;//上传时不可录制
  465. InitializeUpload();
  466. }
  467. }
  468. /// <summary>
  469. /// 关闭事件
  470. /// </summary>
  471. /// <param name="sender"></param>
  472. /// <param name="e"></param>
  473. private void BtnDown_Click(object sender, RoutedEventArgs e)
  474. {
  475. if (IsFirstR)
  476. {
  477. APP.Killffmpeg();
  478. APP.SaveWkData();
  479. APP.SaveDraw();
  480. Thread.Sleep(100);
  481. System.Environment.Exit(0);
  482. }
  483. else
  484. {
  485. MessageWindow.Show("当前正在录制,请先停止录制。");
  486. return;
  487. //MessageBoxResult dr = MessageWindow.Show("当前正在录制,是否停止录制?", "提示", MessageBoxButton.OKCancel);
  488. //if (dr == MessageBoxResult.OK)
  489. //{
  490. // APP.SaveWkData();
  491. // APP.SaveDraw();
  492. // BtnStop_Click(null, null);
  493. // while (!IsFirstR)
  494. // {
  495. // Thread.Sleep(100);
  496. // }
  497. // System.Environment.Exit(0);
  498. //}
  499. //else
  500. //{
  501. // return;
  502. //}
  503. }
  504. }
  505. /// <summary>
  506. /// 设置 保存事件
  507. /// </summary>
  508. /// <param name="sender"></param>
  509. /// <param name="e"></param>
  510. private void BtnSave_Click(object sender, RoutedEventArgs e)
  511. {
  512. #region 合法性判断
  513. //if (string.IsNullOrWhiteSpace(txbStoragePath.Text.Trim()))
  514. //{
  515. // MessageWindow.Show("路径不可为空!");
  516. // return;
  517. //}
  518. //string temp = FileToolsCommon.GetLegalPath(txbStoragePath.Text) + APP.WKData.WkName.Trim() + "/";
  519. //if (!APP.WKData.WkPath.Equals(temp))
  520. //{
  521. // APP.WKData.WkPath = FileToolsCommon.GetLegalPath(txbStoragePath.Text) + APP.WKData.WkName.Trim() + "/";
  522. // if (FileToolsCommon.IsExistDirectory(APP.WKData.WkPath))
  523. // {
  524. // //微课已存在
  525. // MessageBoxResult dr = MessageWindow.Show("讲解已存在是否覆盖?", "提示", MessageBoxButton.OKCancel);
  526. // if (dr == MessageBoxResult.OK)
  527. // {
  528. // FileToolsCommon.DeleteDirectory(APP.WKData.WkPath);
  529. // }
  530. // else
  531. // {
  532. // return;
  533. // }
  534. // }
  535. // //创建文件夹
  536. // FileToolsCommon.CreateDirectory(APP.WKData.WkPath);
  537. //}
  538. #endregion
  539. ImgRecord.Visibility = Visibility.Visible;//设置结束时可录制
  540. ImgRecordTwo.Visibility = Visibility.Collapsed;//设置结束时可录制
  541. BtnRecord.IsEnabled = true;//设置结束时可录制
  542. if (rbnMP4.IsChecked == true)
  543. {
  544. //存储文件
  545. FileToolsCommon.SetConfigValue("VideoType", "1");
  546. }
  547. else if (rbnFLV.IsChecked == true)
  548. {
  549. FileToolsCommon.SetConfigValue("VideoType", "2");
  550. }
  551. else
  552. {
  553. FileToolsCommon.SetConfigValue("VideoType", "3");
  554. }
  555. if (rbnY.IsChecked == true)
  556. {
  557. FileToolsCommon.SetConfigValue("IsSound", "true");
  558. }
  559. else
  560. {
  561. FileToolsCommon.SetConfigValue("IsSound", "false");
  562. }
  563. /// < !--摄像头位置 1.右上 2.左上 3.右下 4.左下-- >
  564. if (rbnRight.IsChecked == true)
  565. {
  566. FileToolsCommon.SetConfigValue("CameraPosition", "1");
  567. }
  568. else if (rbnLeft.IsChecked == true)
  569. {
  570. FileToolsCommon.SetConfigValue("CameraPosition", "2");
  571. }
  572. else if (rbnRightUnder.IsChecked == true)
  573. {
  574. FileToolsCommon.SetConfigValue("CameraPosition", "3");
  575. }
  576. else if (rbnLeftUnder.IsChecked == true)
  577. {
  578. FileToolsCommon.SetConfigValue("CameraPosition", "4");
  579. }
  580. if (rbnMP4.IsChecked == true)
  581. {
  582. FileToolsCommon.SetConfigValue("VideoType", "1");
  583. }
  584. else if (rbnFLV.IsChecked == true)
  585. {
  586. FileToolsCommon.SetConfigValue("VideoType", "2");
  587. }
  588. else if (rbnAVI.IsChecked == true)
  589. {
  590. FileToolsCommon.SetConfigValue("VideoType", "3");
  591. }
  592. APP.CameraPosition = FileToolsCommon.GetConfigValue("CameraPosition");
  593. GridMain.Visibility = Visibility.Visible;
  594. gridSetUp.Visibility = Visibility.Collapsed;
  595. imgPlayerRight.Visibility = Visibility.Collapsed;
  596. imgPlayerLeft.Visibility = Visibility.Collapsed;
  597. imgPlayerRightUnder.Visibility = Visibility.Collapsed;
  598. imgPlayerLeftUnder.Visibility = Visibility.Collapsed;
  599. if(!txbStoragePath.Content.ToString().Equals(APP.WKData.WkPath))
  600. {
  601. //存储文件
  602. FileToolsCommon.SetConfigValue("VideoSavePath", txbStoragePath.Content.ToString());
  603. System.Windows.MessageBox.Show("路径已变更,下次创建微课时自动生效!!!");
  604. }
  605. }
  606. /// <summary>
  607. /// 设置事件
  608. /// </summary>
  609. /// <param name="sender"></param>
  610. /// <param name="e"></param>
  611. private void BtnSetUp_Click(object sender, RoutedEventArgs e)
  612. {
  613. if (!TxbRecordingWord.Text.Equals("暂停"))
  614. {
  615. GridMain.Visibility = Visibility.Collapsed;
  616. gridSetUp.Visibility = Visibility.Visible;
  617. txbStoragePath.Content = APP.WKData.WkPath;
  618. ImgRecord.Visibility = Visibility.Collapsed;//设置时不可录制
  619. ImgRecordTwo.Visibility = Visibility.Visible;//设置时不可录制
  620. BtnRecord.IsEnabled = false;//设置时不可录制
  621. /// < !--摄像头位置 1.右上 2.左上 3.右下 4.左下-- >
  622. if ("1".Equals(APP.CameraPosition))
  623. {
  624. rbnRight.IsChecked = true;
  625. }
  626. else if ("2".Equals(APP.CameraPosition))
  627. {
  628. rbnLeft.IsChecked = true;
  629. }
  630. else if ("3".Equals(APP.CameraPosition))
  631. {
  632. rbnRightUnder.IsChecked = true;
  633. }
  634. else if ("4".Equals(APP.CameraPosition))
  635. {
  636. rbnLeftUnder.IsChecked = true;
  637. }
  638. string type= FileToolsCommon.GetConfigValue("VideoType");//<!--视频格式 1、MP4 2、FlV 3、AVI-->
  639. if ("1".Equals(type))
  640. {
  641. rbnMP4.IsChecked = true;
  642. }
  643. else if ("2".Equals(type))
  644. {
  645. rbnFLV.IsChecked = true;
  646. }
  647. else if ("3".Equals(type))
  648. {
  649. rbnAVI.IsChecked = true;
  650. }
  651. string isSound = FileToolsCommon.GetConfigValue("IsSound");//<!--声音 true 有 false 无-->
  652. if(isSound=="true")
  653. {
  654. rbnY.IsChecked = true;
  655. }
  656. else
  657. {
  658. rbnN.IsChecked = true;
  659. }
  660. }
  661. }
  662. /// <summary>
  663. /// 设置 浏览事件
  664. /// </summary>
  665. /// <param name="sender"></param>
  666. /// <param name="e"></param>
  667. private void BtnBrowse_Click(object sender, RoutedEventArgs e)
  668. {
  669. //System.Diagnostics.Process.Start(APP.WKData.WkPath);
  670. string desktopPath = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
  671. Ofd = new System.Windows.Forms.FolderBrowserDialog();
  672. Result = Ofd.ShowDialog();
  673. if (Result == System.Windows.Forms.DialogResult.OK)
  674. {
  675. if (Ofd.SelectedPath != "")
  676. {
  677. txbStoragePath.Content = Ofd.SelectedPath;
  678. //string ApplicationData = ZConfig.dataPath + "fileStorageAddress.txt";
  679. //string temp = ofd.SelectedPath;
  680. //System.IO.File.WriteAllText(ApplicationData, temp, Encoding.Default);
  681. }
  682. }
  683. }
  684. /// <summary>
  685. /// 画笔颜色事件 白色
  686. /// </summary>
  687. /// <param name="sender"></param>
  688. /// <param name="e"></param>
  689. private void BtnWhite_Click(object sender, RoutedEventArgs e)
  690. {
  691. ////创建 DrawingAttributes 类的一个实例
  692. //drawingAttributes = new DrawingAttributes();
  693. ////将 InkCanvas 的 DefaultDrawingAttributes 属性的值赋成创建的 DrawingAttributes 类的对象的引用
  694. ////InkCanvas 通过 DefaultDrawingAttributes 属性来获取墨迹的各种设置,该属性的类型为 DrawingAttributes 型
  695. //blackboard_canvas.DefaultDrawingAttributes = drawingAttributes;
  696. ////设置 DrawingAttributes 的 Color 属性设置颜色
  697. drawingAttributes.Color = Colors.White;
  698. Color = Colors.White;
  699. }
  700. /// <summary>
  701. /// 画笔颜色事件 红色
  702. /// </summary>
  703. /// <param name="sender"></param>
  704. /// <param name="e"></param>
  705. private void BtnRed_Click(object sender, RoutedEventArgs e)
  706. {
  707. //设置 DrawingAttributes 的 Color 属性设置颜色
  708. drawingAttributes.Color = Colors.Red;
  709. Color = Colors.Red;
  710. imgRed.Visibility = Visibility.Visible;
  711. imgGray.Visibility = Visibility.Collapsed;
  712. imgCyanBlue.Visibility = Visibility.Collapsed;
  713. imgYellow.Visibility = Visibility.Collapsed;
  714. imgBlue.Visibility = Visibility.Collapsed;
  715. }
  716. /// <summary>
  717. /// 画笔颜色事件 黑色
  718. /// </summary>
  719. /// <param name="sender"></param>
  720. /// <param name="e"></param>
  721. private void BtnGray_Click(object sender, RoutedEventArgs e)
  722. {
  723. drawingAttributes.Color = Colors.Black;
  724. Color = Colors.Black;
  725. imgRed.Visibility = Visibility.Collapsed;
  726. imgGray.Visibility = Visibility.Visible;
  727. imgCyanBlue.Visibility = Visibility.Collapsed;
  728. imgYellow.Visibility = Visibility.Collapsed;
  729. imgBlue.Visibility = Visibility.Collapsed;
  730. }
  731. /// <summary>
  732. /// 画笔颜色事件 青色
  733. /// </summary>
  734. /// <param name="sender"></param>
  735. /// <param name="e"></param>
  736. private void BtnCyanBlue_Click(object sender, RoutedEventArgs e)
  737. {
  738. drawingAttributes.Color = Colors.LimeGreen;
  739. Color = Colors.LimeGreen;
  740. imgRed.Visibility = Visibility.Collapsed;
  741. imgGray.Visibility = Visibility.Collapsed;
  742. imgCyanBlue.Visibility = Visibility.Visible;
  743. imgYellow.Visibility = Visibility.Collapsed;
  744. imgBlue.Visibility = Visibility.Collapsed;
  745. }
  746. /// <summary>
  747. /// 画笔颜色事件 黄色
  748. /// </summary>
  749. /// <param name="sender"></param>
  750. /// <param name="e"></param>
  751. private void BtnYellow_Click(object sender, RoutedEventArgs e)
  752. {
  753. drawingAttributes.Color = Colors.Gold;
  754. Color = Colors.Gold;
  755. imgRed.Visibility = Visibility.Collapsed;
  756. imgGray.Visibility = Visibility.Collapsed;
  757. imgCyanBlue.Visibility = Visibility.Collapsed;
  758. imgYellow.Visibility = Visibility.Visible;
  759. imgBlue.Visibility = Visibility.Collapsed;
  760. }
  761. /// <summary>
  762. /// 画笔颜色事件 蓝色
  763. /// </summary>
  764. /// <param name="sender"></param>
  765. /// <param name="e"></param>
  766. private void BtnBlue_Click(object sender, RoutedEventArgs e)
  767. {
  768. drawingAttributes.Color = Colors.DeepSkyBlue;
  769. Color = Colors.DeepSkyBlue;
  770. imgRed.Visibility = Visibility.Collapsed;
  771. imgGray.Visibility = Visibility.Collapsed;
  772. imgCyanBlue.Visibility = Visibility.Collapsed;
  773. imgYellow.Visibility = Visibility.Collapsed;
  774. imgBlue.Visibility = Visibility.Visible;
  775. }
  776. /// <summary>
  777. /// 画笔粗细事件 细
  778. /// </summary>
  779. /// <param name="sender"></param>
  780. /// <param name="e"></param>
  781. private void RbnFine_Click(object sender, RoutedEventArgs e)
  782. {
  783. drawingAttributes.Width = 1;
  784. drawingAttributes.Height = 1;
  785. PenSize = 1;
  786. }
  787. /// <summary>
  788. /// 画笔粗细事件 中
  789. /// </summary>
  790. /// <param name="sender"></param>
  791. /// <param name="e"></param>
  792. private void RbnIn_Click(object sender, RoutedEventArgs e)
  793. {
  794. drawingAttributes.Width = 3;
  795. drawingAttributes.Height = 3;
  796. PenSize = 3;
  797. }
  798. /// <summary>
  799. /// 画笔粗细事件 粗
  800. /// </summary>
  801. /// <param name="sender"></param>
  802. /// <param name="e"></param>
  803. private void RbnCrude_Click(object sender, RoutedEventArgs e)
  804. {
  805. drawingAttributes.Width = 5;
  806. drawingAttributes.Height = 5;
  807. PenSize = 5;
  808. }
  809. /// <summary>
  810. /// 登陆事件
  811. /// </summary>
  812. /// <param name="sender"></param>
  813. /// <param name="e"></param>
  814. private void BtnLoginType_Click(object sender, RoutedEventArgs e)
  815. {
  816. Login();
  817. }
  818. /// <summary>
  819. /// 登陆
  820. /// </summary>
  821. private void Login()
  822. {
  823. if (APP.W_LoginWindow == null)
  824. {
  825. APP.W_LoginWindow = new LoginWindow();
  826. APP.W_LoginWindow.WindowStartupLocation = WindowStartupLocation.CenterOwner;
  827. APP.W_LoginWindow.Owner = this;
  828. }
  829. else
  830. {
  831. APP.W_LoginWindow.Initialize();
  832. }
  833. APP.W_LoginWindow.ShowDialog();
  834. if (APP.IsLoginType)
  835. {
  836. txbLoginType.Text = APP.UserInfo.Username;
  837. ImgUpload.Visibility = Visibility.Visible;
  838. ImgUploadTwo.Visibility = Visibility.Collapsed;
  839. }
  840. else
  841. {
  842. txbLoginType.Text = "未登录";
  843. ImgUpload.Visibility = Visibility.Collapsed;
  844. ImgUploadTwo.Visibility = Visibility.Visible;
  845. }
  846. }
  847. /// <summary>
  848. /// 截图事件
  849. /// </summary>
  850. /// <param name="sender"></param>
  851. /// <param name="e"></param>
  852. private void BtnScreenshot_Click(object sender, RoutedEventArgs e)
  853. {
  854. APP.ImgPath = string.Empty;
  855. string time = GetTimeStamp();
  856. string desktopPath = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory) + time + ".jpg";
  857. APP.ImgPath = desktopPath;
  858. ImageHelper.GetScreenshot(new System.Drawing.Rectangle(0, 0, 0, 0), desktopPath,false,out BitmapImage bitmap);
  859. if (this.WindowState == WindowState.Normal)//截图隐藏窗口
  860. {
  861. this.WindowState = WindowState.Minimized;
  862. }
  863. if (APP.W_JieTuWindow != null)
  864. {
  865. APP.W_JieTuWindow.initialization();
  866. APP.W_JieTuWindow.Screenshot();
  867. APP.W_JieTuWindow.WindowState = WindowState.Maximized;
  868. APP.W_JieTuWindow.Visibility = Visibility.Visible;
  869. }
  870. else
  871. {
  872. APP.W_JieTuWindow = new JieTuWindow();
  873. // 订阅事件
  874. APP.W_JieTuWindow.ChangeTextEvent += new ChangeTextHandler(frm_ChangeTextEvent);
  875. APP.W_JieTuWindow.click_closeJietuWindowClick += JietuWindow_click_closeJietuWindowClick;
  876. APP.W_JieTuWindow.Show();
  877. }
  878. //imgCanvas.Source = new BitmapImage(new Uri(desktopPath));
  879. }
  880. /// <summary>
  881. /// 截图关闭窗口
  882. /// </summary>
  883. /// <param name="text"></param>
  884. private void frm_ChangeTextEvent(string text)
  885. {
  886. if ("关闭窗口".Equals(text))
  887. {
  888. if (this.WindowState == WindowState.Minimized)//截图完恢复窗口
  889. {
  890. this.Topmost = true;
  891. this.WindowState = WindowState.Normal;
  892. }
  893. if (!string.IsNullOrWhiteSpace(APP.ImgPath) && File.Exists(APP.ImgPath))
  894. {
  895. if (APP.pageData.currpage == 0)
  896. {
  897. APP.pageData.pagenum += 1;
  898. APP.pageData.currpage = APP.pageData.pagenum;
  899. gridPage.Visibility = Visibility.Visible;//页码大于0 显示
  900. }
  901. if (APP.PageDrawList.Count >= APP.pageData.currpage)
  902. {
  903. APP.PageDrawList[APP.pageData.currpage - 1].PageImagePath = APP.ImgPath;//zxycs
  904. APP.PageDrawList[APP.pageData.currpage - 1].PdfImagePath = APP.ImgPath;
  905. }
  906. else
  907. {
  908. Model_DrawData model_DrawData = new Model_DrawData();
  909. model_DrawData.PageImagePath = APP.ImgPath;
  910. model_DrawData.PdfImagePath = APP.ImgPath;
  911. APP.PageDrawList.Add(model_DrawData);
  912. }
  913. if (APP.PageDrawList.Count >= APP.pageData.currpage && !string.IsNullOrWhiteSpace(APP.PageDrawList[APP.pageData.currpage - 1].PageImagePath))
  914. {
  915. imgDocumentation.Source = null;
  916. imgCanvas.Source = new BitmapImage(new Uri(APP.PageDrawList[APP.pageData.currpage - 1].PageImagePath));
  917. APP.PageDrawList[APP.pageData.currpage - 1].ImgDocumentation = false;
  918. ImgPrint.Visibility = Visibility.Visible;//截图成功可打印
  919. ImgPrintTwo.Visibility = Visibility.Collapsed;
  920. btnPrint.IsEnabled = true;
  921. }
  922. }
  923. this.Topmost = false;
  924. }
  925. }
  926. /// <summary>
  927. /// 截图关闭 非正常关闭截图时,截图清空
  928. /// </summary>
  929. private void JietuWindow_click_closeJietuWindowClick()
  930. {
  931. if (this.WindowState == WindowState.Minimized)//截图完恢复窗口
  932. {
  933. this.WindowState = WindowState.Normal;
  934. }
  935. APP.W_JieTuWindow = null;
  936. }
  937. /// <summary>
  938. /// 获取时间戳
  939. /// </summary>
  940. /// <returns></returns>
  941. public string GetTimeStamp()
  942. {
  943. TimeSpan ts = DateTime.Now - new DateTime(1970, 1, 1, 0, 0, 0, 0);
  944. return Convert.ToInt64(ts.TotalSeconds).ToString();
  945. }
  946. /// <summary>
  947. /// 导入事件
  948. /// </summary>
  949. /// <param name="sender"></param>
  950. /// <param name="e"></param>
  951. private void BtnImport_Click(object sender, RoutedEventArgs e)
  952. {
  953. try
  954. {
  955. string desktopPath = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
  956. ofd = new System.Windows.Forms.OpenFileDialog
  957. {
  958. Filter = "文档|*.docx;*.doc;*ppt",
  959. InitialDirectory = desktopPath,
  960. Multiselect = false,
  961. AddExtension = true,
  962. DereferenceLinks = true
  963. };
  964. new Thread(
  965. o =>
  966. {
  967. Thread.Sleep(400);
  968. Dispatcher.Invoke(new Action(() =>
  969. {
  970. OpenDialog();
  971. }
  972. ));
  973. })
  974. {
  975. IsBackground = true
  976. }.Start();
  977. }
  978. catch (Exception ex)
  979. {
  980. LogHelper.WriteErrLog("【导入(BtnImport_Click)" + ex.Message, ex);
  981. }
  982. }
  983. /// <summary>
  984. /// 导入文档
  985. /// </summary>
  986. private void OpenDialog()
  987. {
  988. result = ofd.ShowDialog();
  989. if (result == System.Windows.Forms.DialogResult.OK)
  990. {
  991. if (ofd.FileName != "")
  992. {
  993. APP.myloading.Show();
  994. #region PPT转PDF
  995. string filepath = ofd.FileName;
  996. string path = ofd.SafeFileName.Replace(".ppt", "").Trim();
  997. string type = ofd.SafeFileName.Replace(".ppt", "typezsygppt").Trim();
  998. if (type.Contains("typezsygppt"))//ppt
  999. {
  1000. try
  1001. {
  1002. string pathTemp = AppDomain.CurrentDomain.BaseDirectory + "Temp\\";
  1003. path = pathTemp + path + ".pdf";
  1004. //PPT转PDF
  1005. Presentation ppt = new Presentation(filepath);
  1006. ppt.Save(path, Aspose.Slides.Export.SaveFormat.Pdf);
  1007. #endregion
  1008. #region PDF转图片
  1009. // 图片绝对路径集合
  1010. List<string> images = new List<string>();
  1011. string directoryPath = pathTemp;
  1012. //aspose许可证
  1013. //Aspose.Pdf.License l = new Aspose.Pdf.License();
  1014. //string licenseName = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Aspose.Total.Product.Family.lic");
  1015. //l.SetLicense(licenseName);
  1016. //定义Jpeg转换设备
  1017. Aspose.Pdf.Document document = new Aspose.Pdf.Document(path);
  1018. var device = new Aspose.Pdf.Devices.JpegDevice();
  1019. //int quality = int.Parse(this.comboBox1.SelectedItem.ToString());
  1020. //directoryPath += quality;
  1021. Directory.CreateDirectory(directoryPath);
  1022. //默认质量为100,设置质量的好坏与处理速度不成正比,甚至是设置的质量越低反而花的时间越长,怀疑处理过程是先生成高质量的再压缩
  1023. device = new Aspose.Pdf.Devices.JpegDevice(100);
  1024. //遍历每一页转为jpg
  1025. for (var i = 1; i <= document.Pages.Count; i++)
  1026. {
  1027. long ii = Timestamp();
  1028. string filePathOutPut = Path.Combine(directoryPath, string.Format("{0}{1}.jpg", ii, i));
  1029. images.Add(filePathOutPut);
  1030. FileStream fs = new FileStream(filePathOutPut, FileMode.OpenOrCreate);
  1031. try
  1032. {
  1033. device.Process(document.Pages[i], fs);
  1034. fs.Close();
  1035. }
  1036. catch (Exception ex)
  1037. {
  1038. fs.Close();
  1039. File.Delete(filePathOutPut);
  1040. }
  1041. }
  1042. #endregion
  1043. string[] page = images.ToArray();
  1044. int num = 0;
  1045. for (int i = 0 + APP.pageData.pagenum; i < page.Length + APP.pageData.pagenum; i++)//给画板模型加图片路径
  1046. {
  1047. if (APP.PageDrawList != null && APP.PageDrawList.Count > i)
  1048. {
  1049. APP.PageDrawList[i].PageImagePath = page[i - APP.pageData.pagenum]; //zxycs
  1050. APP.PageDrawList[i].PdfImagePath = page[i - APP.pageData.pagenum];
  1051. APP.PageDrawList[i].PageNum = i + 1;
  1052. APP.PageDrawList[i].ImgDocumentation = true;
  1053. }
  1054. else
  1055. {
  1056. Model_DrawData model_DrawData = new Model_DrawData();
  1057. model_DrawData.PageImagePath = page[i - APP.pageData.pagenum];
  1058. model_DrawData.PdfImagePath = page[i - APP.pageData.pagenum];
  1059. model_DrawData.PageNum = i + 1;
  1060. model_DrawData.ImgDocumentation = true;
  1061. APP.PageDrawList.Add(model_DrawData);
  1062. }
  1063. ImgPrint.Visibility = Visibility.Visible;//导入成功可打印
  1064. ImgPrintTwo.Visibility = Visibility.Collapsed;
  1065. btnPrint.IsEnabled = true;
  1066. APP.SaveDraw();
  1067. num++;
  1068. }
  1069. if (num > 0)
  1070. {
  1071. APP.pageData.currpage = APP.pageData.pagenum + 1;
  1072. APP.pageData.pagenum += num;
  1073. gridPage.Visibility = Visibility.Visible;//页码大于0 显示
  1074. }
  1075. if (APP.pageData.currpage > 0 && APP.pageData.currpage < APP.PageDrawList.Count)
  1076. {
  1077. imgCanvas.Source = null;
  1078. ImgScreenshot.Visibility = Visibility.Collapsed;//当前页为导入时不可截图
  1079. ImgScreenshotTwo.Visibility = Visibility.Visible;
  1080. btnScreenshot.IsEnabled = false;
  1081. imgDocumentation.Source = new BitmapImage(new Uri(APP.PageDrawList[APP.pageData.currpage - 1].PageImagePath));//给当前页面展示图片
  1082. }
  1083. else
  1084. {
  1085. imgDocumentation.Source = null;
  1086. imgCanvas.Source = null;
  1087. ///截图可用
  1088. ImgScreenshot.Visibility = Visibility.Visible;
  1089. ImgScreenshotTwo.Visibility = Visibility.Collapsed;
  1090. btnScreenshot.IsEnabled = true;
  1091. }
  1092. APP.myloading.Hide();
  1093. }
  1094. catch (Exception ex)
  1095. {
  1096. APP.myloading.Hide();
  1097. LogHelper.WriteErrLog("【XHMicroLessonSystemWindow】(OpenDialog PPT)" + ex.Message, ex);
  1098. }
  1099. }
  1100. else//word
  1101. {
  1102. try
  1103. {
  1104. string paths = AppDomain.CurrentDomain.BaseDirectory + "Temp\\";
  1105. string[] page = ConvertWordToImage(filepath, paths, "", 0, 0, null, 0).ToArray();
  1106. int num = 0;
  1107. for (int i = 0 + APP.pageData.pagenum; i < page.Length + APP.pageData.pagenum; i++)//给画板模型加图片路径
  1108. {
  1109. if (APP.PageDrawList != null && APP.PageDrawList.Count > i)
  1110. {
  1111. APP.PageDrawList[i].PageImagePath = page[i - APP.pageData.pagenum]; //zxycs
  1112. APP.PageDrawList[i].PdfImagePath = page[i - APP.pageData.pagenum];
  1113. APP.PageDrawList[i].PageNum = i + 1;
  1114. APP.PageDrawList[i].ImgDocumentation = true;
  1115. }
  1116. else
  1117. {
  1118. Model_DrawData model_DrawData = new Model_DrawData();
  1119. model_DrawData.PageImagePath = page[i - APP.pageData.pagenum];
  1120. model_DrawData.PdfImagePath = page[i - APP.pageData.pagenum];
  1121. model_DrawData.PageNum = i + 1;
  1122. model_DrawData.ImgDocumentation = true;
  1123. APP.PageDrawList.Add(model_DrawData);
  1124. }
  1125. ImgPrint.Visibility = Visibility.Visible;//导入成功可打印
  1126. ImgPrintTwo.Visibility = Visibility.Collapsed;
  1127. btnPrint.IsEnabled = true;
  1128. APP.SaveDraw();
  1129. num++;
  1130. }
  1131. if (num > 0)
  1132. {
  1133. APP.pageData.currpage = APP.pageData.pagenum + 1;
  1134. APP.pageData.pagenum += num;
  1135. gridPage.Visibility = Visibility.Visible;//页码大于0 显示
  1136. }
  1137. if (APP.pageData.currpage > 0 && APP.pageData.currpage < APP.PageDrawList.Count)
  1138. {
  1139. imgCanvas.Source = null;
  1140. ImgScreenshot.Visibility = Visibility.Collapsed;//当前页为导入时不可截图
  1141. ImgScreenshotTwo.Visibility = Visibility.Visible;
  1142. btnScreenshot.IsEnabled = false;
  1143. imgDocumentation.Visibility = Visibility.Visible;
  1144. imgDocumentation.Source = new BitmapImage(new Uri(APP.PageDrawList[APP.pageData.currpage - 1].PageImagePath));//给当前页面展示图片
  1145. }
  1146. else
  1147. {
  1148. imgDocumentation.Source = null;
  1149. imgCanvas.Source = null;
  1150. ///截图可用
  1151. ImgScreenshot.Visibility = Visibility.Visible;
  1152. ImgScreenshotTwo.Visibility = Visibility.Collapsed;
  1153. btnScreenshot.IsEnabled = true;
  1154. }
  1155. APP.myloading.Hide();
  1156. }
  1157. catch (Exception ex)
  1158. {
  1159. APP.myloading.Hide();
  1160. LogHelper.WriteErrLog("【XHMicroLessonSystemWindow】(OpenDialog 导入文档)" + ex.Message, ex);
  1161. }
  1162. }
  1163. }
  1164. }
  1165. }
  1166. /// <summary>
  1167. /// 返回一个时间戳到毫秒
  1168. /// </summary>
  1169. /// <returns></returns>
  1170. public static long Timestamp()
  1171. {
  1172. TimeSpan ts = DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0);
  1173. long timestr = Convert.ToInt64(ts.TotalMilliseconds);
  1174. return timestr;
  1175. }
  1176. #region 录制窗口
  1177. #region 变量
  1178. /// <summary>
  1179. /// 视频保存路径
  1180. /// </summary>
  1181. //string RecordingPath;
  1182. /// <summary>
  1183. /// 图片保存路径
  1184. /// </summary>
  1185. string ImgPath;
  1186. /// <summary>
  1187. /// 音频保存路径名
  1188. /// </summary>
  1189. string AudioPathName;
  1190. /// <summary>
  1191. /// 视频保存路径名
  1192. /// </summary>
  1193. string VideoSavePathName;
  1194. /// <summary>
  1195. /// 暂停录制
  1196. /// </summary>
  1197. bool IsSuspendR = true;
  1198. /// <summary>
  1199. /// 录制是否已停止
  1200. /// </summary>
  1201. bool IsFirstR = true;
  1202. /// <summary>
  1203. /// 图片
  1204. /// </summary>
  1205. List<string> RsImgName = null;
  1206. /// <summary>
  1207. /// 是否开始截图计数
  1208. /// </summary>
  1209. bool IsStartCount = false;
  1210. #endregion
  1211. /// <summary>
  1212. /// 录制窗口内容
  1213. /// </summary>
  1214. /// <param name="sender"></param>
  1215. /// <param name="e"></param>
  1216. private void BtnRecord_Click(object sender, RoutedEventArgs e)
  1217. {
  1218. if (!APP.CheckScreenCapturerRecorder())
  1219. {
  1220. MessageWindow.Show("使用此功能需安装环境,请在确定后依次点击“OK-Next>-Next>Install”完成安装!");
  1221. APP.InstallScreenCapturerRecorder();
  1222. return;
  1223. }
  1224. if (APP.pageData.currpage > 0)
  1225. {
  1226. blackboard_canvas.Visibility = Visibility.Visible;
  1227. }
  1228. else
  1229. {
  1230. MessageWindow.Show("请先导入文档或截图!");
  1231. return;
  1232. }
  1233. //btnStop.IsEnabled = true;//停止录制按钮可点击
  1234. StartRecord();
  1235. }
  1236. /// <summary>
  1237. /// 停止录制窗口内容
  1238. /// </summary>
  1239. /// <param name="sender"></param>
  1240. /// <param name="e"></param>
  1241. private void BtnStop_Click(object sender, RoutedEventArgs e)
  1242. {
  1243. blackboard_canvas.Visibility = Visibility.Collapsed;
  1244. EndRecord();
  1245. }
  1246. System.Timers.Timer timer;
  1247. /// <summary>
  1248. /// 设置录屏文件地址
  1249. /// </summary>
  1250. void SetUpVideoPathName()
  1251. {
  1252. }
  1253. /// <summary>
  1254. /// 开始录制和暂停录制
  1255. /// </summary>
  1256. void StartRecord()
  1257. {
  1258. if (IsSuspendR)
  1259. {
  1260. if (IsFirstR)//是否第一次录制 初始化录制
  1261. {
  1262. #region 计时器初始化
  1263. if (t == null)
  1264. {
  1265. t = new DispatcherTimer();
  1266. t.Tick += OnTimer;
  1267. t.Interval = new TimeSpan(0, 0, 0, 1);
  1268. t.IsEnabled = true;
  1269. t.Start();
  1270. }
  1271. t.Interval = new TimeSpan(0, 0, 0, 1);
  1272. txbTime.Visibility = Visibility.Visible;
  1273. #endregion
  1274. VideoInfo = new Model_Video();
  1275. VideoInfo.VideoType = (Enum_VideoType)int.Parse(FileToolsCommon.GetConfigValue("VideoType"));
  1276. VideoInfo.WkType = Enum_WKVidetype.RecordingLessons;
  1277. ImgPath = APP.WKData.WkPath + "temp/Image/";
  1278. AudioPathName = APP.WKData.WkPath + "temp/audio/";
  1279. FileToolsCommon.DeleteDirectory(APP.WKData.WkPath + "temp/");
  1280. FileToolsCommon.CreateDirectory(APP.WKData.WkPath);
  1281. FileToolsCommon.CreateDirectory(ImgPath);
  1282. FileToolsCommon.CreateDirectory(AudioPathName);
  1283. AudioPathName += APP.WKData.WkName + ".MP3";
  1284. VideoSavePathName = APP.WKData.WkPath + APP.WKData.WkName + "_录制." + VideoInfo.VideoType.ToString();
  1285. int num = 1;
  1286. while (FileToolsCommon.IsExistFile(VideoSavePathName))
  1287. {
  1288. VideoSavePathName = APP.WKData.WkPath + APP.WKData.WkName + "_录制_" + num + "." + VideoInfo.VideoType.ToString();
  1289. num++;
  1290. }
  1291. #region 设置录屏唯一 废弃
  1292. //if (FileToolsCommon.IsExistFile(VideoSavePathName))
  1293. //{
  1294. // MessageBoxResult dr = MessageWindow.Show("课程已录制,是否覆盖?", "提示", MessageBoxButton.OKCancel);
  1295. // if (dr == MessageBoxResult.OK)
  1296. // {
  1297. // try
  1298. // {
  1299. // FileToolsCommon.DeleteFile(VideoSavePathName);
  1300. // APP.VideoList.RemoveAll(x => x.VideoPath == VideoSavePathName);
  1301. // }
  1302. // catch (Exception ex)
  1303. // {
  1304. // LogHelper.WriteErrLog("【录制】(StartRecord)无法移除视频," + ex.Message, ex);
  1305. // }
  1306. // }
  1307. // else
  1308. // {
  1309. // return;
  1310. // }
  1311. //}
  1312. #endregion
  1313. #region 禁用按钮
  1314. ImgPrint.Visibility = Visibility.Collapsed;//录制中不可打印
  1315. ImgPrintTwo.Visibility = Visibility.Visible;
  1316. btnPrint.IsEnabled = false;
  1317. ImgScreenshot.Visibility = Visibility.Collapsed;//录制中不可截图
  1318. ImgScreenshotTwo.Visibility = Visibility.Visible;
  1319. btnScreenshot.IsEnabled = false;
  1320. ImgImport.Visibility = Visibility.Collapsed;//录制中不可导入文档
  1321. ImgImportTwo.Visibility = Visibility.Visible;
  1322. btnImport.IsEnabled = false;
  1323. ImgScreenRecording.Visibility = Visibility.Collapsed;//录制中不可录屏
  1324. ImgScreenRecordingTwo.Visibility = Visibility.Visible;
  1325. btnScreenRecording.IsEnabled = false;
  1326. ImgUpload.Visibility = Visibility.Collapsed;//录制中不可上传
  1327. ImgUploadTwo.Visibility = Visibility.Visible;
  1328. btnUpload.IsEnabled = false;
  1329. ImgSetUp.Visibility = Visibility.Collapsed;//录制中不可设置
  1330. ImgSetUpTwo.Visibility = Visibility.Visible;
  1331. btnSetUp.IsEnabled = false;
  1332. btnLoginType.IsEnabled = false;
  1333. #endregion
  1334. #region 录像倒计时
  1335. if (APP.W_CountdownWindow == null)
  1336. {
  1337. APP.W_CountdownWindow = new CountdownWindow();
  1338. APP.W_CountdownWindow.Initialize();
  1339. //APP.W_CountdownWindow.Topmost = true;
  1340. }
  1341. else
  1342. {
  1343. APP.W_CountdownWindow.Initialize();
  1344. //APP.W_CountdownWindow.Topmost = true;
  1345. }
  1346. APP.W_CountdownWindow.Show();
  1347. #endregion
  1348. IsFirstR = false;
  1349. RsImgName = new List<string>();
  1350. timer = new System.Timers.Timer(200);//设置执行一次(false)还是一直执行(true)
  1351. timer.AutoReset = true;//设置是否执行System.Timers.Timer.Elapsed事件
  1352. timer.Elapsed += new System.Timers.ElapsedEventHandler(Timer_Elapsed);
  1353. timer.Enabled = true; //启动计时器
  1354. }
  1355. //继续录制
  1356. IsSuspendR = false;
  1357. //BtnRecording.Content = "暂停录制";
  1358. ImgRecord.Source = new BitmapImage(new Uri("pack://application:,,,/Images/microLessonSystem_23.png"));
  1359. ImgStop.Visibility = Visibility.Collapsed;
  1360. ImgStopTwo.Visibility = Visibility.Visible;
  1361. TxbRecordingWord.Text = "暂停";
  1362. #region 2秒内不可点击
  1363. new Thread(new ThreadStart(new Action(() =>
  1364. {
  1365. Dispatcher.Invoke(() =>
  1366. {
  1367. BtnRecord.IsEnabled = false;
  1368. btnStop.IsEnabled = false;
  1369. });
  1370. Thread.Sleep(2000);
  1371. Dispatcher.Invoke(() =>
  1372. {
  1373. BtnRecord.IsEnabled = true;
  1374. btnStop.IsEnabled = true;
  1375. });
  1376. }))).Start();
  1377. #endregion
  1378. try
  1379. {
  1380. new Thread(new ThreadStart(new Action(() =>
  1381. {
  1382. Thread.Sleep(1000);
  1383. APP.FFmpeg.StartRecordingAudio(AudioPathName);
  1384. Thread.Sleep(1000);
  1385. Dispatcher.Invoke(() =>
  1386. {
  1387. IsStartCount = true;
  1388. Stack();
  1389. //timer.Start();
  1390. });
  1391. }))).Start();
  1392. }
  1393. catch (Exception ex)
  1394. {
  1395. MessageWindow.Show(ex.Message);
  1396. }
  1397. }
  1398. else
  1399. {
  1400. //暂停
  1401. IsSuspendR = true;
  1402. ImgRecord.Source = new BitmapImage(new Uri("pack://application:,,,/Images/microLessonSystem_14.png"));
  1403. ImgStop.Visibility = Visibility.Visible;
  1404. ImgStopTwo.Visibility = Visibility.Collapsed;
  1405. TxbRecordingWord.Text = "继续";
  1406. TimeOut();
  1407. #region 2秒内不可点击
  1408. new Thread(new ThreadStart(new Action(() =>
  1409. {
  1410. Dispatcher.Invoke(() =>
  1411. {
  1412. BtnRecord.IsEnabled = false;
  1413. btnStop.IsEnabled = false;
  1414. });
  1415. Thread.Sleep(2000);
  1416. Dispatcher.Invoke(() =>
  1417. {
  1418. BtnRecord.IsEnabled = true;
  1419. btnStop.IsEnabled = true;
  1420. });
  1421. }))).Start();
  1422. #endregion
  1423. try
  1424. {
  1425. APP.FFmpeg.SuspendFFmpeg();
  1426. new Thread(new ThreadStart(new Action(() =>
  1427. {
  1428. while (APP.FFmpeg.myProcess != null)
  1429. {
  1430. Thread.Sleep(100);
  1431. }
  1432. IsStartCount = false;
  1433. }))).Start();
  1434. }
  1435. catch (Exception ex)
  1436. {
  1437. MessageWindow.Show(ex.Message);
  1438. }
  1439. }
  1440. }
  1441. /// <summary>
  1442. /// 录制保存图片
  1443. /// </summary>
  1444. /// <param name="sender"></param>
  1445. /// <param name="e"></param>
  1446. private void Timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
  1447. {
  1448. if (IsStartCount)
  1449. {
  1450. try
  1451. {
  1452. Dispatcher.Invoke(() =>
  1453. {
  1454. string FilePathName = ImgPath + RsImgName.Count + ".png";
  1455. ImageHelper.SaveUIToImage(GridMain, FilePathName, (int)this.ActualWidth, (int)this.ActualHeight);
  1456. RsImgName.Add(FilePathName);
  1457. });
  1458. }
  1459. catch (Exception ex)
  1460. {
  1461. LogHelper.WriteErrLog("【录制】(Timer_Elapsed)生成图片错误:" + ex.Message, ex);
  1462. }
  1463. }
  1464. }
  1465. /// <summary>
  1466. /// 停止录制并生成录制文件
  1467. /// </summary>
  1468. void EndRecord()
  1469. {
  1470. if (!IsFirstR)
  1471. {
  1472. #region 恢复被禁用的按钮
  1473. ImgPrint.Visibility = Visibility.Visible;
  1474. ImgPrintTwo.Visibility = Visibility.Collapsed;
  1475. btnPrint.IsEnabled = true;
  1476. ImgScreenshot.Visibility = Visibility.Visible;
  1477. ImgScreenshotTwo.Visibility = Visibility.Collapsed;
  1478. btnScreenshot.IsEnabled = true;
  1479. ImgImport.Visibility = Visibility.Visible;
  1480. ImgImportTwo.Visibility = Visibility.Collapsed;
  1481. btnImport.IsEnabled = true;
  1482. ImgScreenRecording.Visibility = Visibility.Visible;
  1483. ImgScreenRecordingTwo.Visibility = Visibility.Collapsed;
  1484. btnScreenRecording.IsEnabled = true;
  1485. ImgUpload.Visibility = Visibility.Visible;
  1486. ImgUploadTwo.Visibility = Visibility.Collapsed;
  1487. btnUpload.IsEnabled = true;
  1488. ImgSetUp.Visibility = Visibility.Visible;
  1489. ImgSetUpTwo.Visibility = Visibility.Collapsed;
  1490. btnSetUp.IsEnabled = true;
  1491. btnLoginType.IsEnabled = true;
  1492. //btnStop.IsEnabled = false;//停止录制按钮不可点击
  1493. #endregion
  1494. IsSuspendR = true;
  1495. ImgRecord.Source = new BitmapImage(new Uri("pack://application:,,,/Images/microLessonSystem_14.png"));
  1496. ImgStop.Visibility = Visibility.Visible;
  1497. ImgStopTwo.Visibility = Visibility.Collapsed;
  1498. TimeOut();
  1499. txbType.Text = "保存中";
  1500. #region 2秒内不可点击
  1501. new Thread(new ThreadStart(new Action(() =>
  1502. {
  1503. Dispatcher.Invoke(() =>
  1504. {
  1505. BtnRecord.IsEnabled = false;
  1506. btnStop.IsEnabled = false;
  1507. });
  1508. }))).Start();
  1509. #endregion
  1510. try
  1511. {
  1512. #region 清空画板数据
  1513. APP.pageData.currpage = 0;
  1514. APP.pageData.pagenum = 0;
  1515. myblackboard.clear();
  1516. APP.PageDrawList.Clear();
  1517. imgCanvas.Source = null;
  1518. imgDocumentation.Source = null;
  1519. gridPage.Visibility = Visibility.Collapsed;
  1520. #endregion
  1521. //缩略图
  1522. string ThumbnailPath = FileToolsCommon.GetDirectoryName(VideoSavePathName) + "ThumbnailPath/";
  1523. FileToolsCommon.CreateDirectory(ThumbnailPath);
  1524. //缩略图存储位置
  1525. string ThumbnailPathName = ThumbnailPath + FileToolsCommon.GetIOFileNameNoExtension(VideoSavePathName) + ".JPG";
  1526. int gridActWidth = (int)GridMain.ActualWidth;
  1527. int gridActHeight = (int)GridMain.ActualHeight;
  1528. APP.FFmpeg.StopFFmpeg(AudioPathName);
  1529. new Thread(new ThreadStart(new Action(() =>
  1530. {
  1531. //停止截图
  1532. while (APP.FFmpeg.myProcess != null)
  1533. {
  1534. Thread.Sleep(100);
  1535. }
  1536. Dispatcher.Invoke(() =>
  1537. {
  1538. IsStartCount = false;
  1539. timer.Stop();
  1540. });
  1541. //}))).Start();
  1542. //new Thread(new ThreadStart(new Action(() =>
  1543. //{
  1544. //判断音频是否存在 判断音频临时文件夹是否存在
  1545. if (!FileToolsCommon.IsExistFile(AudioPathName))
  1546. {
  1547. Thread.Sleep(100);
  1548. }
  1549. if (FileToolsCommon.IsExistDirectory(FileToolsCommon.GetDirectoryName(AudioPathName) + "temp/"))
  1550. {
  1551. Thread.Sleep(100);
  1552. }
  1553. APP.FFmpeg.SynthesisVideo(ImgPath, AudioPathName, VideoSavePathName, 5, gridActWidth, gridActHeight);
  1554. //}))).Start();
  1555. //new Thread(new ThreadStart(new Action(() =>
  1556. //{
  1557. while (!FileToolsCommon.IsExistFile(VideoSavePathName))
  1558. {
  1559. Thread.Sleep(100);
  1560. }
  1561. while (FileToolsCommon.IsExistDirectory(FileToolsCommon.GetDirectoryName(VideoSavePathName) + "temp/"))
  1562. {
  1563. Thread.Sleep(100);
  1564. }
  1565. Dispatcher.Invoke(() =>
  1566. {
  1567. BtnRecord.IsEnabled = true;
  1568. btnStop.IsEnabled = true;
  1569. TxbRecordingWord.Text = "录制";
  1570. End();
  1571. txbTime.Text = "";
  1572. txbTime.Visibility = Visibility.Hidden;
  1573. txbType.Text = "";
  1574. });
  1575. FileToolsCommon.DeleteFile(ThumbnailPathName);
  1576. VideoInfo.RSTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  1577. Thread.Sleep(500);
  1578. //VideoInfo.VideoSize = FileToolsCommon.GetFileSizeByMB(VideoSavePathName).ToString() + " MB";
  1579. VideoInfo.VideoPath = VideoSavePathName;
  1580. VideoInfo.ThumbnailPath = ThumbnailPathName;
  1581. APP.FFmpeg.GenerateThumbnails(VideoSavePathName, ThumbnailPathName);
  1582. VideoInfo.FileGuid = Guid.NewGuid().ToString();
  1583. VideoInfo.IsUpload = false;
  1584. VideoInfo.Uploaded = 0;
  1585. VideoInfo.Savefolder = APP.UserInfo.Schoolid + "/resource";
  1586. APP.VideoList.Add(VideoInfo);
  1587. //保存数据
  1588. APP.SaveWkData();
  1589. IsFirstR = true;
  1590. }))).Start();
  1591. //List<Model_Video> VideoList
  1592. }
  1593. catch (Exception ex)
  1594. {
  1595. MessageWindow.Show(ex.Message);
  1596. }
  1597. }
  1598. }
  1599. #endregion
  1600. /// <summary>
  1601. /// 增加事件
  1602. /// </summary>
  1603. /// <param name="sender"></param>
  1604. /// <param name="e"></param>
  1605. private void BtnAdd_Click(object sender, RoutedEventArgs e)
  1606. {
  1607. if (APP.pageData.currpage > 0)
  1608. {
  1609. APP.PageDrawList[APP.pageData.currpage - 1].IsImageLocation = true;
  1610. }
  1611. if (IsStartCount && blackboard_canvas.Visibility == Visibility.Collapsed)
  1612. {
  1613. blackboard_canvas.Visibility = Visibility.Visible;
  1614. }
  1615. APP.pageData.pagenum += 1;
  1616. gridPage.Visibility = Visibility.Visible;//页码大于0 显示
  1617. APP.pageData.currpage = APP.pageData.pagenum;
  1618. //myblackboard.changepage(APP.pageData.currpage - 1);
  1619. ///清空页面图片UI
  1620. imgCanvas.Source = null;
  1621. imgDocumentation.Source = null;
  1622. ///画板模型增加一页
  1623. Model_DrawData model_DrawData = new Model_DrawData();
  1624. model_DrawData.PageNum = APP.pageData.currpage;
  1625. APP.PageDrawList.Add(model_DrawData);
  1626. //APP.SaveDraw();
  1627. if (btnImport.IsEnabled == true)
  1628. {
  1629. ///截图可用
  1630. ImgScreenshot.Visibility = Visibility.Visible;
  1631. ImgScreenshotTwo.Visibility = Visibility.Collapsed;
  1632. btnScreenshot.IsEnabled = true;
  1633. }
  1634. }
  1635. /// <summary>
  1636. /// 打印事件
  1637. /// </summary>
  1638. /// <param name="sender"></param>
  1639. /// <param name="e"></param>
  1640. private void BtnPrint_Click(object sender, RoutedEventArgs e)
  1641. {
  1642. try
  1643. {
  1644. //3种情况 1.文档图片 2.截图图片 3.没有图片
  1645. iTextSharp.text.Document document = new iTextSharp.text.Document(iTextSharp.text.PageSize.A4, 25, 25, 25, 25);
  1646. //iTextSharp.text.Rectangle page = new iTextSharp.text.Rectangle(iTextSharp.text.PageSize.A4., 250f);//cs
  1647. ////设置纸张横向
  1648. //document.SetPageSize(iTextSharp.text.PageSize.A4.Rotate());
  1649. string imgPath = FileToolsCommon.GetFileAbsolutePath("temp");
  1650. FileToolsCommon.CreateFile(imgPath);
  1651. imgPath += "\\101.pdf";
  1652. iTextSharp.text.pdf.PdfWriter.GetInstance(document, new FileStream(imgPath, FileMode.Create, FileAccess.ReadWrite));
  1653. document.Open();
  1654. iTextSharp.text.Image image;
  1655. for (int i = 0; i < APP.PageDrawList.Count; i++)
  1656. {
  1657. long ii = Timestamp();
  1658. string directoryPath = AppDomain.CurrentDomain.BaseDirectory + "Temp\\";
  1659. string filePathOutPut = Path.Combine(directoryPath, string.Format("print{0}{1}.jpg", ii, i));
  1660. RectangleF rectangleFs = new RectangleF();
  1661. MergerImg("", filePathOutPut, rectangleFs, out string errmsg);
  1662. image = iTextSharp.text.Image.GetInstance(filePathOutPut);
  1663. if (String.IsNullOrEmpty(APP.PageDrawList[i].PageImagePath))//没有图片
  1664. {
  1665. }
  1666. else if (APP.PageDrawList[i].ImgDocumentation == true)
  1667. {
  1668. image = iTextSharp.text.Image.GetInstance(APP.PageDrawList[i].PageImagePath);
  1669. }
  1670. else
  1671. {
  1672. RectangleF rectangleF = new RectangleF();
  1673. rectangleF.Width = (float)APP.PageDrawList[i].ImageSizes.CenterX;
  1674. rectangleF.Height = (float)APP.PageDrawList[i].ImageSizes.CenterY;
  1675. rectangleF.X = (float)APP.PageDrawList[i].ImageLocation.X;
  1676. rectangleF.Y = (float)APP.PageDrawList[i].ImageLocation.Y;
  1677. string msg = string.Empty;
  1678. bool isImg = MergerImg(APP.PageDrawList[i].PageImagePath, filePathOutPut, rectangleF, out msg);
  1679. if (isImg)
  1680. {
  1681. image = iTextSharp.text.Image.GetInstance(filePathOutPut);
  1682. }
  1683. else
  1684. {
  1685. image = iTextSharp.text.Image.GetInstance(APP.PageDrawList[i].PageImagePath);
  1686. }
  1687. }
  1688. if (image.Height > iTextSharp.text.PageSize.A4.Height - 25)
  1689. {
  1690. image.ScaleToFit(iTextSharp.text.PageSize.A4.Width - 25, iTextSharp.text.PageSize.A4.Height - 25);
  1691. }
  1692. else if (image.Width > iTextSharp.text.PageSize.A4.Width - 25)
  1693. {
  1694. image.ScaleToFit(iTextSharp.text.PageSize.A4.Width - 25, iTextSharp.text.PageSize.A4.Height - 25);
  1695. }
  1696. image.Alignment = iTextSharp.text.Image.ALIGN_MIDDLE;
  1697. document.NewPage();
  1698. document.Add(image);
  1699. //iTextSharp.text.Chunk c1 = new iTextSharp.text.Chunk("Hello World");
  1700. //iTextSharp.text.Phrase p1 = new iTextSharp.text.Phrase();
  1701. //p1.Leading = 150; //行间距
  1702. //document.Add(p1);
  1703. }
  1704. Console.WriteLine("转换成功!");
  1705. document.Close();
  1706. }
  1707. catch (Exception ex)
  1708. {
  1709. Console.WriteLine("转换失败,原因:" + ex.Message);
  1710. }
  1711. //document.Close();
  1712. ////Console.ReadKey();
  1713. if (APP.W_PrintWindow == null)
  1714. {
  1715. APP.W_PrintWindow = new PrintWindow();
  1716. //APP.W_PrintWindow.Topmost = true;
  1717. APP.W_PrintWindow.Owner = this;
  1718. }
  1719. if (APP.PageDrawList.Count > 0 && !string.IsNullOrWhiteSpace(APP.PageDrawList[0].PageImagePath))
  1720. {
  1721. APP.W_PrintWindow.Initialize(APP.PageDrawList[0].PageImagePath);
  1722. }
  1723. else
  1724. {
  1725. APP.W_PrintWindow.Initialize("");
  1726. }
  1727. APP.W_PrintWindow.ShowDialog();
  1728. //int pr = 1;
  1729. //string msg = string.Empty;
  1730. //string outPut = string.Empty;
  1731. //LatticeFileHelper.GeneratingPDF(@"G:\101.pdf", @"G:\102.TPF",out pr, out msg, out outPut);
  1732. //if(pr==0)
  1733. //{
  1734. // outPut = outPut.Replace("[", "").Replace("]","").Replace("\"","").Trim();
  1735. // APP.OutPut = outPut.Split(',');
  1736. // string defa = string.Empty;
  1737. // List<string>defaList= LatticeFileHelper.GetPrinterList(out defa);
  1738. // int printResult = 1;
  1739. // string standardError = string.Empty;
  1740. // string standardOutput = string.Empty;
  1741. // LatticeFileHelper.PrinterTPFFile(@"G:\102.TPF",1, /*defa*/"导出为WPS PDF", out printResult,out standardError,out standardOutput);
  1742. //}
  1743. }
  1744. /// 上一页
  1745. /// </summary>
  1746. /// <param name="sender"></param>
  1747. /// <param name="e"></param>
  1748. private void last_button_Click(object sender, RoutedEventArgs e)
  1749. {
  1750. if (APP.pageData.currpage > 1)
  1751. {
  1752. APP.pageData.currpage -= 1;
  1753. myblackboard.changepage(APP.pageData.currpage - 1);
  1754. if (btnImport.IsEnabled == true)
  1755. {
  1756. ///截图可用
  1757. ImgScreenshot.Visibility = Visibility.Visible;
  1758. ImgScreenshotTwo.Visibility = Visibility.Collapsed;
  1759. btnScreenshot.IsEnabled = true;
  1760. }
  1761. if (APP.pageData.currpage <= APP.PageDrawList.Count)
  1762. {
  1763. if (APP.PageDrawList[APP.pageData.currpage - 1].ImageLocation != null)
  1764. {
  1765. APP.PageDrawList[APP.pageData.currpage - 1].IsImageLocation = true;
  1766. }
  1767. if (!string.IsNullOrWhiteSpace(txbCurrpage.Text) && APP.pageData.currpage <= APP.PageDrawList.Count && APP.pageData.currpage > 0 && !string.IsNullOrWhiteSpace(APP.PageDrawList[APP.pageData.currpage - 1].PageImagePath))
  1768. {
  1769. //imgCanvas.Source = new BitmapImage(new Uri(APP.Paths[APP.pageData.currpage - 1]));//cs
  1770. if (APP.PageDrawList[APP.pageData.currpage - 1].ImgDocumentation)
  1771. {
  1772. imgCanvas.Source = null;
  1773. imgDocumentation.Source = new BitmapImage(new Uri(APP.PageDrawList[APP.pageData.currpage - 1].PageImagePath));
  1774. ImgScreenshot.Visibility = Visibility.Collapsed;//当前页为导入时不可截图
  1775. ImgScreenshotTwo.Visibility = Visibility.Visible;
  1776. btnScreenshot.IsEnabled = false;
  1777. }
  1778. else
  1779. {
  1780. imgDocumentation.Source = null;
  1781. imgCanvas.Source = new BitmapImage(new Uri(APP.PageDrawList[APP.pageData.currpage - 1].PageImagePath));
  1782. APP.PageDrawList[APP.pageData.currpage - 1].IsImageLocation = false;
  1783. if (APP.PageDrawList[APP.pageData.currpage - 1].ImageLocation != null && APP.PageDrawList[APP.pageData.currpage - 1].ImageLocation.X > 0)
  1784. {
  1785. var group = IMG.FindResource("Imageview") as TransformGroup;
  1786. var transform = group.Children[1] as TranslateTransform;
  1787. #region 高低 缩放比例
  1788. if (APP.PageDrawList[APP.pageData.currpage - 1].ImageSize != null)
  1789. {
  1790. var transform1 = group.Children[0] as ScaleTransform;
  1791. transform1.ScaleX = APP.PageDrawList[APP.pageData.currpage - 1].ImageSize.ScaleX;
  1792. transform1.ScaleY = APP.PageDrawList[APP.pageData.currpage - 1].ImageSize.ScaleY;
  1793. imgCanvas.Width = APP.PageDrawList[APP.pageData.currpage - 1].ImageSizes.CenterX;
  1794. imgCanvas.Height = APP.PageDrawList[APP.pageData.currpage - 1].ImageSizes.CenterY;
  1795. }
  1796. #endregion
  1797. #region XY轴
  1798. transform.X = APP.PageDrawList[APP.pageData.currpage - 1].ImageLocation.X;
  1799. transform.Y = APP.PageDrawList[APP.pageData.currpage - 1].ImageLocation.Y;
  1800. #endregion
  1801. mouseDown = false;
  1802. }
  1803. }
  1804. }
  1805. else
  1806. {
  1807. imgCanvas.Source = null;
  1808. imgDocumentation.Source = null;
  1809. }
  1810. }
  1811. }
  1812. }
  1813. /// <summary>
  1814. /// 下一页
  1815. /// </summary>
  1816. /// <param name="sender"></param>
  1817. /// <param name="e"></param>
  1818. private void next_btn_Click(object sender, RoutedEventArgs e)
  1819. {
  1820. if (APP.pageData.currpage < APP.pageData.pagenum)
  1821. {
  1822. APP.pageData.currpage += 1;
  1823. myblackboard.changepage(APP.pageData.currpage - 1);
  1824. if (btnImport.IsEnabled == true)
  1825. {
  1826. ///截图可用
  1827. ImgScreenshot.Visibility = Visibility.Visible;
  1828. ImgScreenshotTwo.Visibility = Visibility.Collapsed;
  1829. btnScreenshot.IsEnabled = true;
  1830. }
  1831. if (APP.pageData.currpage <= APP.PageDrawList.Count)
  1832. {
  1833. if (APP.PageDrawList[APP.pageData.currpage - 1].ImageLocation != null)
  1834. {
  1835. APP.PageDrawList[APP.pageData.currpage - 1].IsImageLocation = true;
  1836. }
  1837. if (!string.IsNullOrWhiteSpace(txbCurrpage.Text) && APP.pageData.currpage <= APP.PageDrawList.Count && !string.IsNullOrWhiteSpace(APP.PageDrawList[APP.pageData.currpage - 1].PageImagePath))
  1838. {
  1839. if (APP.PageDrawList[APP.pageData.currpage - 1].ImgDocumentation)
  1840. {
  1841. imgCanvas.Source = null;
  1842. imgDocumentation.Source = new BitmapImage(new Uri(APP.PageDrawList[APP.pageData.currpage - 1].PageImagePath));
  1843. ImgScreenshot.Visibility = Visibility.Collapsed;//当前页为导入时不可截图
  1844. ImgScreenshotTwo.Visibility = Visibility.Visible;
  1845. btnScreenshot.IsEnabled = false;
  1846. }
  1847. else
  1848. {
  1849. imgDocumentation.Source = null;
  1850. imgCanvas.Source = new BitmapImage(new Uri(APP.PageDrawList[APP.pageData.currpage - 1].PageImagePath));
  1851. APP.PageDrawList[APP.pageData.currpage - 1].IsImageLocation = false;
  1852. if (APP.PageDrawList[APP.pageData.currpage - 1].ImageLocation != null && APP.PageDrawList[APP.pageData.currpage - 1].ImageLocation.X > 0)
  1853. {
  1854. var group = IMG.FindResource("Imageview") as TransformGroup;
  1855. #region 高低 缩放比例
  1856. if (APP.PageDrawList[APP.pageData.currpage - 1].ImageSize != null)
  1857. {
  1858. var transform1 = group.Children[0] as ScaleTransform;
  1859. transform1.ScaleX = APP.PageDrawList[APP.pageData.currpage - 1].ImageSize.ScaleX;
  1860. transform1.ScaleY = APP.PageDrawList[APP.pageData.currpage - 1].ImageSize.ScaleY;
  1861. imgCanvas.Width = APP.PageDrawList[APP.pageData.currpage - 1].ImageSizes.CenterX;
  1862. imgCanvas.Height = APP.PageDrawList[APP.pageData.currpage - 1].ImageSizes.CenterY;
  1863. }
  1864. #endregion
  1865. #region 坐标XY轴
  1866. var transform = group.Children[1] as TranslateTransform;
  1867. transform.X = APP.PageDrawList[APP.pageData.currpage - 1].ImageLocation.X;
  1868. transform.Y = APP.PageDrawList[APP.pageData.currpage - 1].ImageLocation.Y;
  1869. #endregion
  1870. mouseDown = false;
  1871. }
  1872. }
  1873. }
  1874. else
  1875. {
  1876. imgCanvas.Source = null;
  1877. imgDocumentation.Source = null;
  1878. }
  1879. }
  1880. }
  1881. }
  1882. /// <summary>
  1883. /// 生成图片
  1884. /// </summary>
  1885. /// <param name="_path">图片地址</param>
  1886. /// <param name="_saveimg">保存位置</param>
  1887. /// <param name="_rectangle">图片位置</param>
  1888. /// <param name="errmsg">错误消息</param>
  1889. /// <returns></returns>
  1890. private bool MergerImg(string _path, string _saveimg, RectangleF _rectangle, out string errmsg)
  1891. {
  1892. errmsg = null;
  1893. try
  1894. {
  1895. Bitmap bitmap = null;
  1896. //创建要显示的图片对象,根据参数的个数设置宽度
  1897. Bitmap backgroudImg = new Bitmap((int)gridM.ActualWidth, (int)gridM.ActualHeight);
  1898. Graphics g = Graphics.FromImage(backgroudImg);
  1899. //清除画布,背景设置为白色
  1900. g.Clear(System.Drawing.Color.White);
  1901. if (!string.IsNullOrWhiteSpace(_path))
  1902. {
  1903. bitmap = ImageHelper.ReadBitmapFile(_path);
  1904. g.DrawImage(bitmap, _rectangle);
  1905. }
  1906. backgroudImg.Save(_saveimg);
  1907. g.Dispose();
  1908. backgroudImg.Dispose();
  1909. if (bitmap != null)
  1910. {
  1911. bitmap.Dispose();
  1912. }
  1913. GC.Collect();
  1914. return true;
  1915. }
  1916. catch (Exception ex)
  1917. {
  1918. errmsg = ex.Message;
  1919. LogHelper.WriteErrLog("【截图合成】(MergerImg)图片合成失败:" + ex.Message, ex);
  1920. return false;
  1921. }
  1922. }
  1923. /// <summary>
  1924. /// 将Word文档转换为图片的方法(该方法基于第三方DLL),你可以像这样调用该方法: ConvertPDF2Image("F:\\PdfFile.doc", "F:\\",
  1925. /// "ImageFile", 1, 20, ImageFormat.Png, 256);
  1926. /// </summary>
  1927. /// <param name="pdfInputPath">Word文件路径</param>
  1928. /// <param name="imageOutputPath">图片输出路径,如果为空,默认值为Word所在路径</param>
  1929. /// <param name="imageName">图片的名字,不需要带扩展名,如果为空,默认值为Word的名称</param>
  1930. /// <param name="startPageNum">从PDF文档的第几页开始转换,如果为0,默认值为1</param>
  1931. /// <param name="endPageNum">从PDF文档的第几页开始停止转换,如果为0,默认值为Word总页数</param>
  1932. /// <param name="imageFormat">设置所需图片格式,如果为null,默认格式为PNG</param>
  1933. /// <param name="resolution">设置图片的像素,数字越大越清晰,如果为0,默认值为128,建议最大值不要超过1024</param>
  1934. public List<string> ConvertWordToImage(string wordInputPath, string imageOutputPath,
  1935. string imageName, int startPageNum, int endPageNum, ImageFormat imageFormat, float resolution)
  1936. {
  1937. // 返回的图片绝对路径集合
  1938. List<string> images = new List<string>();
  1939. try
  1940. {
  1941. // open word file
  1942. Aspose.Words.Document doc = new Aspose.Words.Document(wordInputPath);
  1943. // validate parameter
  1944. if (doc == null) { throw new Exception("Word文件无效或者Word文件被加密!"); }
  1945. if (imageOutputPath.Trim().Length == 0) { imageOutputPath = System.IO.Path.GetDirectoryName(wordInputPath); }
  1946. if (!Directory.Exists(imageOutputPath)) { Directory.CreateDirectory(imageOutputPath); }
  1947. if (imageName.Trim().Length == 0) { imageName = System.IO.Path.GetFileNameWithoutExtension(wordInputPath); }
  1948. if (startPageNum <= 0) { startPageNum = 1; }
  1949. if (endPageNum > doc.PageCount || endPageNum <= 0) { endPageNum = doc.PageCount; }
  1950. if (startPageNum > endPageNum) { int tempPageNum = startPageNum; startPageNum = endPageNum; endPageNum = startPageNum; }
  1951. if (imageFormat == null) { imageFormat = ImageFormat.Png; }
  1952. if (resolution <= 0) { resolution = 128; }
  1953. ImageSaveOptions imageSaveOptions = new ImageSaveOptions(GetSaveFormat(imageFormat))
  1954. {
  1955. Resolution = resolution
  1956. };
  1957. // start to convert each page
  1958. for (int i = startPageNum; i <= endPageNum; i++)
  1959. {
  1960. imageSaveOptions.PageIndex = i - 1;
  1961. doc.Save(System.IO.Path.Combine(imageOutputPath, imageName) + "_" + APP.num.ToString() + "." + imageFormat.ToString(), imageSaveOptions);
  1962. images.Add(System.IO.Path.Combine(imageOutputPath, imageName) + "_" + APP.num.ToString() + "." + imageFormat.ToString());
  1963. APP.num++;
  1964. }
  1965. imageSaveOptions = null;
  1966. doc = null;
  1967. }
  1968. catch (Exception ex)
  1969. {
  1970. MessageWindow.Show("文档已打开,请关闭后重试!");
  1971. LogHelper.WriteErrLog("【课堂考试(ExamWindow)】错误日志:" + ex.Message, ex);
  1972. }
  1973. return images;
  1974. }
  1975. private static SaveFormat GetSaveFormat(ImageFormat imageFormat)
  1976. {
  1977. SaveFormat sf;// = SaveFormat.Unknown;
  1978. if (imageFormat.Equals(ImageFormat.Png))
  1979. {
  1980. sf = SaveFormat.Png;
  1981. }
  1982. else if (imageFormat.Equals(ImageFormat.Jpeg))
  1983. {
  1984. sf = SaveFormat.Jpeg;
  1985. }
  1986. else if (imageFormat.Equals(ImageFormat.Tiff))
  1987. {
  1988. sf = SaveFormat.Tiff;
  1989. }
  1990. else if (imageFormat.Equals(ImageFormat.Bmp))
  1991. {
  1992. sf = SaveFormat.Bmp;
  1993. }
  1994. else
  1995. {
  1996. sf = SaveFormat.Unknown;
  1997. }
  1998. return sf;
  1999. }
  2000. #region 图像缩放,移动
  2001. private bool mouseDown;
  2002. private System.Windows.Point mouseXY;
  2003. private void IMG1_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
  2004. {
  2005. var img = sender as ContentControl;
  2006. if (img == null)
  2007. {
  2008. return;
  2009. }
  2010. img.CaptureMouse();
  2011. mouseDown = true;
  2012. mouseXY = e.GetPosition(img);
  2013. Console.WriteLine("mouseXY.X = " + mouseXY.X + "; mouseXY.Y = " + mouseXY.Y);
  2014. }
  2015. private void PicEMap_MouseDown(object sender, MouseButtonEventArgs e)
  2016. {
  2017. System.Windows.Point point = e.GetPosition(imgCanvas);
  2018. //Console.WriteLine("PicEmap.X = " + point.X + "; PicEmap.Y = " + point.Y);
  2019. //if ((point.X - 304) * (point.X - 304) + (point.Y - 86) * (point.Y - 86) < 100)
  2020. //{
  2021. // Console.WriteLine("在范围内");
  2022. //}
  2023. }
  2024. private void IMG1_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
  2025. {
  2026. var img = sender as ContentControl;
  2027. if (img == null)
  2028. {
  2029. return;
  2030. }
  2031. img.ReleaseMouseCapture();
  2032. mouseDown = false;
  2033. }
  2034. private void IMG1_MouseMove(object sender, System.Windows.Input.MouseEventArgs e)
  2035. {
  2036. var img = sender as ContentControl;
  2037. if (img == null)
  2038. {
  2039. return;
  2040. }
  2041. if (mouseDown)
  2042. {
  2043. Domousemove(img, e);
  2044. }
  2045. }
  2046. /// <summary>
  2047. /// x y轴
  2048. /// </summary>
  2049. /// <param name="img"></param>
  2050. /// <param name="e"></param>
  2051. private void Domousemove(ContentControl img, System.Windows.Input.MouseEventArgs e)
  2052. {
  2053. if (e.LeftButton != MouseButtonState.Pressed)
  2054. {
  2055. return;
  2056. }
  2057. if (APP.PageDrawList[APP.pageData.currpage - 1].ImageLocation != null && APP.PageDrawList[APP.pageData.currpage - 1].IsImageLocation)
  2058. {
  2059. return;
  2060. }
  2061. var group = IMG.FindResource("Imageview") as TransformGroup;
  2062. var transform = group.Children[1] as TranslateTransform;
  2063. var position = e.GetPosition(img);
  2064. transform.X -= mouseXY.X - position.X;
  2065. transform.Y -= mouseXY.Y - position.Y;
  2066. mouseXY = position;
  2067. APP.PageDrawList[APP.pageData.currpage - 1].ImageLocation = new TranslateTransform();
  2068. APP.PageDrawList[APP.pageData.currpage - 1].ImageLocation.X = transform.X;
  2069. APP.PageDrawList[APP.pageData.currpage - 1].ImageLocation.Y = transform.Y;
  2070. //APP.PageDrawList[APP.pageData.currpage - 1].IsImageLocation = false;
  2071. }
  2072. private void IMG1_MouseWheel(object sender, MouseWheelEventArgs e)
  2073. {
  2074. var img = sender as ContentControl;
  2075. if (img == null)
  2076. {
  2077. return;
  2078. }
  2079. var point = e.GetPosition(img);
  2080. Console.WriteLine("point.X = " + point.X + "; point.Y=" + point.Y);
  2081. var PicLocate = e.GetPosition(imgCanvas);
  2082. Console.WriteLine("PicEmap.X = " + PicLocate.X + "; PicEmap.Y=" + PicLocate.Y);
  2083. var group = IMG.FindResource("Imageview") as TransformGroup;
  2084. var delta = e.Delta * 0.001;
  2085. DowheelZoom(group, point, delta);
  2086. }
  2087. private void DowheelZoom(TransformGroup group, System.Windows.Point point, double delta)
  2088. {
  2089. var pointToContent = group.Inverse.Transform(point);
  2090. var transform = group.Children[0] as ScaleTransform;
  2091. if (transform.ScaleX + delta < 0.1) return;
  2092. transform.ScaleX += delta;
  2093. transform.ScaleY += delta;
  2094. var transform1 = group.Children[1] as TranslateTransform;
  2095. transform1.X = -1 * ((pointToContent.X * transform.ScaleX) - point.X);
  2096. transform1.Y = -1 * ((pointToContent.Y * transform.ScaleY) - point.Y);
  2097. LogHelper.WriteInfoLog("【img宽高】" + imgCanvas.ActualWidth.ToString() + ":"
  2098. + imgCanvas.ActualHeight.ToString() + "百分比:" + transform.ScaleX.ToString() + ":" + transform.ScaleY.ToString()
  2099. );
  2100. //Console.WriteLine("transform.ScaleX = " + transform.ScaleX + "; transform.ScaleY = " + transform.ScaleY);
  2101. APP.PageDrawList[APP.pageData.currpage - 1].ImageSize = new ScaleTransform();
  2102. APP.PageDrawList[APP.pageData.currpage - 1].ImageSize.ScaleX = transform.ScaleX;
  2103. APP.PageDrawList[APP.pageData.currpage - 1].ImageSize.ScaleY = transform.ScaleY;
  2104. APP.PageDrawList[APP.pageData.currpage - 1].ImageLocation = new TranslateTransform();
  2105. APP.PageDrawList[APP.pageData.currpage - 1].ImageLocation.X = transform1.X;
  2106. APP.PageDrawList[APP.pageData.currpage - 1].ImageLocation.Y = transform1.Y;
  2107. APP.PageDrawList[APP.pageData.currpage - 1].ImageSizes = new ScaleTransform();
  2108. APP.PageDrawList[APP.pageData.currpage - 1].ImageSizes.CenterX = imgCanvas.ActualWidth;
  2109. APP.PageDrawList[APP.pageData.currpage - 1].ImageSizes.CenterY = imgCanvas.ActualHeight;
  2110. APP.PageDrawList[APP.pageData.currpage - 1].IsImageLocation = false;
  2111. }
  2112. #endregion
  2113. #region 点阵笔相关
  2114. #region 值初始化
  2115. // 不同尺寸点阵纸点阵宽高尺寸计算方法为:纸张物理尺寸(毫米)/0.3 *8,详见 开发必读.pdf 文档
  2116. /// <summary>
  2117. /// A4点阵纸点阵宽度
  2118. /// </summary>
  2119. private const int A4_WIDTH = 5600;
  2120. /// <summary>
  2121. /// A4点阵纸点阵高度
  2122. /// </summary>
  2123. private const int A4_HEIGHT = 7920;
  2124. /// <summary>
  2125. /// 画板
  2126. /// </summary>
  2127. private Graphics graphics;
  2128. /// <summary>
  2129. /// 笔画坐标数组
  2130. /// </summary>
  2131. private List<System.Drawing.Point> stroke;
  2132. /// <summary>
  2133. /// 笔序列号
  2134. /// </summary>
  2135. private string penSerial;
  2136. /// <summary>
  2137. /// 笔是否在点
  2138. /// </summary>
  2139. private bool isPenDown;
  2140. //当前点阵地址
  2141. private string currentPageSerial = string.Empty;
  2142. //不同点阵地址对应的笔迹绘制图片,用于实现在不同点阵地址书写切换时,显示书写内容自动切换
  2143. //本例图片放在内存中存储,对于大量或者需要在多个点阵地址对应图片进行切换演示,建议将图片存储到文件,以免内存溢出
  2144. private Dictionary<string, System.Drawing.Image> pagesDic = new Dictionary<string, System.Drawing.Image>();
  2145. #endregion
  2146. public void InitPen()
  2147. {
  2148. stroke = new List<System.Drawing.Point>();
  2149. //获取点阵笔实例,并绑定点阵笔事件
  2150. //将授权文件内容传入,获取点阵笔对象实例
  2151. APP.digitalPen = DigitalPenHID.GetInstance(certificates.MyLicense.Bytes);
  2152. //绑定笔连接事件
  2153. APP.digitalPen.PenConnected += OnPenConnect;
  2154. //绑定笔断开事件
  2155. APP.digitalPen.PenDisconnect += OnPenDisconnect;
  2156. //绑定笔书写输出坐标事件
  2157. APP.digitalPen.PenCoordinate += OnPenCoordinate;
  2158. //绑定抬笔事件
  2159. APP.digitalPen.PenUp += OnPenUp;
  2160. //绑定落笔事件
  2161. APP.digitalPen.PenDown += OnPenDown;
  2162. APP.digitalPen.PenBatteryCapacity += OnBatteryCapacity;
  2163. APP.digitalPen.PenMemoryFillLevel += OnMemoryFillLevel;
  2164. //完成初始化点阵笔,开始与点阵笔通信
  2165. ERROR_CODE ER = APP.digitalPen.Start();
  2166. ////绑定笔在新的点阵地址页面书写事件
  2167. //APP.digitalPen.PenNewPage += APP.digitalPen_OnPenNewPage;
  2168. ////绑定笔信息事件
  2169. //APP.digitalPen.PenInfo += APP.digitalPen_OnPenInfo;
  2170. //启动接收笔数据,完成初始化工作
  2171. ERROR_CODE rc = APP.digitalPen.Start();
  2172. //判断是否成功
  2173. if (ER != ERROR_CODE.ERROR_OK)
  2174. {
  2175. MessageWindow.Show("初始化失败,授权过期,返回值:" + ER.ToString());
  2176. }
  2177. }
  2178. /// <summary>
  2179. /// 落笔
  2180. /// </summary>
  2181. /// <param name="time">时间戳,1970年1月1日到现在的总毫秒数</param>
  2182. /// <param name="penSerial">点阵笔序列号</param>
  2183. /// <param name="penType">点阵笔型号编号</param>
  2184. private void OnPenDown(ulong time, string penSerial, int penType)
  2185. {
  2186. if (this.CheckAccess())
  2187. {
  2188. Action<ulong, string, int> action = new Action<ulong, string, int>(OnPenDown);
  2189. this.Dispatcher.Invoke(action, new object[] { time, penSerial, penType });
  2190. }
  2191. else
  2192. {
  2193. //labPenSerial.Text = penSerial;
  2194. //labPenStatus.Text = "PenDown";
  2195. isPenDown = true;
  2196. //Dispatcher.Invoke(new Action(() =>
  2197. //{
  2198. // for (int i = 0; i < APP.PageDrawList.Count; i++)
  2199. // {
  2200. // if (APP.PageDrawList[i].PageCode == penSerial)
  2201. // {
  2202. // if (i < APP.pageData.pagenum)
  2203. // {
  2204. // if (i < APP.pageData.currpage)
  2205. // {
  2206. // int num = APP.pageData.currpage - i;
  2207. // APP.pageData.currpage -= num;
  2208. // myblackboard.changepage(APP.pageData.currpage - 1);
  2209. // if (APP.PageDrawList.Count > 0)
  2210. // {
  2211. // if (!string.IsNullOrWhiteSpace(txbCurrpage.Text) && APP.pageData.currpage <= APP.PageDrawList.Count && APP.pageData.currpage > 0 && !string.IsNullOrWhiteSpace(APP.PageDrawList[APP.pageData.currpage - 1].PageImagePath))
  2212. // {
  2213. // //imgCanvas.Source = new BitmapImage(new Uri(APP.Paths[APP.pageData.currpage - 1]));//cs
  2214. // imgCanvas.Source = new BitmapImage(new Uri(APP.PageDrawList[APP.pageData.currpage - 1].PageImagePath));
  2215. // }
  2216. // else
  2217. // {
  2218. // imgCanvas.Source = null;
  2219. // }
  2220. // }
  2221. // }
  2222. // else
  2223. // {
  2224. // int num = i - APP.pageData.currpage;
  2225. // APP.pageData.currpage += num;
  2226. // myblackboard.changepage(APP.pageData.currpage - 1);
  2227. // if (APP.PageDrawList.Count > 0)
  2228. // {
  2229. // if (!string.IsNullOrWhiteSpace(txbCurrpage.Text) && APP.pageData.currpage <= APP.PageDrawList.Count && !string.IsNullOrWhiteSpace(APP.PageDrawList[APP.pageData.currpage - 1].PageImagePath))
  2230. // {
  2231. // //imgCanvas.Source = new BitmapImage(new Uri(APP.Paths[APP.pageData.currpage-1]));
  2232. // imgCanvas.Source = new BitmapImage(new Uri(APP.PageDrawList[APP.pageData.currpage - 1].PageImagePath));
  2233. // }
  2234. // else
  2235. // {
  2236. // imgCanvas.Source = null;
  2237. // }
  2238. // }
  2239. // }
  2240. // }
  2241. // return;
  2242. // }
  2243. // }
  2244. // //myblackboard.changepages(0, 0, true);
  2245. // //myblackboard.changepaget(0, 0, true, blackboard_canvas);
  2246. //}));
  2247. }
  2248. //myblackboard.changepages(0, 0, true);
  2249. }
  2250. /// <summary>
  2251. /// 抬笔
  2252. /// </summary>
  2253. /// <param name="time">时间戳,1970年1月1日到现在的总毫秒数</param>
  2254. /// <param name="penSerial">点阵笔序列号</param>
  2255. /// <param name="penType">点阵笔型号编号</param>
  2256. private void OnPenUp(ulong time, string penSerial, int penType)
  2257. {
  2258. if (this.CheckAccess())
  2259. {
  2260. Action<ulong, string, int> action = new Action<ulong, string, int>(OnPenUp);
  2261. this.Dispatcher.Invoke(action, new object[] { time, penSerial, penType });
  2262. }
  2263. else
  2264. {
  2265. isPenDown = false;
  2266. APP.PenSerial = penSerial;
  2267. //int leftPoints = stroke.Count % 3;
  2268. //if (0 != leftPoints)
  2269. //{
  2270. // int from = stroke.Count - leftPoints - 1;
  2271. // if (from < 0)
  2272. // from = 0;
  2273. // int to = stroke.Count - 1;
  2274. // DrawCoordinates(from, to);
  2275. //}
  2276. stroke.Clear();
  2277. }
  2278. if (APP.pageData.currpage > 0)
  2279. {
  2280. Dispatcher.Invoke(new Action(() =>
  2281. {
  2282. myblackboard.changepages(0, 0, true, Color, PenSize, APP.pageData.currpage - 1);
  2283. }));
  2284. }
  2285. }
  2286. /// <summary>
  2287. /// 笔断开
  2288. /// </summary>
  2289. /// <param name="time">时间戳,1970年1月1日到现在的总毫秒数</param>
  2290. /// <param name="penSerial">点阵笔序列号</param>
  2291. /// <param name="penType">点阵笔型号编号</param>
  2292. private void OnPenDisconnect(ulong time, string penSerial, int penType)
  2293. {
  2294. if (this.CheckAccess())
  2295. {
  2296. Action<ulong, string, int> action = new Action<ulong, string, int>(OnPenDisconnect);
  2297. this.Dispatcher.Invoke(action, new object[] { time, penSerial, penType });
  2298. }
  2299. else
  2300. {
  2301. APP.PenSerial = penSerial;
  2302. APP.PenStatus = false;
  2303. Dispatcher.Invoke(new Action(() =>
  2304. {
  2305. txbNotConnected.Text = "未连接";
  2306. txbNotConnecteds.Text = "未连接";
  2307. }));
  2308. }
  2309. }
  2310. /// <summary>
  2311. /// 笔连接
  2312. /// </summary>
  2313. /// <param name="time">时间戳,1970年1月1日到现在的总毫秒数</param>
  2314. /// <param name="penSerial">点阵笔序列号</param>
  2315. /// <param name="penType">点阵笔型号编号</param>
  2316. private void OnPenConnect(ulong time, string penSerial, int penType)
  2317. {
  2318. if (this.CheckAccess())
  2319. {
  2320. Action<ulong, string, int> action = new Action<ulong, string, int>(OnPenConnect);
  2321. this.Dispatcher.Invoke(action, new object[] { time, penSerial, penType });
  2322. }
  2323. else
  2324. {
  2325. APP.PenSerial = penSerial;
  2326. APP.PenStatus = true;
  2327. this.penSerial = penSerial;
  2328. //连接后,在获取笔数据前,可以清除笔内的历史数据
  2329. //APP.digitalPen.ClearMemory(penSerial);
  2330. //开始接收笔数据
  2331. APP.digitalPen.GetPenData(penSerial);
  2332. Dispatcher.Invoke(new Action(() =>
  2333. {
  2334. txbNotConnected.Text = "已连接";
  2335. txbNotConnecteds.Text = "已连接";
  2336. }));
  2337. }
  2338. }
  2339. /// <summary>
  2340. /// 电池电量
  2341. /// </summary>
  2342. /// <param name="time"></param>
  2343. /// <param name="penSerial"></param>
  2344. /// <param name="penType"></param>
  2345. /// <param name="capacity"></param>
  2346. private void OnBatteryCapacity(ulong time, string penSerial, int penType, byte capacity)
  2347. {
  2348. if (this.CheckAccess())
  2349. {
  2350. Action<ulong, string, int, byte> action = new Action<ulong, string, int, byte>(OnBatteryCapacity);
  2351. this.Dispatcher.Invoke(action, new object[] { time, penSerial, penType, capacity });
  2352. }
  2353. else
  2354. {
  2355. //System.Windows.MessageWindow.Show("电池电量:" + capacity.ToString());
  2356. }
  2357. }
  2358. /// <summary>
  2359. /// 已用存储
  2360. /// </summary>
  2361. /// <param name="time"></param>
  2362. /// <param name="penSerial"></param>
  2363. /// <param name="penType"></param>
  2364. /// <param name="fillLevel"></param>
  2365. private void OnMemoryFillLevel(ulong time, string penSerial, int penType, byte fillLevel)
  2366. {
  2367. if (this.CheckAccess())
  2368. {
  2369. Action<ulong, string, int, byte> action = new Action<ulong, string, int, byte>(OnMemoryFillLevel);
  2370. this.Dispatcher.Invoke(action, new object[] { time, penSerial, penType, fillLevel });
  2371. }
  2372. else
  2373. {
  2374. //System.Windows.MessageWindow.Show("存储:" + fillLevel.ToString());
  2375. }
  2376. }
  2377. /// <summary>
  2378. /// 笔书写,收到坐标
  2379. /// </summary>
  2380. /// <param name="time">时间戳,1970年1月1日到现在的总毫秒数</param>
  2381. /// <param name="penSerial">点阵笔序列号</param>
  2382. /// <param name="penType">点阵笔型号编号</param>
  2383. /// <param name="pageSerial">点阵地址</param>
  2384. /// <param name="cx">x坐标</param>
  2385. /// <param name="cy">y坐标</param>
  2386. /// <param name="force">压力值</param>
  2387. private void OnPenCoordinate(ulong time, string penSerial, int penType, string pageSerial, int cx, int cy, byte force)
  2388. {
  2389. if (this.CheckAccess())
  2390. {
  2391. Action<ulong, string, int, string, int, int, byte> ac = new Action<ulong, string, int, string, int, int, byte>(OnPenCoordinate);
  2392. this.Dispatcher.Invoke(ac, new object[] { time, pageSerial, penType, pageSerial, cx, cy, force });
  2393. }
  2394. else
  2395. {
  2396. //判断是否是落笔后输出的坐标,在设置悬浮模式下,落笔前的悬浮坐标不绘制
  2397. if (!isPenDown)
  2398. {
  2399. return;
  2400. }
  2401. stroke.Add(new System.Drawing.Point(cx, cy));
  2402. double PropW = blackboard_canvas.ActualWidth / A4_WIDTH;
  2403. double PropH = blackboard_canvas.ActualHeight / A4_HEIGHT;
  2404. //点
  2405. double testX = (double)cx * PropW;
  2406. double testY = (double)cy * PropH;
  2407. //pageSerial //点阵IP地址 与打印的页面关联
  2408. if (APP.pageData.currpage > 0)
  2409. {
  2410. Dispatcher.Invoke(new Action(() =>
  2411. {
  2412. //myblackboard.changepages(testX, testY,false);
  2413. myblackboard.changepages(testX, testY, false, Color, PenSize, APP.pageData.currpage - 1);
  2414. #region 设置滚动条位置
  2415. //点在显示页面上方
  2416. if (testY < scroMain.VerticalOffset)
  2417. {
  2418. //滚动条当前位置
  2419. double RollCurrentLocation = scroMain.VerticalOffset;
  2420. //向上滚动至以点为中心需要滚动的距离
  2421. double UpRoll = (RollCurrentLocation - testY) + (scroMain.ActualHeight / 2);
  2422. //如果小于0则等于0
  2423. double RollLocation = RollCurrentLocation - UpRoll;
  2424. if (RollLocation < 0)
  2425. {
  2426. RollLocation = 0;
  2427. }
  2428. ////滚动条实际偏移量
  2429. //double RollOffset = RollCurrentLocation - RollLocation;
  2430. scroMain.ScrollToVerticalOffset(RollLocation);
  2431. }
  2432. //点在显示页面下方
  2433. if (testY > scroMain.VerticalOffset + scroMain.ActualHeight)
  2434. {
  2435. //滚动条当前位置
  2436. double RollCurrentLocation = scroMain.VerticalOffset;
  2437. //向下滚动至以点为中心需要滚动的距离
  2438. double DownRoll = (testY - RollCurrentLocation) - (scroMain.ActualHeight / 2);
  2439. //如果小于0则等于0
  2440. double RollLocation = RollCurrentLocation + DownRoll;
  2441. //滚动条最大滚动值
  2442. double ScrollbarMaxNum = gridM.ActualHeight - scroMain.ActualHeight;
  2443. if (RollLocation > ScrollbarMaxNum)
  2444. {
  2445. RollLocation = ScrollbarMaxNum;
  2446. }
  2447. ////滚动条实际偏移量
  2448. //double RollOffset = RollLocation-RollCurrentLocation;
  2449. scroMain.ScrollToVerticalOffset(RollLocation);
  2450. }
  2451. #endregion
  2452. //gridM.Height //A4高度
  2453. //scroMain.VerticalOffset;//获取滚动条位置
  2454. //scroMain.ActualHeight//A4纸显示高度
  2455. //scroMain.ScrollToHorizontalOffset()//设置滚动条位置
  2456. //Mouse.GetPosition(this)
  2457. if (testX > 0 && testY > 0)
  2458. {
  2459. //System.Windows.Point getP = blackboard_canvas.PointToScreen(new System.Windows.Point(testX, testY));
  2460. System.Windows.Point getP = scroMain.PointToScreen(new System.Windows.Point(testX, testY - scroMain.VerticalOffset));
  2461. SetCursorPos((int)getP.X, (int)getP.Y);
  2462. }
  2463. }));
  2464. }
  2465. ////每3个点画一条曲线
  2466. //if (stroke.Count % 3 == 0)
  2467. //{
  2468. // int from = stroke.Count - 3 - 1;
  2469. // if (from < 0)
  2470. // from = 0;
  2471. // int to = stroke.Count - 1;
  2472. // DrawCoordinates(from, to);
  2473. //}
  2474. }
  2475. }
  2476. /// <summary>
  2477. /// 停止笔
  2478. /// </summary>
  2479. public void StopDigitalPen()
  2480. {
  2481. //停止,释放资源
  2482. APP.digitalPen.Stop();
  2483. }
  2484. /// <summary>
  2485. /// 清空笔内存储
  2486. /// </summary>
  2487. public void ClearPenStorage()
  2488. {
  2489. if (!string.IsNullOrEmpty(penSerial))
  2490. APP.digitalPen.ClearMemory(penSerial);
  2491. }
  2492. /// <summary>
  2493. /// 获取剩余电量
  2494. /// </summary>
  2495. public void GetPenElectricityQuantity()
  2496. {
  2497. if (!string.IsNullOrEmpty(penSerial))
  2498. APP.digitalPen.GetBatteryCapacity(penSerial);
  2499. }
  2500. /// <summary>
  2501. /// 获取存储空间
  2502. /// </summary>
  2503. public void GetUsedStorage()
  2504. {
  2505. if (!string.IsNullOrEmpty(penSerial))
  2506. APP.digitalPen.GetMemoryFillLevel(penSerial);
  2507. }
  2508. /// <summary>
  2509. /// 开启悬浮
  2510. /// </summary>
  2511. public void 开启悬浮()
  2512. {
  2513. if (!string.IsNullOrEmpty(penSerial))
  2514. APP.digitalPen.SetPenHoverMode(true, penSerial);
  2515. }
  2516. /// <summary>
  2517. /// 关闭悬浮
  2518. /// </summary>
  2519. public void 关闭悬浮()
  2520. {
  2521. if (!string.IsNullOrEmpty(penSerial))
  2522. APP.digitalPen.SetPenHoverMode(false, penSerial);
  2523. }
  2524. #endregion
  2525. /// <summary>
  2526. /// 最小化
  2527. /// </summary>
  2528. /// <param name="sender"></param>
  2529. /// <param name="e"></param>
  2530. private void BtnShrink_Click(object sender, RoutedEventArgs e)
  2531. {
  2532. if (this.WindowState == WindowState.Minimized)
  2533. {
  2534. this.WindowState = WindowState.Normal;
  2535. }
  2536. else
  2537. {
  2538. this.WindowState = WindowState.Minimized;
  2539. }
  2540. }
  2541. /// <summary>
  2542. /// 位置确定
  2543. /// </summary>
  2544. /// <param name="sender"></param>
  2545. /// <param name="e"></param>
  2546. private void BtnOk_Click(object sender, RoutedEventArgs e)
  2547. {
  2548. //APP.PageDrawList[APP.pageData.currpage - 1].IsImageLocation = true;
  2549. //btnOk.Visibility = Visibility.Collapsed;
  2550. //blackboard_canvas.Visibility = Visibility.Visible;
  2551. }
  2552. /// <summary>
  2553. /// 引用user32.dll动态链接库(windows api),
  2554. /// 使用库中定义 API:SetCursorPos
  2555. /// 设置光标位置
  2556. /// </summary>
  2557. [System.Runtime.InteropServices.DllImport("user32.dll")]
  2558. private static extern int SetCursorPos(int x, int y);
  2559. /// 截图的图片鼠标右键事件
  2560. /// </summary>
  2561. /// <param name="sender"></param>
  2562. /// <param name="e"></param>
  2563. private void imgCanvas_MouseRightButtonDown(object sender, MouseButtonEventArgs e)
  2564. {
  2565. imgCanvas.Source = null;
  2566. }
  2567. #region 上传
  2568. /// <summary>
  2569. /// 初始化上传
  2570. /// </summary>
  2571. public void InitializeUpload()
  2572. {
  2573. APP.myloading.Show();
  2574. MouseNumber = 0;
  2575. IsModify = false;
  2576. //加载视频列表
  2577. LoadingVideoList();
  2578. int i = 1;
  2579. bool isColour = true;
  2580. pageData.menuList.Clear();
  2581. //显示视频
  2582. foreach (Model_Video videoinfo in model_VideoList)
  2583. {
  2584. //是否已上传
  2585. //videoinfo.IsUpload;
  2586. //录制时间
  2587. //videoinfo.RSTime;
  2588. //文件大小
  2589. //videoinfo.VideoSize;
  2590. //文件缩略图路径
  2591. //videoinfo.ThumbnailPath;
  2592. //文件唯一标示 上传事件筛选需要上传的视频
  2593. //videoinfo.FileGuid;
  2594. //文件存储路径
  2595. //videoinfo.VidePath;
  2596. string colour = "#FFFFFF";
  2597. if (isColour == true)
  2598. {
  2599. colour = "#FFFFFF";
  2600. isColour = false;
  2601. }
  2602. else
  2603. {
  2604. colour = "#E6F1FF";
  2605. isColour = true;
  2606. }
  2607. string vis = "Visible";
  2608. string cos = "Collapsed";
  2609. if (!videoinfo.IsUpload)
  2610. {
  2611. vis = "Collapsed";
  2612. cos = "Visible";
  2613. }
  2614. if (i <= 16)
  2615. {
  2616. pageData.menuList.Add(new FileDirectoryModel()
  2617. {
  2618. SerialNumber = i,
  2619. VideoName = Common.system.FileToolsCommon.GetIOFileName(videoinfo.VideoPath).Replace(".MP4", "").Replace(".FLV", "").Replace(".AVI", "").Trim(),
  2620. Name = Common.system.FileToolsCommon.GetIOFileName(videoinfo.VideoPath).Replace(".MP4", "").Replace(".FLV", "").Replace(".AVI", "").Trim(),
  2621. FilePath = videoinfo.VideoPath.Replace(FileToolsCommon.GetIOFileName(videoinfo.VideoPath), "").Trim(),
  2622. VideoDuration = 0,
  2623. VideoSize = videoinfo.VideoSize,
  2624. VideoTime = videoinfo.RSTime,
  2625. IsEnabled = false,
  2626. Path = videoinfo.VideoPath,
  2627. Colour = colour,
  2628. Visi = vis,
  2629. Coll = cos,
  2630. FileGuid = videoinfo.FileGuid,
  2631. VideoType = videoinfo.VideoType.ToString()
  2632. }); ;
  2633. }
  2634. i++;
  2635. }
  2636. Currpage = 0;
  2637. PageNum = 0;
  2638. if (pageData.menuList.Count>0)
  2639. {
  2640. Currpage = 1;
  2641. txbCurrpageTwo.Text = Currpage.ToString();
  2642. stpUp.Visibility = Visibility.Visible;
  2643. }
  2644. else
  2645. {
  2646. stpUp.Visibility = Visibility.Hidden;
  2647. }
  2648. PageNum = model_VideoList.Count;
  2649. if (PageNum > 0)
  2650. {
  2651. int t = 1;
  2652. while (PageNum > 16 * t)
  2653. {
  2654. t++;
  2655. }
  2656. PageNum = t;
  2657. }
  2658. else
  2659. {
  2660. PageNum = 0;
  2661. }
  2662. txbPageNumTwo.Text = PageNum.ToString();
  2663. APP.myloading.Hide();
  2664. DataContext = pageData;
  2665. }
  2666. /// <summary>
  2667. /// 当前页
  2668. /// </summary>
  2669. int Currpage = 0;
  2670. /// <summary>
  2671. /// 总页码
  2672. /// </summary>
  2673. int PageNum = 0;
  2674. /// <summary>
  2675. /// 加载视频列表
  2676. /// </summary>
  2677. public void LoadingVideoList()
  2678. {
  2679. try
  2680. {
  2681. model_VideoList = new List<Model_Video>();
  2682. foreach (Model_WKData Vdata in APP.WKDataList)
  2683. {
  2684. if (Vdata.VideoList == null)
  2685. continue;
  2686. foreach (Model_Video videoinfo in Vdata.VideoList)
  2687. {
  2688. try
  2689. {
  2690. if (string.IsNullOrWhiteSpace(videoinfo.VideoPath))
  2691. {
  2692. continue;
  2693. }
  2694. if (string.IsNullOrWhiteSpace(videoinfo.VideoSize) || videoinfo.VideoSize == "0 MB")
  2695. {
  2696. videoinfo.VideoSize = FileToolsCommon.GetFileSizeByMB(videoinfo.VideoPath).ToString() + " MB";
  2697. }
  2698. model_VideoList.Add(videoinfo);
  2699. }
  2700. catch (Exception ex)
  2701. {
  2702. LogHelper.WriteErrLog("【加载视频列表】(LoadingVideoList)" + ex.Message, ex);
  2703. }
  2704. }
  2705. }
  2706. }
  2707. catch (Exception ex)
  2708. {
  2709. LogHelper.WriteErrLog("【加载视频列表】(LoadingVideoList)" + ex.Message, ex);
  2710. }
  2711. }
  2712. /// <summary>
  2713. /// 上传
  2714. /// </summary>
  2715. /// <param name="sender"></param>
  2716. /// <param name="e"></param>
  2717. private void BtnUploads_Click(object sender, RoutedEventArgs e)
  2718. {
  2719. pageData.menuList[Subscript].IsEnabled = false;
  2720. List<System.Windows.Controls.Button> buttons = FindChilds<System.Windows.Controls.Button>(listView1, "btnUpload");
  2721. for (int i = 0; i < buttons.Count; i++)
  2722. {
  2723. if (buttons[i] == sender)
  2724. {
  2725. DAL_Upload dAL_Upload = new DAL_Upload();
  2726. if (dAL_Upload.UploadVideo(pageData.menuList[i].FileGuid, out string ErrMessage))
  2727. {
  2728. //foreach (Model_WKData wKData in APP.WKDataList)
  2729. //{
  2730. // if (wKData.VideoList == null)
  2731. // continue;
  2732. // //if()
  2733. // //{
  2734. // //}
  2735. //}
  2736. pageData.menuList[i].Visi = "Collapsed";
  2737. pageData.menuList[i].Coll = "Visible";
  2738. DataContext = pageData;
  2739. //MessageWindow.Show("视频上传服务器成功!");
  2740. if (APP.W_UploadWindow == null)
  2741. {
  2742. APP.W_UploadWindow = new UploadWindow();
  2743. APP.W_UploadWindow.Owner = this;
  2744. }
  2745. //long size = Convert.ToInt64(FileToolsCommon.GetFileSizeByMB(pageData.menuList[i].FilePath));
  2746. APP.W_UploadWindow.Initialize(pageData.menuList[i].VideoName,11110 /*Convert.ToInt64(pageData.menuList[i].VideoSize)*/, pageData.menuList[i].VideoType);
  2747. APP.W_UploadWindow.ShowDialog();
  2748. }
  2749. else
  2750. {
  2751. MessageWindow.Show(ErrMessage);
  2752. }
  2753. }
  2754. }
  2755. }
  2756. /// <summary>
  2757. /// 删除
  2758. /// </summary>
  2759. /// <param name="sender"></param>
  2760. /// <param name="e"></param>
  2761. private void BtnDelete_Click(object sender, RoutedEventArgs e)
  2762. {
  2763. pageData.menuList[Subscript].IsEnabled = false;
  2764. List<System.Windows.Controls.Button> buttons = FindChilds<System.Windows.Controls.Button>(listView1, "btnDelete");
  2765. for (int i = 0; i < buttons.Count; i++)
  2766. {
  2767. if (buttons[i] == sender)
  2768. {
  2769. //if (APP.W_PromptWindow == null)
  2770. //{
  2771. // APP.W_PromptWindow = new PromptWindow();
  2772. // APP.W_PromptWindow.Owner = this;
  2773. //}
  2774. //APP.W_PromptWindow.Initialize(pageData.menuList[i].VideoName);
  2775. //APP.W_PromptWindow.ShowDialog();
  2776. foreach (Model_WKData wKData in APP.WKDataList)
  2777. {
  2778. if (wKData.VideoList == null)
  2779. continue;
  2780. if (wKData.VideoList.Exists(x => x.FileGuid == pageData.menuList[i].FileGuid))
  2781. {
  2782. try
  2783. {
  2784. FileToolsCommon.DeleteFile(wKData.VideoList.Find(x => x.FileGuid == pageData.menuList[i].FileGuid).VideoPath);
  2785. FileToolsCommon.DeleteFile(wKData.VideoList.Find(x => x.FileGuid == pageData.menuList[i].FileGuid).ThumbnailPath);
  2786. wKData.VideoList.Remove(wKData.VideoList.Find(x => x.FileGuid == pageData.menuList[i].FileGuid));
  2787. InitializeUpload();
  2788. return;
  2789. }
  2790. catch (Exception ex)
  2791. {
  2792. System.Windows.MessageBox.Show("无法删除视频!" + ex.Message);
  2793. return;
  2794. }
  2795. }
  2796. }
  2797. }
  2798. }
  2799. }
  2800. /// <summary>
  2801. /// 播放
  2802. /// </summary>
  2803. /// <param name="sender"></param>
  2804. /// <param name="e"></param>
  2805. private void BtnPlay_Click(object sender, RoutedEventArgs e)
  2806. {
  2807. pageData.menuList[Subscript].IsEnabled = false;
  2808. List<System.Windows.Controls.Button> buttons = FindChilds<System.Windows.Controls.Button>(listView1, "btnPlay");
  2809. for (int i = 0; i < buttons.Count; i++)
  2810. {
  2811. if (buttons[i] == sender)
  2812. {
  2813. try
  2814. {
  2815. ProcessStartInfo psi = new ProcessStartInfo(pageData.menuList[i].Path);
  2816. Process pro = new Process
  2817. {
  2818. StartInfo = psi
  2819. };
  2820. pro.Start();
  2821. }
  2822. catch (Exception ex)
  2823. {
  2824. LogHelper.WriteErrLog("FileDirectoryWindow【BtnPlay_Click】" + ex.Message, ex);
  2825. System.Windows.MessageBox.Show(ex.Message);
  2826. return;
  2827. }
  2828. }
  2829. }
  2830. }
  2831. /// <summary>
  2832. /// 搜索集合匹配的索引
  2833. /// </summary>
  2834. /// <typeparam name="T"></typeparam>
  2835. /// <param name="parent"></param>
  2836. /// <param name="childName"></param>
  2837. /// <returns></returns>
  2838. public static List<T> FindChilds<T>(DependencyObject parent, string childName)
  2839. where T : DependencyObject
  2840. {
  2841. List<T> list = new List<T>();
  2842. if (parent == null)
  2843. {
  2844. return list;
  2845. }
  2846. int childrenCount = VisualTreeHelper.GetChildrenCount(parent);
  2847. for (int i = 0; i < childrenCount; i++)
  2848. {
  2849. DependencyObject child = VisualTreeHelper.GetChild(parent, i);
  2850. // 如果子控件不是需查找的控件类型
  2851. T childType = child as T;
  2852. if (childType == null)
  2853. {
  2854. // 在下一级控件中递归查找
  2855. List<T> findChildList = FindChilds<T>(child, childName);
  2856. for (int j = 0; j < findChildList.Count; j++)
  2857. {
  2858. }
  2859. list.AddRange(FindChilds<T>(child, childName));
  2860. }
  2861. else if (!string.IsNullOrEmpty(childName))
  2862. {
  2863. FrameworkElement frameworkElement = child as FrameworkElement;
  2864. // 如果控件名称符合参数条件
  2865. if (frameworkElement != null && frameworkElement.Name == childName)
  2866. {
  2867. list.Add((T)child);
  2868. }
  2869. }
  2870. else
  2871. {
  2872. // 查找到了控件
  2873. list.Add((T)child);
  2874. }
  2875. }
  2876. return list;
  2877. }
  2878. /// <summary>
  2879. /// 修改
  2880. /// </summary>
  2881. /// <param name="sender"></param>
  2882. /// <param name="e"></param>
  2883. private void BtnModify_Click(object sender, RoutedEventArgs e)
  2884. {
  2885. if (IsModify)
  2886. {
  2887. pageData.menuList[Subscript].IsEnabled = false;
  2888. }
  2889. List<System.Windows.Controls.Button> buttons = FindChilds<System.Windows.Controls.Button>(listView1, "btnModify");
  2890. for (int i = 0; i < buttons.Count; i++)
  2891. {
  2892. if (buttons[i] == sender)
  2893. {
  2894. pageData.menuList[i].IsEnabled = true;
  2895. Subscript = i;
  2896. IsModify = true;
  2897. }
  2898. }
  2899. }
  2900. int MouseNumber = 0;
  2901. /// <summary>
  2902. /// 上传 上页
  2903. /// </summary>
  2904. /// <param name="sender"></param>
  2905. /// <param name="e"></param>
  2906. private void BtnLastPage_Click(object sender, RoutedEventArgs e)
  2907. {
  2908. if (Currpage >1)
  2909. {
  2910. Currpage -= 1;
  2911. txbCurrpageTwo.Text = Currpage.ToString();
  2912. int i = 1;
  2913. bool isColour = true;
  2914. pageData.menuList.Clear();
  2915. //显示视频
  2916. foreach (Model_Video videoinfo in model_VideoList)
  2917. {
  2918. //是否已上传
  2919. //videoinfo.IsUpload;
  2920. //录制时间
  2921. //videoinfo.RSTime;
  2922. //文件大小
  2923. //videoinfo.VideoSize;
  2924. //文件缩略图路径
  2925. //videoinfo.ThumbnailPath;
  2926. //文件唯一标示 上传事件筛选需要上传的视频
  2927. //videoinfo.FileGuid;
  2928. //文件存储路径
  2929. //videoinfo.VidePath;
  2930. string colour = "#FFFFFF";
  2931. if (isColour == true)
  2932. {
  2933. colour = "#FFFFFF";
  2934. isColour = false;
  2935. }
  2936. else
  2937. {
  2938. colour = "#E6F1FF";
  2939. isColour = true;
  2940. }
  2941. string vis = "Visible";
  2942. string cos = "Collapsed";
  2943. if (!videoinfo.IsUpload)
  2944. {
  2945. vis = "Collapsed";
  2946. cos = "Visible";
  2947. }
  2948. if (i <= Currpage * 16 && i >= (Currpage - 1) * 16)
  2949. {
  2950. pageData.menuList.Add(new FileDirectoryModel()
  2951. {
  2952. SerialNumber = i,
  2953. VideoName = Common.system.FileToolsCommon.GetIOFileName(videoinfo.VideoPath).Replace(".MP4", "").Replace(".FLV", "").Replace(".AVI", "").Trim(),
  2954. Name = Common.system.FileToolsCommon.GetIOFileName(videoinfo.VideoPath).Replace(".MP4", "").Replace(".FLV", "").Replace(".AVI", "").Trim(),
  2955. FilePath = videoinfo.VideoPath.Replace(FileToolsCommon.GetIOFileName(videoinfo.VideoPath), "").Trim(),
  2956. VideoDuration = 0,
  2957. VideoSize = videoinfo.VideoSize,
  2958. VideoTime = videoinfo.RSTime,
  2959. IsEnabled = false,
  2960. Path = videoinfo.VideoPath,
  2961. Colour = colour,
  2962. Visi = vis,
  2963. Coll = cos,
  2964. FileGuid = videoinfo.FileGuid,
  2965. VideoType = videoinfo.VideoType.ToString()
  2966. }); ;
  2967. }
  2968. i++;
  2969. }
  2970. APP.myloading.Hide();
  2971. }
  2972. }
  2973. /// <summary>
  2974. /// 上传 下页
  2975. /// </summary>
  2976. /// <param name="sender"></param>
  2977. /// <param name="e"></param>
  2978. private void BtnNextPage_Click(object sender, RoutedEventArgs e)
  2979. {
  2980. if(Currpage< PageNum)
  2981. {
  2982. Currpage += 1;
  2983. txbCurrpageTwo.Text = Currpage.ToString();
  2984. int i = 1;
  2985. bool isColour = true;
  2986. pageData.menuList.Clear();
  2987. //显示视频
  2988. foreach (Model_Video videoinfo in model_VideoList)
  2989. {
  2990. //是否已上传
  2991. //videoinfo.IsUpload;
  2992. //录制时间
  2993. //videoinfo.RSTime;
  2994. //文件大小
  2995. //videoinfo.VideoSize;
  2996. //文件缩略图路径
  2997. //videoinfo.ThumbnailPath;
  2998. //文件唯一标示 上传事件筛选需要上传的视频
  2999. //videoinfo.FileGuid;
  3000. //文件存储路径
  3001. //videoinfo.VidePath;
  3002. string colour = "#FFFFFF";
  3003. if (isColour == true)
  3004. {
  3005. colour = "#FFFFFF";
  3006. isColour = false;
  3007. }
  3008. else
  3009. {
  3010. colour = "#E6F1FF";
  3011. isColour = true;
  3012. }
  3013. string vis = "Visible";
  3014. string cos = "Collapsed";
  3015. if (!videoinfo.IsUpload)
  3016. {
  3017. vis = "Collapsed";
  3018. cos = "Visible";
  3019. }
  3020. if (i <= Currpage*16&&i>(Currpage-1)*16)
  3021. {
  3022. pageData.menuList.Add(new FileDirectoryModel()
  3023. {
  3024. SerialNumber = i,
  3025. VideoName = Common.system.FileToolsCommon.GetIOFileName(videoinfo.VideoPath).Replace(".MP4", "").Replace(".FLV", "").Replace(".AVI", "").Trim(),
  3026. Name = Common.system.FileToolsCommon.GetIOFileName(videoinfo.VideoPath).Replace(".MP4", "").Replace(".FLV", "").Replace(".AVI", "").Trim(),
  3027. FilePath = videoinfo.VideoPath.Replace(FileToolsCommon.GetIOFileName(videoinfo.VideoPath), "").Trim(),
  3028. VideoDuration = 0,
  3029. VideoSize = videoinfo.VideoSize,
  3030. VideoTime = videoinfo.RSTime,
  3031. IsEnabled = false,
  3032. Path = videoinfo.VideoPath,
  3033. Colour = colour,
  3034. Visi = vis,
  3035. Coll = cos,
  3036. FileGuid = videoinfo.FileGuid,
  3037. VideoType = videoinfo.VideoType.ToString()
  3038. }); ;
  3039. }
  3040. i++;
  3041. }
  3042. APP.myloading.Hide();
  3043. }
  3044. }
  3045. #endregion
  3046. }
  3047. }