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

XHMicroLessonSystemWindow.xaml.cs 114KB

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