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

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721
  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. namespace XHWK.WKTool
  23. {
  24. /// <summary>
  25. /// 主页面
  26. /// </summary>
  27. public partial class XHMicroLessonSystemWindow : Window
  28. {
  29. #region 字段
  30. /// <summary>
  31. /// 文件目录窗口
  32. /// </summary>
  33. //private CountdownWindow FileDirectoryWindows = null;
  34. private FolderBrowserDialog Ofd;
  35. private DialogResult Result;
  36. public readonly BlackboardNew myblackboard;
  37. private System.Windows.Forms.DialogResult result;
  38. private System.Windows.Forms.OpenFileDialog ofd;
  39. //声明一个 DrawingAttributes 类型的变量
  40. DrawingAttributes drawingAttributes;
  41. Model_Video VideoInfo = null;
  42. //定义事件
  43. public event ChangeTextHandler ChangeTextEvent;
  44. //定义委托
  45. public delegate void ChangeTextHandler(string text);
  46. /// <summary>
  47. /// 图片
  48. /// </summary>
  49. string [] ImgPDFPath = new string[300];
  50. #endregion
  51. #region 初始化
  52. /// <summary>
  53. /// 主页面
  54. /// </summary>
  55. public XHMicroLessonSystemWindow()
  56. {
  57. 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=")));
  58. InitializeComponent();
  59. myblackboard = new BlackboardNew(blackboard_canvas);
  60. APP.pageData.pagenum = 1;
  61. APP.pageData.currpage = 1;
  62. DataContext = APP.pageData;
  63. txbStoragePath.Content = FileToolsCommon.GetConfigValue("VideoType");
  64. if (FileToolsCommon.GetConfigValue("IsSound").Equals("true"))
  65. {
  66. rbnY.IsChecked = true;
  67. }
  68. else
  69. {
  70. rbnN.IsChecked = true;
  71. }
  72. txbStoragePath.Content = FileToolsCommon.GetConfigValue("VideoSavePath");
  73. Initialize();
  74. InitPen();
  75. }
  76. /// <summary>
  77. /// 初始化
  78. /// </summary>
  79. public void Initialize()
  80. {
  81. //创建 DrawingAttributes 类的一个实例
  82. drawingAttributes = new DrawingAttributes();
  83. //将 InkCanvas 的 DefaultDrawingAttributes 属性的值赋成创建的 DrawingAttributes 类的对象的引用
  84. //InkCanvas 通过 DefaultDrawingAttributes 属性来获取墨迹的各种设置,该属性的类型为 DrawingAttributes 型
  85. blackboard_canvas.DefaultDrawingAttributes = drawingAttributes;
  86. blackboard_canvas.UseCustomCursor = true;
  87. drawingAttributes.FitToCurve = true;
  88. drawingAttributes.IgnorePressure = false;
  89. blackboard_canvas.Cursor = System.Windows.Input.Cursors.Pen;
  90. //wfhCamera.Visibility = Visibility.Hidden;
  91. ImgPDFPath = null;
  92. ImgPDFPath = new string[300];
  93. }
  94. #endregion
  95. #region 事件
  96. /// <summary>
  97. /// 窗体移动
  98. /// </summary>
  99. /// <param name="sender"></param>
  100. /// <param name="e"></param>
  101. private void Window_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
  102. {
  103. DragMove();
  104. }
  105. #region 摄像头
  106. System.Timers.Timer times;
  107. List<string> RbnOpen;
  108. bool IsRbnOpen = false;
  109. /// <summary>
  110. /// 摄像头打开事件
  111. /// </summary>
  112. /// <param name="sender"></param>
  113. /// <param name="e"></param>
  114. private void RbnOpen_Click(object sender, RoutedEventArgs e)
  115. {
  116. //UCCamera win = new UCCamera();
  117. ////win.Topmost = true;
  118. //win.ShowDialog();
  119. //wfhCamera.Visibility = Visibility.Visible;
  120. //CameraHelper.IsDisplay = true;
  121. //CameraHelper.SourcePlayer = player;
  122. CameraHelper.UpdateCameraDevices();
  123. if (CameraHelper.CameraDevices.Count > 0)
  124. {
  125. CameraHelper.SetCameraDevice(0);
  126. imgPlayer.Visibility = Visibility.Visible;
  127. RbnOpen = new List<string>();
  128. times = new System.Timers.Timer(200);//设置执行一次(false)还是一直执行(true)
  129. times.AutoReset = true;//设置是否执行System.Timers.Timer.Elapsed事件
  130. times.Elapsed += new System.Timers.ElapsedEventHandler(Times_Elapsed);
  131. times.Enabled = true; //启动计时器
  132. IsRbnOpen = true;
  133. }
  134. }
  135. int I = 9999;
  136. private void Times_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
  137. {
  138. if (IsRbnOpen)
  139. {
  140. try
  141. {
  142. Dispatcher.Invoke(() =>
  143. {
  144. if(I>10010)
  145. {
  146. long time = Timestamp();
  147. //string FilePathName = ImgPath + RsImgName.Count + ".png";
  148. string path = CameraHelper.CaptureImage(@"G:\103", time.ToString());
  149. if (!string.IsNullOrWhiteSpace(path))
  150. {
  151. RbnOpen.Add(path);
  152. imgPlayer.Source = new BitmapImage(new Uri(path));
  153. }
  154. }
  155. I++;
  156. });
  157. }
  158. catch (Exception ex)
  159. {
  160. LogHelper.WriteErrLog("【摄像】(Times_Elapsed)生成图片错误:" + ex.Message, ex);
  161. }
  162. }
  163. }
  164. /// <summary>
  165. /// 摄像头关闭事件
  166. /// </summary>
  167. /// <param name="sender"></param>
  168. /// <param name="e"></param>
  169. private void RbnTurnOff_Click(object sender, RoutedEventArgs e)
  170. {
  171. IsRbnOpen = false;
  172. imgPlayer.Visibility = Visibility.Hidden;
  173. CameraHelper.CloseDevice();
  174. I = 9999;
  175. }
  176. #endregion
  177. #endregion
  178. /// <summary>
  179. /// 录屏事件
  180. /// </summary>
  181. /// <param name="sender"></param>
  182. /// <param name="e"></param>
  183. private void BtnScreenRecording_Click(object sender, RoutedEventArgs e)
  184. {
  185. if (APP.IsLoginType == false)
  186. {
  187. Login();
  188. return;
  189. }
  190. if (APP.W_ScreenRecordingToolbarWindow == null)
  191. {
  192. APP.W_ScreenRecordingToolbarWindow = new ScreenRecordingToolbarWindow
  193. {
  194. Topmost = true
  195. };
  196. APP.W_ScreenRecordingToolbarWindow.Initialize();
  197. }
  198. else
  199. {
  200. APP.W_ScreenRecordingToolbarWindow.Initialize();
  201. }
  202. //显示在右下角
  203. APP.W_ScreenRecordingToolbarWindow.Left = PrimaryScreen.DESKTOP.Width - APP.W_ScreenRecordingToolbarWindow.Width - 10;
  204. APP.W_ScreenRecordingToolbarWindow.Top = PrimaryScreen.DESKTOP.Height - APP.W_ScreenRecordingToolbarWindow.Height - 160;
  205. APP.W_ScreenRecordingToolbarWindow.Topmost = true;
  206. APP.W_ScreenRecordingToolbarWindow.Show();
  207. Hide();
  208. }
  209. /// <summary>
  210. /// 上传事件
  211. /// </summary>
  212. /// <param name="sender"></param>
  213. /// <param name="e"></param>
  214. private void BtnUpload_Click(object sender, RoutedEventArgs e)
  215. {
  216. if (APP.IsLoginType == false)
  217. {
  218. Login();
  219. return;
  220. }
  221. FileDirectoryWindow fileDirectoryWindow = new FileDirectoryWindow();
  222. fileDirectoryWindow.Show();
  223. }
  224. /// <summary>
  225. /// 关闭事件
  226. /// </summary>
  227. /// <param name="sender"></param>
  228. /// <param name="e"></param>
  229. private void BtnDown_Click(object sender, RoutedEventArgs e)
  230. {
  231. if (IsFirstR)
  232. {
  233. APP.Killffmpeg();
  234. APP.SaveWkData();
  235. APP.SaveDraw();
  236. Thread.Sleep(100);
  237. System.Environment.Exit(0);
  238. }
  239. else
  240. {
  241. MessageBoxResult dr = System.Windows.MessageBox.Show("当前正在录制,是否停止录制?", "提示", MessageBoxButton.OKCancel);
  242. if (dr == MessageBoxResult.OK)
  243. {
  244. APP.SaveWkData();
  245. APP.SaveDraw();
  246. BtnStop_Click(null, null);
  247. while (!IsFirstR)
  248. {
  249. Thread.Sleep(100);
  250. }
  251. System.Environment.Exit(0);
  252. }
  253. else
  254. {
  255. return;
  256. }
  257. }
  258. }
  259. /// <summary>
  260. /// 设置 保存事件
  261. /// </summary>
  262. /// <param name="sender"></param>
  263. /// <param name="e"></param>
  264. private void BtnSave_Click(object sender, RoutedEventArgs e)
  265. {
  266. //#region 合法性判断
  267. //if (string.IsNullOrWhiteSpace(txbStoragePath.Text.Trim()))
  268. //{
  269. // System.Windows.MessageBox.Show("路径不可为空!");
  270. // return;
  271. //}
  272. //string temp = FileToolsCommon.GetLegalPath(txbStoragePath.Text) + APP.WKData.WkName.Trim() + "/";
  273. //if (!APP.WKData.WkPath.Equals(temp))
  274. //{
  275. // APP.WKData.WkPath = FileToolsCommon.GetLegalPath(txbStoragePath.Text) + APP.WKData.WkName.Trim() + "/";
  276. // if (FileToolsCommon.IsExistDirectory(APP.WKData.WkPath))
  277. // {
  278. // //微课已存在
  279. // MessageBoxResult dr = System.Windows.MessageBox.Show("讲解已存在是否覆盖?", "提示", MessageBoxButton.OKCancel);
  280. // if (dr == MessageBoxResult.OK)
  281. // {
  282. // FileToolsCommon.DeleteDirectory(APP.WKData.WkPath);
  283. // }
  284. // else
  285. // {
  286. // return;
  287. // }
  288. // }
  289. // //创建文件夹
  290. // FileToolsCommon.CreateDirectory(APP.WKData.WkPath);
  291. //}
  292. //#endregion
  293. if (rbnMP4.IsChecked == true)
  294. {
  295. //存储文件
  296. FileToolsCommon.SetConfigValue("VideoType", "1");
  297. }
  298. else if (rbnFLV.IsChecked == true)
  299. {
  300. FileToolsCommon.SetConfigValue("VideoType", "2");
  301. }
  302. else
  303. {
  304. FileToolsCommon.SetConfigValue("VideoType", "3");
  305. }
  306. if (rbnY.IsChecked == true)
  307. {
  308. FileToolsCommon.SetConfigValue("IsSound", "true");
  309. }
  310. else
  311. {
  312. FileToolsCommon.SetConfigValue("IsSound", "false");
  313. }
  314. GridMain.Visibility = Visibility.Visible;
  315. gridSetUp.Visibility = Visibility.Collapsed;
  316. }
  317. /// <summary>
  318. /// 设置事件
  319. /// </summary>
  320. /// <param name="sender"></param>
  321. /// <param name="e"></param>
  322. private void BtnSetUp_Click(object sender, RoutedEventArgs e)
  323. {
  324. GridMain.Visibility = Visibility.Collapsed;
  325. gridSetUp.Visibility = Visibility.Visible;
  326. txbStoragePath.Content = APP.WKData.WkPath;
  327. }
  328. /// <summary>
  329. /// 设置 浏览事件
  330. /// </summary>
  331. /// <param name="sender"></param>
  332. /// <param name="e"></param>
  333. private void BtnBrowse_Click(object sender, RoutedEventArgs e)
  334. {
  335. System.Diagnostics.Process.Start(APP.WKData.WkPath);
  336. //string desktopPath = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
  337. //Ofd = new System.Windows.Forms.FolderBrowserDialog();
  338. //Result = Ofd.ShowDialog();
  339. //if (Result == System.Windows.Forms.DialogResult.OK)
  340. //{
  341. // if (Ofd.SelectedPath != "")
  342. // {
  343. // //txbStoragePath.Text = Ofd.SelectedPath;
  344. // //string ApplicationData = ZConfig.dataPath + "fileStorageAddress.txt";
  345. // //string temp = ofd.SelectedPath;
  346. // //System.IO.File.WriteAllText(ApplicationData, temp, Encoding.Default);
  347. // }
  348. //}
  349. }
  350. /// <summary>
  351. /// 画笔颜色事件 白色
  352. /// </summary>
  353. /// <param name="sender"></param>
  354. /// <param name="e"></param>
  355. private void BtnWhite_Click(object sender, RoutedEventArgs e)
  356. {
  357. ////创建 DrawingAttributes 类的一个实例
  358. //drawingAttributes = new DrawingAttributes();
  359. ////将 InkCanvas 的 DefaultDrawingAttributes 属性的值赋成创建的 DrawingAttributes 类的对象的引用
  360. ////InkCanvas 通过 DefaultDrawingAttributes 属性来获取墨迹的各种设置,该属性的类型为 DrawingAttributes 型
  361. //blackboard_canvas.DefaultDrawingAttributes = drawingAttributes;
  362. ////设置 DrawingAttributes 的 Color 属性设置颜色
  363. drawingAttributes.Color = Colors.White;
  364. }
  365. /// <summary>
  366. /// 画笔颜色事件 红色
  367. /// </summary>
  368. /// <param name="sender"></param>
  369. /// <param name="e"></param>
  370. private void BtnRed_Click(object sender, RoutedEventArgs e)
  371. {
  372. //设置 DrawingAttributes 的 Color 属性设置颜色
  373. drawingAttributes.Color = Colors.Red;
  374. }
  375. /// <summary>
  376. /// 画笔颜色事件 灰色
  377. /// </summary>
  378. /// <param name="sender"></param>
  379. /// <param name="e"></param>
  380. private void BtnGray_Click(object sender, RoutedEventArgs e)
  381. {
  382. drawingAttributes.Color = Colors.Gray;
  383. }
  384. /// <summary>
  385. /// 画笔颜色事件 青色
  386. /// </summary>
  387. /// <param name="sender"></param>
  388. /// <param name="e"></param>
  389. private void BtnCyanBlue_Click(object sender, RoutedEventArgs e)
  390. {
  391. drawingAttributes.Color = Colors.LimeGreen;
  392. }
  393. /// <summary>
  394. /// 画笔颜色事件 黄色
  395. /// </summary>
  396. /// <param name="sender"></param>
  397. /// <param name="e"></param>
  398. private void BtnYellow_Click(object sender, RoutedEventArgs e)
  399. {
  400. drawingAttributes.Color = Colors.Gold;
  401. }
  402. /// <summary>
  403. /// 画笔颜色事件 蓝色
  404. /// </summary>
  405. /// <param name="sender"></param>
  406. /// <param name="e"></param>
  407. private void BtnBlue_Click(object sender, RoutedEventArgs e)
  408. {
  409. drawingAttributes.Color = Colors.DeepSkyBlue;
  410. }
  411. /// <summary>
  412. /// 画笔粗细事件 细
  413. /// </summary>
  414. /// <param name="sender"></param>
  415. /// <param name="e"></param>
  416. private void RbnFine_Click(object sender, RoutedEventArgs e)
  417. {
  418. drawingAttributes.Width = 1;
  419. drawingAttributes.Height = 1;
  420. }
  421. /// <summary>
  422. /// 画笔粗细事件 中
  423. /// </summary>
  424. /// <param name="sender"></param>
  425. /// <param name="e"></param>
  426. private void RbnIn_Click(object sender, RoutedEventArgs e)
  427. {
  428. drawingAttributes.Width = 3;
  429. drawingAttributes.Height = 3;
  430. }
  431. /// <summary>
  432. /// 画笔粗细事件 粗
  433. /// </summary>
  434. /// <param name="sender"></param>
  435. /// <param name="e"></param>
  436. private void RbnCrude_Click(object sender, RoutedEventArgs e)
  437. {
  438. drawingAttributes.Width = 5;
  439. drawingAttributes.Height = 5;
  440. }
  441. /// <summary>
  442. /// 登陆事件
  443. /// </summary>
  444. /// <param name="sender"></param>
  445. /// <param name="e"></param>
  446. private void BtnLoginType_Click(object sender, RoutedEventArgs e)
  447. {
  448. Login();
  449. }
  450. /// <summary>
  451. /// 登陆
  452. /// </summary>
  453. private void Login()
  454. {
  455. if (APP.W_LoginWindow == null)
  456. {
  457. APP.W_LoginWindow = new LoginWindow();
  458. }
  459. else
  460. {
  461. APP.W_LoginWindow.Initialize();
  462. }
  463. APP.W_LoginWindow.ShowDialog();
  464. if (APP.IsLoginType)
  465. {
  466. txbLoginType.Text = APP.UserInfo.Username;
  467. }
  468. else
  469. {
  470. txbLoginType.Text = "未登录";
  471. }
  472. }
  473. /// <summary>
  474. /// 截图事件
  475. /// </summary>
  476. /// <param name="sender"></param>
  477. /// <param name="e"></param>
  478. private void BtnScreenshot_Click(object sender, RoutedEventArgs e)
  479. {
  480. if (APP.IsLoginType == false)
  481. {
  482. Login();
  483. return;
  484. }
  485. string time = GetTimeStamp();
  486. string desktopPath = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory) + time + ".jpg";
  487. ImageHelper.GetScreenshot(new System.Drawing.Rectangle(0, 0, 0, 0), desktopPath);
  488. if (APP.W_JieTuWindow != null)
  489. {
  490. APP.W_JieTuWindow.initialization();
  491. APP.W_JieTuWindow.Screenshot();
  492. APP.W_JieTuWindow.WindowState = WindowState.Maximized;
  493. APP.W_JieTuWindow.Visibility = Visibility.Visible;
  494. }
  495. else
  496. {
  497. APP.W_JieTuWindow = new JieTuWindow();
  498. // 订阅事件
  499. APP.W_JieTuWindow.ChangeTextEvent += new ChangeTextHandler(frm_ChangeTextEvent);
  500. APP.W_JieTuWindow.click_closeJietuWindowClick += JietuWindow_click_closeJietuWindowClick;
  501. APP.W_JieTuWindow.Show();
  502. }
  503. //imgCanvas.Source = new BitmapImage(new Uri(desktopPath));
  504. }
  505. /// <summary>
  506. /// 截图关闭窗口
  507. /// </summary>
  508. /// <param name="text"></param>
  509. private void frm_ChangeTextEvent(string text)
  510. {
  511. if ("关闭窗口".Equals(text))
  512. {
  513. if(!string.IsNullOrWhiteSpace(APP.ImgPath)&&File.Exists(APP.ImgPath))
  514. {
  515. APP.JPaths[APP.pageData.currpage]= APP.ImgPath;
  516. if(!string.IsNullOrWhiteSpace(APP.JPaths[APP.pageData.currpage]))
  517. {
  518. imgCanvas.Source = new BitmapImage(new Uri(APP.JPaths[APP.pageData.currpage]));
  519. }
  520. }
  521. }
  522. }
  523. /// <summary>
  524. /// 截图关闭 非正常关闭截图时,截图清空
  525. /// </summary>
  526. private void JietuWindow_click_closeJietuWindowClick()
  527. {
  528. APP.W_JieTuWindow = null;
  529. }
  530. /// <summary>
  531. /// 获取时间戳
  532. /// </summary>
  533. /// <returns></returns>
  534. public string GetTimeStamp()
  535. {
  536. TimeSpan ts = DateTime.Now - new DateTime(1970, 1, 1, 0, 0, 0, 0);
  537. return Convert.ToInt64(ts.TotalSeconds).ToString();
  538. }
  539. /// <summary>
  540. /// 导入事件
  541. /// </summary>
  542. /// <param name="sender"></param>
  543. /// <param name="e"></param>
  544. private void BtnImport_Click(object sender, RoutedEventArgs e)
  545. {
  546. if (APP.IsLoginType == false)
  547. {
  548. Login();
  549. return;
  550. }
  551. try
  552. {
  553. string desktopPath = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
  554. ofd = new System.Windows.Forms.OpenFileDialog
  555. {
  556. Filter = "文档|*.docx;*.doc;*ppt",
  557. InitialDirectory = desktopPath,
  558. Multiselect = false,
  559. AddExtension = true,
  560. DereferenceLinks = true
  561. };
  562. new Thread(
  563. o =>
  564. {
  565. Thread.Sleep(400);
  566. Dispatcher.Invoke(new Action(() =>
  567. {
  568. OpenDialog();
  569. }
  570. ));
  571. })
  572. {
  573. IsBackground = true
  574. }.Start();
  575. }
  576. catch (Exception ex)
  577. {
  578. LogHelper.WriteErrLog("【导入(BtnImport_Click)" + ex.Message, ex);
  579. }
  580. }
  581. private void OpenDialog()
  582. {
  583. result = ofd.ShowDialog();
  584. if (result == System.Windows.Forms.DialogResult.OK)
  585. {
  586. if (ofd.FileName != "")
  587. {
  588. #region PPT转PDF
  589. string filepath = ofd.FileName;
  590. string path = ofd.SafeFileName.Replace(".ppt", "").Trim();
  591. string type = ofd.SafeFileName.Replace(".ppt", "typezsygppt").Trim();
  592. if (type.Contains("typezsygppt"))
  593. {
  594. try
  595. {
  596. string pathTemp = AppDomain.CurrentDomain.BaseDirectory + "Temp\\";
  597. path = pathTemp + path + ".pdf";
  598. //PPT转PDF
  599. Presentation ppt = new Presentation(filepath);
  600. ppt.Save(path, Aspose.Slides.Export.SaveFormat.Pdf);
  601. #endregion
  602. #region PDF转图片
  603. // 图片绝对路径集合
  604. List<string> images = new List<string>();
  605. string directoryPath = pathTemp;
  606. //aspose许可证
  607. //Aspose.Pdf.License l = new Aspose.Pdf.License();
  608. //string licenseName = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Aspose.Total.Product.Family.lic");
  609. //l.SetLicense(licenseName);
  610. //定义Jpeg转换设备
  611. Aspose.Pdf.Document document = new Aspose.Pdf.Document(path);
  612. var device = new Aspose.Pdf.Devices.JpegDevice();
  613. //int quality = int.Parse(this.comboBox1.SelectedItem.ToString());
  614. //directoryPath += quality;
  615. Directory.CreateDirectory(directoryPath);
  616. //默认质量为100,设置质量的好坏与处理速度不成正比,甚至是设置的质量越低反而花的时间越长,怀疑处理过程是先生成高质量的再压缩
  617. device = new Aspose.Pdf.Devices.JpegDevice(100);
  618. //遍历每一页转为jpg
  619. for (var i = 1; i <= document.Pages.Count; i++)
  620. {
  621. long ii = Timestamp();
  622. string filePathOutPut = Path.Combine(directoryPath, string.Format("{0}{1}.jpg", ii, i));
  623. images.Add(filePathOutPut);
  624. FileStream fs = new FileStream(filePathOutPut, FileMode.OpenOrCreate);
  625. try
  626. {
  627. device.Process(document.Pages[i], fs);
  628. fs.Close();
  629. }
  630. catch (Exception ex)
  631. {
  632. fs.Close();
  633. File.Delete(filePathOutPut);
  634. }
  635. }
  636. #endregion
  637. APP.Paths = images.ToArray();
  638. ImgPDFPath = images.ToArray();
  639. for (int i = 0; i < APP.Paths.Length; i++)
  640. {
  641. APP.pageData.pagenum += 1;
  642. }
  643. if (APP.pageData.pagenum > 1)
  644. {
  645. APP.pageData.pagenum -= 1;
  646. }
  647. if (!string.IsNullOrWhiteSpace(txbCurrpage.Text) && APP.pageData.currpage < APP.Paths.Length)
  648. {
  649. imgCanvas.Source = new BitmapImage(new Uri(APP.Paths[APP.pageData.currpage - 1]));
  650. }
  651. else
  652. {
  653. imgCanvas.Source = null;
  654. }
  655. }
  656. catch (Exception ex)
  657. {
  658. LogHelper.WriteErrLog("【XHMicroLessonSystemWindow】(OpenDialog PPT)" + ex.Message, ex);
  659. }
  660. }
  661. else
  662. {
  663. try
  664. {
  665. string paths = AppDomain.CurrentDomain.BaseDirectory + "Temp\\";
  666. APP.Paths = ConvertWordToImage(filepath, paths, "", 0, 0, null, 0).ToArray();
  667. for (int i = 0; i < APP.Paths.Length; i++)
  668. {
  669. APP.pageData.pagenum += 1;
  670. }
  671. if (APP.pageData.pagenum > 1)
  672. {
  673. APP.pageData.pagenum -= 1;
  674. }
  675. if (!string.IsNullOrWhiteSpace(txbCurrpage.Text) && APP.pageData.currpage < APP.Paths.Length)
  676. {
  677. imgCanvas.Source = new BitmapImage(new Uri(APP.Paths[APP.pageData.currpage - 1]));
  678. }
  679. else
  680. {
  681. imgCanvas.Source = null;
  682. }
  683. }
  684. catch (Exception ex)
  685. {
  686. LogHelper.WriteErrLog("【XHMicroLessonSystemWindow】(OpenDialog PDF)" + ex.Message, ex);
  687. }
  688. }
  689. }
  690. }
  691. }
  692. /// <summary>
  693. /// 返回一个时间戳到毫秒
  694. /// </summary>
  695. /// <returns></returns>
  696. public static long Timestamp()
  697. {
  698. TimeSpan ts = DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0);
  699. long timestr = Convert.ToInt64(ts.TotalMilliseconds);
  700. return timestr;
  701. }
  702. #region 录制窗口
  703. #region 变量
  704. /// <summary>
  705. /// 视频保存路径
  706. /// </summary>
  707. string RecordingPath;
  708. /// <summary>
  709. /// 图片保存路径
  710. /// </summary>
  711. string ImgPath;
  712. /// <summary>
  713. /// 音频保存路径名
  714. /// </summary>
  715. string AudioPathName;
  716. /// <summary>
  717. /// 视频保存路径名
  718. /// </summary>
  719. string VideoSavePathName;
  720. /// <summary>
  721. /// 暂停录制
  722. /// </summary>
  723. bool IsSuspendR = true;
  724. /// <summary>
  725. /// 录制是否已停止
  726. /// </summary>
  727. bool IsFirstR = true;
  728. /// <summary>
  729. /// 图片
  730. /// </summary>
  731. List<string> RsImgName = null;
  732. /// <summary>
  733. /// 是否开始截图计数
  734. /// </summary>
  735. bool IsStartCount = false;
  736. #endregion
  737. /// <summary>
  738. /// 录制窗口内容
  739. /// </summary>
  740. /// <param name="sender"></param>
  741. /// <param name="e"></param>
  742. private void BtnRecord_Click(object sender, RoutedEventArgs e)
  743. {
  744. if (APP.IsLoginType == false)
  745. {
  746. Login();
  747. return;
  748. }
  749. blackboard_canvas.Visibility = Visibility.Visible;
  750. StartRecord();
  751. }
  752. /// <summary>
  753. /// 停止录制窗口内容
  754. /// </summary>
  755. /// <param name="sender"></param>
  756. /// <param name="e"></param>
  757. private void BtnStop_Click(object sender, RoutedEventArgs e)
  758. {
  759. if (APP.IsLoginType == false)
  760. {
  761. Login();
  762. return;
  763. }
  764. blackboard_canvas.Visibility = Visibility.Collapsed;
  765. EndRecord();
  766. }
  767. System.Timers.Timer timer;
  768. /// <summary>
  769. /// 开始录制和暂停录制
  770. /// </summary>
  771. void StartRecord()
  772. {
  773. if (IsSuspendR)
  774. {
  775. if (IsFirstR)//是否第一次录制 初始化录制
  776. {
  777. VideoInfo = new Model_Video();
  778. VideoInfo.VideoType = (Enum_VideoType)int.Parse(FileToolsCommon.GetConfigValue("VideoType"));
  779. VideoInfo.WkType = Enum_WKVidetype.RecordingLessons;
  780. RecordingPath = APP.WKData.WkPath;
  781. ImgPath = APP.WKData.WkPath + "temp/Image/";
  782. AudioPathName = APP.WKData.WkPath + "temp/audio/";
  783. FileToolsCommon.DeleteDirectory(APP.WKData.WkPath + "temp/");
  784. FileToolsCommon.CreateDirectory(RecordingPath);
  785. FileToolsCommon.CreateDirectory(ImgPath);
  786. FileToolsCommon.CreateDirectory(AudioPathName);
  787. AudioPathName += APP.WKData.WkName + ".MP3";
  788. VideoSavePathName = RecordingPath + APP.WKData.WkName + "_录制." + VideoInfo.VideoType.ToString();
  789. if (FileToolsCommon.IsExistFile(VideoSavePathName))
  790. {
  791. MessageBoxResult dr = System.Windows.MessageBox.Show("课程已录制,是否覆盖?", "提示", MessageBoxButton.OKCancel);
  792. if (dr == MessageBoxResult.OK)
  793. {
  794. try
  795. {
  796. FileToolsCommon.DeleteFile(VideoSavePathName);
  797. APP.VideoList.RemoveAll(x => x.VidePath == VideoSavePathName);
  798. }
  799. catch (Exception ex)
  800. {
  801. LogHelper.WriteErrLog("【录制】(StartRecord)无法移除视频," + ex.Message, ex);
  802. }
  803. }
  804. else
  805. {
  806. return;
  807. }
  808. }
  809. IsFirstR = false;
  810. RsImgName = new List<string>();
  811. timer = new System.Timers.Timer(200);//设置执行一次(false)还是一直执行(true)
  812. timer.AutoReset = true;//设置是否执行System.Timers.Timer.Elapsed事件
  813. timer.Elapsed += new System.Timers.ElapsedEventHandler(Timer_Elapsed);
  814. timer.Enabled = true; //启动计时器
  815. }
  816. #region 录像倒计时
  817. if (APP.W_CountdownWindow == null)
  818. {
  819. APP.W_CountdownWindow = new CountdownWindow();
  820. //APP.W_CountdownWindow.Topmost = true;
  821. }
  822. else
  823. {
  824. APP.W_CountdownWindow.Initialize();
  825. APP.W_CountdownWindow.Topmost = true;
  826. }
  827. APP.W_CountdownWindow.Show();
  828. #endregion
  829. //继续录制
  830. IsSuspendR = false;
  831. //BtnRecording.Content = "暂停录制";
  832. ImgRecord.Source = new BitmapImage(new Uri("pack://application:,,,/Images/microLessonSystem_23.png"));
  833. TxbRecordingWord.Text = "暂停";
  834. try
  835. {
  836. APP.FFmpeg.StartRecordingAudio(AudioPathName);
  837. new Thread(new ThreadStart(new Action(() =>
  838. {
  839. Thread.Sleep(1000);
  840. Dispatcher.Invoke(() =>
  841. {
  842. IsStartCount = true;
  843. //timer.Start();
  844. });
  845. }))).Start();
  846. }
  847. catch (Exception ex)
  848. {
  849. System.Windows.MessageBox.Show(ex.Message);
  850. }
  851. }
  852. else
  853. {
  854. //暂停
  855. IsSuspendR = true;
  856. ImgRecord.Source = new BitmapImage(new Uri("pack://application:,,,/Images/microLessonSystem_14.png"));
  857. TxbRecordingWord.Text = "继续";
  858. try
  859. {
  860. APP.FFmpeg.SuspendFFmpeg();
  861. new Thread(new ThreadStart(new Action(() =>
  862. {
  863. while (APP.FFmpeg.myProcess != null)
  864. {
  865. Thread.Sleep(100);
  866. }
  867. IsStartCount = false;
  868. }))).Start();
  869. }
  870. catch (Exception ex)
  871. {
  872. System.Windows.MessageBox.Show(ex.Message);
  873. }
  874. }
  875. }
  876. /// <summary>
  877. /// 录制保存图片
  878. /// </summary>
  879. /// <param name="sender"></param>
  880. /// <param name="e"></param>
  881. private void Timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
  882. {
  883. if (IsStartCount)
  884. {
  885. try
  886. {
  887. Dispatcher.Invoke(() =>
  888. {
  889. string FilePathName = ImgPath + RsImgName.Count + ".png";
  890. ImageHelper.SaveUIToImage(GridMain, FilePathName, (int)this.ActualWidth, (int)this.ActualHeight);
  891. RsImgName.Add(FilePathName);
  892. });
  893. }
  894. catch (Exception ex)
  895. {
  896. LogHelper.WriteErrLog("【录制】(Timer_Elapsed)生成图片错误:" + ex.Message, ex);
  897. }
  898. }
  899. }
  900. /// <summary>
  901. /// 停止录制并生成录制文件
  902. /// </summary>
  903. void EndRecord()
  904. {
  905. if (!IsFirstR)
  906. {
  907. IsSuspendR = true;
  908. ImgRecord.Source = new BitmapImage(new Uri("pack://application:,,,/Images/microLessonSystem_14.png"));
  909. TxbRecordingWord.Text = "录制";
  910. try
  911. {
  912. APP.FFmpeg.StopFFmpeg(AudioPathName);
  913. new Thread(new ThreadStart(new Action(() =>
  914. {
  915. while (APP.FFmpeg.myProcess != null)
  916. {
  917. Thread.Sleep(100);
  918. }
  919. Dispatcher.Invoke(() =>
  920. {
  921. IsStartCount = false;
  922. timer.Stop();
  923. });
  924. }))).Start();
  925. new Thread(new ThreadStart(new Action(() =>
  926. {
  927. while (APP.FFmpeg.myProcess != null)
  928. {
  929. Thread.Sleep(100);
  930. }
  931. }))).Start();
  932. APP.FFmpeg.SynthesisVideo(ImgPath, AudioPathName, VideoSavePathName, 5, (int)GridMain.Width, (int)GridMain.Height);
  933. //生成缩略图
  934. string ThumbnailPath = FileToolsCommon.GetDirectoryName(VideoSavePathName) + "ThumbnailPath/";
  935. FileToolsCommon.CreateDirectory(ThumbnailPath);
  936. //缩略图存储位置
  937. string ThumbnailPathName = ThumbnailPath + FileToolsCommon.GetIOFileNameNoExtension(VideoSavePathName) + ".JPG";
  938. new Thread(new ThreadStart(new Action(() =>
  939. {
  940. while (!FileToolsCommon.IsExistFile(VideoSavePathName))
  941. {
  942. Thread.Sleep(100);
  943. }
  944. FileToolsCommon.DeleteFile(ThumbnailPathName);
  945. VideoInfo.VideoSize = FileToolsCommon.GetFileSizeByMB(VideoSavePathName).ToString() + " MB";
  946. VideoInfo.RSTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  947. VideoInfo.VidePath = VideoSavePathName;
  948. VideoInfo.ThumbnailPath = ThumbnailPathName;
  949. APP.FFmpeg.GenerateThumbnails(VideoSavePathName, ThumbnailPathName);
  950. APP.VideoList.Add(VideoInfo);
  951. //保存数据
  952. APP.SaveWkData();
  953. IsFirstR = true;
  954. }))).Start();
  955. //List<Model_Video> VideoList
  956. }
  957. catch (Exception ex)
  958. {
  959. System.Windows.MessageBox.Show(ex.Message);
  960. }
  961. }
  962. }
  963. #endregion
  964. /// <summary>
  965. /// 增加事件
  966. /// </summary>
  967. /// <param name="sender"></param>
  968. /// <param name="e"></param>
  969. private void BtnAdd_Click(object sender, RoutedEventArgs e)
  970. {
  971. if (APP.IsLoginType == false)
  972. {
  973. Login();
  974. return;
  975. }
  976. APP.pageData.pagenum += 1;
  977. APP.pageData.currpage = APP.pageData.pagenum;
  978. myblackboard.changepage(APP.pageData.currpage - 1);
  979. imgCanvas.Source = null;
  980. }
  981. /// <summary>
  982. /// 打印事件
  983. /// </summary>
  984. /// <param name="sender"></param>
  985. /// <param name="e"></param>
  986. private void BtnPrint_Click(object sender, RoutedEventArgs e)
  987. {
  988. if (APP.IsLoginType == false)
  989. {
  990. Login();
  991. return;
  992. }
  993. //for(int i=0;i< APP.pageData.pagenum; i++)
  994. //{
  995. //}
  996. ////string[] files = { @"C:\101\1.jpg", @"C:\101\2.jpg" };
  997. iTextSharp.text.Document document = new iTextSharp.text.Document(iTextSharp.text.PageSize.A4, 25, 25, 25, 25);
  998. try
  999. {
  1000. //iTextSharp.text.Rectangle page = new iTextSharp.text.Rectangle(iTextSharp.text.PageSize.A4., 250f);//cs
  1001. //设置纸张横向
  1002. document.SetPageSize(iTextSharp.text.PageSize.A4.Rotate());
  1003. iTextSharp.text.pdf.PdfWriter.GetInstance(document, new FileStream(@"G:\101.pdf", FileMode.Create, FileAccess.ReadWrite));
  1004. document.Open();
  1005. iTextSharp.text.Image image;
  1006. for (int i = 0; i < 10/*ImgPDFPath.Length*/; i++)
  1007. {
  1008. if (String.IsNullOrEmpty(ImgPDFPath[i])) break;
  1009. image = iTextSharp.text.Image.GetInstance(ImgPDFPath[i]);
  1010. if (image.Height > iTextSharp.text.PageSize.A4.Height - 25)
  1011. {
  1012. image.ScaleToFit(iTextSharp.text.PageSize.A4.Width - 25, iTextSharp.text.PageSize.A4.Height - 25);
  1013. }
  1014. else if (image.Width > iTextSharp.text.PageSize.A4.Width - 25)
  1015. {
  1016. image.ScaleToFit(iTextSharp.text.PageSize.A4.Width - 25, iTextSharp.text.PageSize.A4.Height - 25);
  1017. }
  1018. image.Alignment = iTextSharp.text.Image.ALIGN_MIDDLE;
  1019. document.NewPage();
  1020. document.Add(image);
  1021. //iTextSharp.text.Chunk c1 = new iTextSharp.text.Chunk("Hello World");
  1022. //iTextSharp.text.Phrase p1 = new iTextSharp.text.Phrase();
  1023. //p1.Leading = 150; //行间距
  1024. //document.Add(p1);
  1025. }
  1026. Console.WriteLine("转换成功!");
  1027. document.Close();
  1028. }
  1029. catch (Exception ex)
  1030. {
  1031. Console.WriteLine("转换失败,原因:" + ex.Message);
  1032. }
  1033. //document.Close();
  1034. ////Console.ReadKey();
  1035. int pr = 1;
  1036. string msg = string.Empty;
  1037. string outPut = string.Empty;
  1038. LatticeFileHelper.GeneratingPDF(@"G:\101.pdf", @"G:\102.TPF",out pr, out msg, out outPut);
  1039. if(pr==0)
  1040. {
  1041. outPut = outPut.Replace("[", "").Replace("]","").Replace("\"","").Trim();
  1042. APP.OutPut = outPut.Split(',');
  1043. string defa = string.Empty;
  1044. List<string>defaList= LatticeFileHelper.GetPrinterList(out defa);
  1045. int printResult = 1;
  1046. string standardError = string.Empty;
  1047. string standardOutput = string.Empty;
  1048. LatticeFileHelper.PrinterTPFFile(@"G:\102.TPF",1, /*defa*/"导出为WPS PDF", out printResult,out standardError,out standardOutput);
  1049. }
  1050. }
  1051. /// <summary>
  1052. /// 我的
  1053. /// </summary>
  1054. /// <param name="sender"></param>
  1055. /// <param name="e"></param>
  1056. private void BtnMyMine_Click(object sender, RoutedEventArgs e)
  1057. {
  1058. if (APP.IsLoginType == false)
  1059. {
  1060. Login();
  1061. return;
  1062. }
  1063. }
  1064. /// <summary>
  1065. /// 上一页
  1066. /// </summary>
  1067. /// <param name="sender"></param>
  1068. /// <param name="e"></param>
  1069. private void last_button_Click(object sender, RoutedEventArgs e)
  1070. {
  1071. if (APP.pageData.currpage > 1)
  1072. {
  1073. try
  1074. {
  1075. Dispatcher.Invoke(() =>
  1076. {
  1077. string filePath = FileToolsCommon.GetFileAbsolutePath("/Data/" + APP.UserInfo.Username + "/pdfimagetemp/");
  1078. FileToolsCommon.CreateDirectory(filePath);
  1079. string filePathName = filePath + APP.pageData.currpage.ToString() + ".jpg";
  1080. ImageHelper.SaveUIToImage(GridMain, filePathName, (int)GridMain.ActualWidth, (int)GridMain.ActualHeight);
  1081. ImgPDFPath[APP.pageData.currpage - 1] = filePathName;
  1082. });
  1083. }
  1084. catch (Exception ex)
  1085. {
  1086. LogHelper.WriteErrLog("【XHMicroLessonSystemWindow】(last_button_Click)生成图片错误:" + ex.Message, ex);
  1087. }
  1088. APP.pageData.currpage -= 1;
  1089. myblackboard.changepage(APP.pageData.currpage - 1);
  1090. if (APP.Paths.Length > 0)
  1091. {
  1092. if (!string.IsNullOrWhiteSpace(txbCurrpage.Text) && APP.pageData.currpage < APP.Paths.Length&& APP.pageData.currpage > 0)
  1093. {
  1094. imgCanvas.Source = new BitmapImage(new Uri(APP.Paths[APP.pageData.currpage - 1]));
  1095. }
  1096. else
  1097. {
  1098. imgCanvas.Source = null;
  1099. }
  1100. }
  1101. if (!string.IsNullOrWhiteSpace(APP.JPaths[APP.pageData.currpage]))
  1102. {
  1103. imgCanvas.Source = new BitmapImage(new Uri(APP.JPaths[APP.pageData.currpage]));
  1104. }
  1105. }
  1106. }
  1107. /// <summary>
  1108. /// 下一页
  1109. /// </summary>
  1110. /// <param name="sender"></param>
  1111. /// <param name="e"></param>
  1112. private void next_btn_Click(object sender, RoutedEventArgs e)
  1113. {
  1114. if (APP.pageData.currpage < APP.pageData.pagenum)
  1115. {
  1116. try
  1117. {
  1118. Dispatcher.Invoke(() =>
  1119. {
  1120. string filePath = FileToolsCommon.GetFileAbsolutePath("/Data/" + APP.UserInfo.Username + "/pdfimagetemp/");
  1121. FileToolsCommon.CreateDirectory(filePath);
  1122. string filePathName = filePath + APP.pageData.currpage.ToString() + ".jpg";
  1123. ImageHelper.SaveUIToImage(GridMain, filePathName, (int)GridMain.ActualWidth, (int)GridMain.ActualHeight);
  1124. ImgPDFPath[APP.pageData.currpage - 1] = filePathName;
  1125. });
  1126. }
  1127. catch (Exception ex)
  1128. {
  1129. LogHelper.WriteErrLog("【XHMicroLessonSystemWindow】(next_btn_Click)生成图片错误:" + ex.Message, ex);
  1130. }
  1131. APP.pageData.currpage += 1;
  1132. myblackboard.changepage(APP.pageData.currpage - 1);
  1133. if (APP.Paths.Length > 0)
  1134. {
  1135. if (!string.IsNullOrWhiteSpace(txbCurrpage.Text) && APP.pageData.currpage <= APP.Paths.Length)
  1136. {
  1137. imgCanvas.Source = new BitmapImage(new Uri(APP.Paths[APP.pageData.currpage-1]));
  1138. }
  1139. else
  1140. {
  1141. imgCanvas.Source = null;
  1142. }
  1143. }
  1144. if (!string.IsNullOrWhiteSpace(APP.JPaths[APP.pageData.currpage]))
  1145. {
  1146. imgCanvas.Source = new BitmapImage(new Uri(APP.JPaths[APP.pageData.currpage]));
  1147. }
  1148. }
  1149. }
  1150. /// <summary>
  1151. /// 将Word文档转换为图片的方法(该方法基于第三方DLL),你可以像这样调用该方法: ConvertPDF2Image("F:\\PdfFile.doc", "F:\\",
  1152. /// "ImageFile", 1, 20, ImageFormat.Png, 256);
  1153. /// </summary>
  1154. /// <param name="pdfInputPath">Word文件路径</param>
  1155. /// <param name="imageOutputPath">图片输出路径,如果为空,默认值为Word所在路径</param>
  1156. /// <param name="imageName">图片的名字,不需要带扩展名,如果为空,默认值为Word的名称</param>
  1157. /// <param name="startPageNum">从PDF文档的第几页开始转换,如果为0,默认值为1</param>
  1158. /// <param name="endPageNum">从PDF文档的第几页开始停止转换,如果为0,默认值为Word总页数</param>
  1159. /// <param name="imageFormat">设置所需图片格式,如果为null,默认格式为PNG</param>
  1160. /// <param name="resolution">设置图片的像素,数字越大越清晰,如果为0,默认值为128,建议最大值不要超过1024</param>
  1161. public List<string> ConvertWordToImage(string wordInputPath, string imageOutputPath,
  1162. string imageName, int startPageNum, int endPageNum, ImageFormat imageFormat, float resolution)
  1163. {
  1164. // 返回的图片绝对路径集合
  1165. List<string> images = new List<string>();
  1166. try
  1167. {
  1168. // open word file
  1169. Aspose.Words.Document doc = new Aspose.Words.Document(wordInputPath);
  1170. // validate parameter
  1171. if (doc == null) { throw new Exception("Word文件无效或者Word文件被加密!"); }
  1172. if (imageOutputPath.Trim().Length == 0) { imageOutputPath = System.IO.Path.GetDirectoryName(wordInputPath); }
  1173. if (!Directory.Exists(imageOutputPath)) { Directory.CreateDirectory(imageOutputPath); }
  1174. if (imageName.Trim().Length == 0) { imageName = System.IO.Path.GetFileNameWithoutExtension(wordInputPath); }
  1175. if (startPageNum <= 0) { startPageNum = 1; }
  1176. if (endPageNum > doc.PageCount || endPageNum <= 0) { endPageNum = doc.PageCount; }
  1177. if (startPageNum > endPageNum) { int tempPageNum = startPageNum; startPageNum = endPageNum; endPageNum = startPageNum; }
  1178. if (imageFormat == null) { imageFormat = ImageFormat.Png; }
  1179. if (resolution <= 0) { resolution = 128; }
  1180. ImageSaveOptions imageSaveOptions = new ImageSaveOptions(GetSaveFormat(imageFormat))
  1181. {
  1182. Resolution = resolution
  1183. };
  1184. // start to convert each page
  1185. for (int i = startPageNum; i <= endPageNum; i++)
  1186. {
  1187. imageSaveOptions.PageIndex = i - 1;
  1188. doc.Save(System.IO.Path.Combine(imageOutputPath, imageName) + "_" + APP.num.ToString() + "." + imageFormat.ToString(), imageSaveOptions);
  1189. images.Add(System.IO.Path.Combine(imageOutputPath, imageName) + "_" + APP.num.ToString() + "." + imageFormat.ToString());
  1190. APP.num++;
  1191. }
  1192. imageSaveOptions = null;
  1193. doc = null;
  1194. }
  1195. catch (Exception ex)
  1196. {
  1197. System.Windows.MessageBox.Show("文档已打开,请关闭后重试!");
  1198. LogHelper.WriteErrLog("【课堂考试(ExamWindow)】错误日志:" + ex.Message, ex);
  1199. }
  1200. return images;
  1201. }
  1202. private static SaveFormat GetSaveFormat(ImageFormat imageFormat)
  1203. {
  1204. SaveFormat sf;// = SaveFormat.Unknown;
  1205. if (imageFormat.Equals(ImageFormat.Png))
  1206. {
  1207. sf = SaveFormat.Png;
  1208. }
  1209. else if (imageFormat.Equals(ImageFormat.Jpeg))
  1210. {
  1211. sf = SaveFormat.Jpeg;
  1212. }
  1213. else if (imageFormat.Equals(ImageFormat.Tiff))
  1214. {
  1215. sf = SaveFormat.Tiff;
  1216. }
  1217. else if (imageFormat.Equals(ImageFormat.Bmp))
  1218. {
  1219. sf = SaveFormat.Bmp;
  1220. }
  1221. else
  1222. {
  1223. sf = SaveFormat.Unknown;
  1224. }
  1225. return sf;
  1226. }
  1227. #region 图像缩放,移动
  1228. private bool mouseDown;
  1229. private System.Windows.Point mouseXY;
  1230. private void IMG1_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
  1231. {
  1232. var img = sender as ContentControl;
  1233. if (img == null)
  1234. {
  1235. return;
  1236. }
  1237. img.CaptureMouse();
  1238. mouseDown = true;
  1239. mouseXY = e.GetPosition(img);
  1240. Console.WriteLine("mouseXY.X = " + mouseXY.X + "; mouseXY.Y = " + mouseXY.Y);
  1241. }
  1242. private void PicEMap_MouseDown(object sender, MouseButtonEventArgs e)
  1243. {
  1244. System.Windows.Point point = e.GetPosition(imgCanvas);
  1245. //Console.WriteLine("PicEmap.X = " + point.X + "; PicEmap.Y = " + point.Y);
  1246. //if ((point.X - 304) * (point.X - 304) + (point.Y - 86) * (point.Y - 86) < 100)
  1247. //{
  1248. // Console.WriteLine("在范围内");
  1249. //}
  1250. }
  1251. private void IMG1_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
  1252. {
  1253. var img = sender as ContentControl;
  1254. if (img == null)
  1255. {
  1256. return;
  1257. }
  1258. img.ReleaseMouseCapture();
  1259. mouseDown = false;
  1260. }
  1261. private void IMG1_MouseMove(object sender, System.Windows.Input.MouseEventArgs e)
  1262. {
  1263. var img = sender as ContentControl;
  1264. if (img == null)
  1265. {
  1266. return;
  1267. }
  1268. if (mouseDown)
  1269. {
  1270. Domousemove(img, e);
  1271. }
  1272. }
  1273. private void Domousemove(ContentControl img, System.Windows.Input.MouseEventArgs e)
  1274. {
  1275. if (e.LeftButton != MouseButtonState.Pressed)
  1276. {
  1277. return;
  1278. }
  1279. var group = IMG.FindResource("Imageview") as TransformGroup;
  1280. var transform = group.Children[1] as TranslateTransform;
  1281. var position = e.GetPosition(img);
  1282. transform.X -= mouseXY.X - position.X;
  1283. transform.Y -= mouseXY.Y - position.Y;
  1284. mouseXY = position;
  1285. }
  1286. private void IMG1_MouseWheel(object sender, MouseWheelEventArgs e)
  1287. {
  1288. var img = sender as ContentControl;
  1289. if (img == null)
  1290. {
  1291. return;
  1292. }
  1293. var point = e.GetPosition(img);
  1294. Console.WriteLine("point.X = " + point.X + "; point.Y=" + point.Y);
  1295. var PicLocate = e.GetPosition(imgCanvas);
  1296. Console.WriteLine("PicEmap.X = " + PicLocate.X + "; PicEmap.Y=" + PicLocate.Y);
  1297. var group = IMG.FindResource("Imageview") as TransformGroup;
  1298. var delta = e.Delta * 0.001;
  1299. DowheelZoom(group, point, delta);
  1300. }
  1301. private void DowheelZoom(TransformGroup group, System.Windows.Point point, double delta)
  1302. {
  1303. var pointToContent = group.Inverse.Transform(point);
  1304. var transform = group.Children[0] as ScaleTransform;
  1305. if (transform.ScaleX + delta < 0.1) return;
  1306. transform.ScaleX += delta;
  1307. transform.ScaleY += delta;
  1308. var transform1 = group.Children[1] as TranslateTransform;
  1309. transform1.X = -1 * ((pointToContent.X * transform.ScaleX) - point.X);
  1310. transform1.Y = -1 * ((pointToContent.Y * transform.ScaleY) - point.Y);
  1311. //Console.WriteLine("transform.ScaleX = " + transform.ScaleX + "; transform.ScaleY = " + transform.ScaleY);
  1312. }
  1313. #endregion
  1314. #region 点阵笔相关
  1315. #region 值初始化
  1316. // 不同尺寸点阵纸点阵宽高尺寸计算方法为:纸张物理尺寸(毫米)/0.3 *8,详见 开发必读.pdf 文档
  1317. /// <summary>
  1318. /// A4点阵纸点阵宽度
  1319. /// </summary>
  1320. private const int A4_WIDTH = 5600;
  1321. /// <summary>
  1322. /// A4点阵纸点阵高度
  1323. /// </summary>
  1324. private const int A4_HEIGHT = 7920;
  1325. /// <summary>
  1326. /// 画板
  1327. /// </summary>
  1328. private Graphics graphics;
  1329. /// <summary>
  1330. /// 笔画坐标数组
  1331. /// </summary>
  1332. private List<System.Drawing.Point> stroke;
  1333. /// <summary>
  1334. /// 笔序列号
  1335. /// </summary>
  1336. private string penSerial;
  1337. /// <summary>
  1338. /// 笔是否在点
  1339. /// </summary>
  1340. private bool isPenDown;
  1341. //当前点阵地址
  1342. private string currentPageSerial = string.Empty;
  1343. //不同点阵地址对应的笔迹绘制图片,用于实现在不同点阵地址书写切换时,显示书写内容自动切换
  1344. //本例图片放在内存中存储,对于大量或者需要在多个点阵地址对应图片进行切换演示,建议将图片存储到文件,以免内存溢出
  1345. private Dictionary<string, System.Drawing.Image> pagesDic = new Dictionary<string, System.Drawing.Image>();
  1346. #endregion
  1347. public void InitPen()
  1348. {
  1349. stroke = new List<System.Drawing.Point>();
  1350. //获取点阵笔实例,并绑定点阵笔事件
  1351. //将授权文件内容传入,获取点阵笔对象实例
  1352. APP.digitalPen = DigitalPenHID.GetInstance(certificates.MyLicense.Bytes);
  1353. //绑定笔连接事件
  1354. APP.digitalPen.PenConnected += OnPenConnect;
  1355. //绑定笔断开事件
  1356. APP.digitalPen.PenDisconnect += OnPenDisconnect;
  1357. //绑定笔书写输出坐标事件
  1358. APP.digitalPen.PenCoordinate += OnPenCoordinate;
  1359. //绑定抬笔事件
  1360. APP.digitalPen.PenUp += OnPenUp;
  1361. //绑定落笔事件
  1362. APP.digitalPen.PenDown += OnPenDown;
  1363. APP.digitalPen.PenBatteryCapacity += OnBatteryCapacity;
  1364. APP.digitalPen.PenMemoryFillLevel += OnMemoryFillLevel;
  1365. //完成初始化点阵笔,开始与点阵笔通信
  1366. ERROR_CODE ER = APP.digitalPen.Start();
  1367. ////绑定笔在新的点阵地址页面书写事件
  1368. //APP.digitalPen.PenNewPage += APP.digitalPen_OnPenNewPage;
  1369. ////绑定笔信息事件
  1370. //APP.digitalPen.PenInfo += APP.digitalPen_OnPenInfo;
  1371. //启动接收笔数据,完成初始化工作
  1372. ERROR_CODE rc = APP.digitalPen.Start();
  1373. //判断是否成功
  1374. if (ER != ERROR_CODE.ERROR_OK)
  1375. {
  1376. System.Windows.MessageBox.Show("初始化失败,授权过期,返回值:" + ER.ToString());
  1377. }
  1378. }
  1379. /// <summary>
  1380. /// 落笔
  1381. /// </summary>
  1382. /// <param name="time">时间戳,1970年1月1日到现在的总毫秒数</param>
  1383. /// <param name="penSerial">点阵笔序列号</param>
  1384. /// <param name="penType">点阵笔型号编号</param>
  1385. private void OnPenDown(ulong time, string penSerial, int penType)
  1386. {
  1387. if (this.CheckAccess())
  1388. {
  1389. Action<ulong, string, int> action = new Action<ulong, string, int>(OnPenDown);
  1390. this.Dispatcher.Invoke(action, new object[] { time, penSerial, penType });
  1391. }
  1392. else
  1393. {
  1394. //labPenSerial.Text = penSerial;
  1395. //labPenStatus.Text = "PenDown";
  1396. isPenDown = true;
  1397. }
  1398. //myblackboard.changepages(0, 0, true);
  1399. }
  1400. /// <summary>
  1401. /// 抬笔
  1402. /// </summary>
  1403. /// <param name="time">时间戳,1970年1月1日到现在的总毫秒数</param>
  1404. /// <param name="penSerial">点阵笔序列号</param>
  1405. /// <param name="penType">点阵笔型号编号</param>
  1406. private void OnPenUp(ulong time, string penSerial, int penType)
  1407. {
  1408. if (this.CheckAccess())
  1409. {
  1410. Action<ulong, string, int> action = new Action<ulong, string, int>(OnPenUp);
  1411. this.Dispatcher.Invoke(action, new object[] { time, penSerial, penType });
  1412. }
  1413. else
  1414. {
  1415. isPenDown = false;
  1416. APP.PenSerial = penSerial;
  1417. //int leftPoints = stroke.Count % 3;
  1418. //if (0 != leftPoints)
  1419. //{
  1420. // int from = stroke.Count - leftPoints - 1;
  1421. // if (from < 0)
  1422. // from = 0;
  1423. // int to = stroke.Count - 1;
  1424. // DrawCoordinates(from, to);
  1425. //}
  1426. stroke.Clear();
  1427. }
  1428. Dispatcher.Invoke(new Action(() =>
  1429. {
  1430. myblackboard.changepages(0, 0, true);
  1431. }));
  1432. }
  1433. /// <summary>
  1434. /// 笔断开
  1435. /// </summary>
  1436. /// <param name="time">时间戳,1970年1月1日到现在的总毫秒数</param>
  1437. /// <param name="penSerial">点阵笔序列号</param>
  1438. /// <param name="penType">点阵笔型号编号</param>
  1439. private void OnPenDisconnect(ulong time, string penSerial, int penType)
  1440. {
  1441. if (this.CheckAccess())
  1442. {
  1443. Action<ulong, string, int> action = new Action<ulong, string, int>(OnPenDisconnect);
  1444. this.Dispatcher.Invoke(action, new object[] { time, penSerial, penType });
  1445. }
  1446. else
  1447. {
  1448. APP.PenSerial = penSerial;
  1449. APP.PenStatus = false;
  1450. Dispatcher.Invoke(new Action(() =>
  1451. {
  1452. txbNotConnected.Text = "未连接";
  1453. txbNotConnecteds.Text = "未连接";
  1454. }));
  1455. }
  1456. }
  1457. /// <summary>
  1458. /// 笔连接
  1459. /// </summary>
  1460. /// <param name="time">时间戳,1970年1月1日到现在的总毫秒数</param>
  1461. /// <param name="penSerial">点阵笔序列号</param>
  1462. /// <param name="penType">点阵笔型号编号</param>
  1463. private void OnPenConnect(ulong time, string penSerial, int penType)
  1464. {
  1465. if (this.CheckAccess())
  1466. {
  1467. Action<ulong, string, int> action = new Action<ulong, string, int>(OnPenConnect);
  1468. this.Dispatcher.Invoke(action, new object[] { time, penSerial, penType });
  1469. }
  1470. else
  1471. {
  1472. APP.PenSerial = penSerial;
  1473. APP.PenStatus = true;
  1474. this.penSerial = penSerial;
  1475. //连接后,在获取笔数据前,可以清除笔内的历史数据
  1476. //APP.digitalPen.ClearMemory(penSerial);
  1477. //开始接收笔数据
  1478. APP.digitalPen.GetPenData(penSerial);
  1479. Dispatcher.Invoke(new Action(() =>
  1480. {
  1481. txbNotConnected.Text = "已连接";
  1482. txbNotConnecteds.Text = "已连接";
  1483. }));
  1484. }
  1485. }
  1486. /// <summary>
  1487. /// 电池电量
  1488. /// </summary>
  1489. /// <param name="time"></param>
  1490. /// <param name="penSerial"></param>
  1491. /// <param name="penType"></param>
  1492. /// <param name="capacity"></param>
  1493. private void OnBatteryCapacity(ulong time, string penSerial, int penType, byte capacity)
  1494. {
  1495. if (this.CheckAccess())
  1496. {
  1497. Action<ulong, string, int, byte> action = new Action<ulong, string, int, byte>(OnBatteryCapacity);
  1498. this.Dispatcher.Invoke(action, new object[] { time, penSerial, penType, capacity });
  1499. }
  1500. else
  1501. {
  1502. //System.Windows.MessageBox.Show("电池电量:" + capacity.ToString());
  1503. }
  1504. }
  1505. /// <summary>
  1506. /// 已用存储
  1507. /// </summary>
  1508. /// <param name="time"></param>
  1509. /// <param name="penSerial"></param>
  1510. /// <param name="penType"></param>
  1511. /// <param name="fillLevel"></param>
  1512. private void OnMemoryFillLevel(ulong time, string penSerial, int penType, byte fillLevel)
  1513. {
  1514. if (this.CheckAccess())
  1515. {
  1516. Action<ulong, string, int, byte> action = new Action<ulong, string, int, byte>(OnMemoryFillLevel);
  1517. this.Dispatcher.Invoke(action, new object[] { time, penSerial, penType, fillLevel });
  1518. }
  1519. else
  1520. {
  1521. //System.Windows.MessageBox.Show("存储:" + fillLevel.ToString());
  1522. }
  1523. }
  1524. /// <summary>
  1525. /// 笔书写,收到坐标
  1526. /// </summary>
  1527. /// <param name="time">时间戳,1970年1月1日到现在的总毫秒数</param>
  1528. /// <param name="penSerial">点阵笔序列号</param>
  1529. /// <param name="penType">点阵笔型号编号</param>
  1530. /// <param name="pageSerial">点阵地址</param>
  1531. /// <param name="cx">x坐标</param>
  1532. /// <param name="cy">y坐标</param>
  1533. /// <param name="force">压力值</param>
  1534. private void OnPenCoordinate(ulong time, string penSerial, int penType, string pageSerial, int cx, int cy, byte force)
  1535. {
  1536. if (this.CheckAccess())
  1537. {
  1538. Action<ulong, string, int, string, int, int, byte> ac = new Action<ulong, string, int, string, int, int, byte>(OnPenCoordinate);
  1539. this.Dispatcher.Invoke(ac, new object[] { time, pageSerial, penType, pageSerial, cx, cy, force });
  1540. }
  1541. else
  1542. {
  1543. //判断是否是落笔后输出的坐标,在设置悬浮模式下,落笔前的悬浮坐标不绘制
  1544. if (!isPenDown)
  1545. {
  1546. return;
  1547. }
  1548. stroke.Add(new System.Drawing.Point(cx, cy));
  1549. double PropW = blackboard_canvas.ActualWidth / A4_WIDTH;
  1550. double PropH = blackboard_canvas.ActualHeight / A4_HEIGHT;
  1551. //点
  1552. double testX=(double)cx * PropW;
  1553. double testY=(double)cy * PropH;
  1554. //pageSerial //点阵IP地址 与打印的页面关联
  1555. Dispatcher.Invoke(new Action(() =>
  1556. {
  1557. myblackboard.changepages(testX, testY,false);
  1558. }));
  1559. ////每3个点画一条曲线
  1560. //if (stroke.Count % 3 == 0)
  1561. //{
  1562. // int from = stroke.Count - 3 - 1;
  1563. // if (from < 0)
  1564. // from = 0;
  1565. // int to = stroke.Count - 1;
  1566. // DrawCoordinates(from, to);
  1567. //}
  1568. }
  1569. }
  1570. /// <summary>
  1571. /// 停止笔
  1572. /// </summary>
  1573. public void StopDigitalPen()
  1574. {
  1575. //停止,释放资源
  1576. APP.digitalPen.Stop();
  1577. }
  1578. /// <summary>
  1579. /// 清空笔内存储
  1580. /// </summary>
  1581. public void ClearPenStorage()
  1582. {
  1583. if (!string.IsNullOrEmpty(penSerial))
  1584. APP.digitalPen.ClearMemory(penSerial);
  1585. }
  1586. /// <summary>
  1587. /// 获取剩余电量
  1588. /// </summary>
  1589. public void GetPenElectricityQuantity()
  1590. {
  1591. if (!string.IsNullOrEmpty(penSerial))
  1592. APP.digitalPen.GetBatteryCapacity(penSerial);
  1593. }
  1594. /// <summary>
  1595. /// 获取存储空间
  1596. /// </summary>
  1597. public void GetUsedStorage()
  1598. {
  1599. if (!string.IsNullOrEmpty(penSerial))
  1600. APP.digitalPen.GetMemoryFillLevel(penSerial);
  1601. }
  1602. /// <summary>
  1603. /// 开启悬浮
  1604. /// </summary>
  1605. public void 开启悬浮()
  1606. {
  1607. if (!string.IsNullOrEmpty(penSerial))
  1608. APP.digitalPen.SetPenHoverMode(true, penSerial);
  1609. }
  1610. /// <summary>
  1611. /// 关闭悬浮
  1612. /// </summary>
  1613. public void 关闭悬浮()
  1614. {
  1615. if (!string.IsNullOrEmpty(penSerial))
  1616. APP.digitalPen.SetPenHoverMode(false, penSerial);
  1617. }
  1618. #endregion
  1619. /// <summary>
  1620. /// 最小化
  1621. /// </summary>
  1622. /// <param name="sender"></param>
  1623. /// <param name="e"></param>
  1624. private void BtnShrink_Click(object sender, RoutedEventArgs e)
  1625. {
  1626. if(Visibility== Visibility.Hidden)
  1627. Visibility = Visibility.Visible;
  1628. else
  1629. Visibility = Visibility.Hidden;
  1630. }
  1631. }
  1632. }