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

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