星火微课系统客户端
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773
  1. using Common.system;
  2. using System;
  3. using System.Configuration;
  4. using System.IO;
  5. using System.Threading;
  6. using System.Windows;
  7. using System.Windows.Forms;
  8. using System.Windows.Ink;
  9. using System.Windows.Media;
  10. using System.Windows.Media.Imaging;
  11. using System.Windows.Threading;
  12. using XHWK.Model;
  13. namespace XHWK.WKTool
  14. {
  15. /// <summary>
  16. /// 录屏工具栏
  17. /// </summary>
  18. public partial class ScreenRecordingToolbarWindow : Window
  19. {
  20. #region 初始变量
  21. /// <summary>
  22. /// 视频保存名称
  23. /// </summary>
  24. string VideoSavePathName;
  25. /// <summary>
  26. /// 是否首次录屏
  27. /// </summary>
  28. bool IsFirstRS = true;
  29. /// <summary>
  30. /// 是否暂停
  31. /// </summary>
  32. bool IsSuspend = true;
  33. /// <summary>
  34. /// 视频信息
  35. /// </summary>
  36. Model_Video VideoInfo = null;
  37. //声明一个 DrawingAttributes 类型的变量
  38. DrawingAttributes drawingAttributes;
  39. private DispatcherTimer t = null;
  40. /// <summary>
  41. /// 计时器状态
  42. /// </summary>
  43. private enum State
  44. {
  45. Start,
  46. Pause,
  47. End
  48. }
  49. /// <summary>
  50. /// 状态
  51. /// </summary>
  52. private State _state = State.End;
  53. /// <summary>
  54. /// 计时用
  55. /// </summary>
  56. private TimeSpan _timeSpan = new TimeSpan(0, 0, 0, 0, 0);
  57. KeyboardHookCommon k_hook;
  58. /// <summary>
  59. /// 🖊状态 0红色 1蓝色 10红色批注内 11蓝色批注内
  60. /// </summary>
  61. public int flg = 0;
  62. #endregion
  63. #region 初始化
  64. /// <summary>
  65. /// 录屏工具栏
  66. /// </summary>
  67. public ScreenRecordingToolbarWindow()
  68. {
  69. InitializeComponent();
  70. }
  71. /// <summary>
  72. /// 初始化
  73. /// </summary>
  74. public void Initialize()
  75. {
  76. k_hook = new KeyboardHookCommon();
  77. k_hook.KeyDownEvent += K_hook_KeyDownEvent;
  78. //创建 DrawingAttributes 类的一个实例
  79. drawingAttributes = new DrawingAttributes();
  80. //将 InkCanvas 的 DefaultDrawingAttributes 属性的值赋成创建的 DrawingAttributes 类的对象的引用
  81. //InkCanvas 通过 DefaultDrawingAttributes 属性来获取墨迹的各种设置,该属性的类型为 DrawingAttributes 型
  82. blackboard_canvas.DefaultDrawingAttributes = drawingAttributes;
  83. drawingAttributes.FitToCurve = true;
  84. //隐藏画笔工具栏
  85. //BtnToolbarDown_Click(null, null);
  86. gridToolbar.Visibility = Visibility.Hidden;
  87. gridColour.Visibility = Visibility.Hidden;
  88. gridThickness.Visibility = Visibility.Hidden;
  89. ImgRecordingScreen.Source = new BitmapImage(new Uri("pack://application:,,,/Images/Toobar26.png"));//大圆圈三角形
  90. ImgEndRecordingScreen.Source= new BitmapImage(new Uri("pack://application:,,,/Images/Toobar15.png"));
  91. BtnStopRecordingScreen.IsEnabled = false; //停止录制按钮不点击
  92. imgBlackPenOne.Source = new BitmapImage(new Uri("pack://application:,,,/Images/31.png"));
  93. btnBlackPenOne.IsEnabled = false;//蓝笔不可点击
  94. imgBlackPenTwo.Source = new BitmapImage(new Uri("pack://application:,,,/Images/31.png"));
  95. btnBlackPenTwo.IsEnabled = false;//红笔不可点击
  96. imgReturn.Source = new BitmapImage(new Uri("pack://application:,,,/Images/Toobar29.png"));
  97. btnReturn.IsEnabled = true;//返回主界面可点击
  98. txbTime.Visibility = Visibility.Hidden;//时间不显示
  99. if (t == null)
  100. {
  101. t = new DispatcherTimer();
  102. t.Tick += OnTimer;
  103. t.Interval = new TimeSpan(0, 0, 0, 1);
  104. t.IsEnabled = true;
  105. t.Start();
  106. }
  107. t.Interval = new TimeSpan(0, 0, 0, 1);
  108. //Stack();
  109. //ImgRecordingScreen.Source = new BitmapImage(new Uri("pack://application:,,,/Images/Toobar25.png"));
  110. //BtnRecordingScreen_Click(null, null);
  111. }
  112. private void K_hook_KeyDownEvent(object sender, System.Windows.Forms.KeyEventArgs e)
  113. {
  114. if (e.KeyValue == (int)System.Windows.Forms.Keys.F5 && (int)Control.ModifierKeys == (int)Keys.Control)
  115. {
  116. //开始,暂停
  117. BtnRecordingScreen_Click(null, null);
  118. }
  119. if (e.KeyValue == (int)Keys.S && (int)Control.ModifierKeys == (int)Keys.Control)
  120. {
  121. //结束
  122. BtnStopRecordingScreen_Click(null, null);
  123. }
  124. }
  125. #endregion
  126. #region 事件
  127. /// <summary>
  128. /// 时钟回调
  129. /// </summary>
  130. /// <param name="sender"></param>
  131. /// <param name="e"></param>
  132. private void OnTimer(object sender, EventArgs e)
  133. {
  134. switch (_state)
  135. {
  136. case State.Start:
  137. {
  138. _timeSpan += new TimeSpan(0, 0, 0, 1);
  139. }
  140. break;
  141. case State.Pause:
  142. {
  143. }
  144. break;
  145. case State.End:
  146. {
  147. _timeSpan = new TimeSpan();
  148. //_timeSpan = new TimeSpan(0, 23, 12, 45, 54);
  149. }
  150. break;
  151. }
  152. string time = string.Format("{0:D2}:{1:D2}",/* _timeSpan.Hours,*/ _timeSpan.Minutes, _timeSpan.Seconds);
  153. //char[] times = time.ToCharArray();
  154. txbTime.Text = time;
  155. }
  156. /// <summary>
  157. /// 开始
  158. /// </summary>
  159. /// <param name="sender"></param>
  160. /// <param name="e"></param>
  161. private void Stack()
  162. {
  163. _state = State.Start;
  164. }
  165. /// <summary>
  166. /// 暂停
  167. /// </summary>
  168. private void TimeOut()
  169. {
  170. _state = State.Pause;
  171. }
  172. /// <summary>
  173. /// 结束
  174. /// </summary>
  175. /// <param name="sender"></param>
  176. /// <param name="e"></param>
  177. private void End()
  178. {
  179. _state = State.End;
  180. }
  181. #region 录屏
  182. /// <summary>
  183. /// 设置录屏文件地址
  184. /// </summary>
  185. void SetUpVideoPathName()
  186. {
  187. //FileToolsCommon.DeleteDirectory(APP.WKData.WkPath + "temp/");
  188. FileToolsCommon.CreateDirectory(APP.WKData.WkPath);
  189. FileToolsCommon.DeleteDirectory(APP.WKData.WkPath + "tempsr/");
  190. VideoSavePathName = APP.WKData.WkPath + APP.WKData.WkName + "_录屏." + ((Enum_VideoType)int.Parse(FileToolsCommon.GetConfigValue("VideoType"))).ToString();
  191. int num = 1;
  192. while (FileToolsCommon.IsExistFile(VideoSavePathName))
  193. {
  194. VideoSavePathName = APP.WKData.WkPath + APP.WKData.WkName + "_录屏_" + num + "." + ((Enum_VideoType)int.Parse(FileToolsCommon.GetConfigValue("VideoType"))).ToString();
  195. num++;
  196. }
  197. }
  198. /// <summary>
  199. /// 开始或暂停录制
  200. /// </summary>
  201. /// <param name="sender"></param>
  202. /// <param name="e"></param>
  203. private void BtnRecordingScreen_Click(object sender, RoutedEventArgs e)
  204. {
  205. if (IsSuspend)
  206. {
  207. Stack();
  208. if (IsFirstRS)
  209. {
  210. VideoInfo = new Model_Video();
  211. VideoInfo.VideoType = (Enum_VideoType)int.Parse(FileToolsCommon.GetConfigValue("VideoType"));
  212. VideoInfo.WkType = Enum_WKVidetype.RecordingScreen;
  213. SetUpVideoPathName();
  214. IsFirstRS = false;
  215. k_hook.Start();//安装键盘钩子
  216. }
  217. IsSuspend = false;
  218. //#region 录像倒计时
  219. //if (APP.W_CountdownWindow == null)
  220. //{
  221. // APP.W_CountdownWindow = new CountdownWindow();
  222. // //APP.W_CountdownWindow.Topmost = true;
  223. //}
  224. //else
  225. //{
  226. // APP.W_CountdownWindow.Initialize();
  227. // //APP.W_CountdownWindow.Topmost = true;
  228. //}
  229. //APP.W_CountdownWindow.Show();
  230. //#endregion
  231. ImgRecordingScreen.Source = new BitmapImage(new Uri("pack://application:,,,/Images/Toobar25.png"));//播放状态
  232. ImgEndRecordingScreen.Source = new BitmapImage(new Uri("pack://application:,,,/Images/Toobar14.png"));
  233. BtnStopRecordingScreen.IsEnabled = true; //停止录制按钮可点击
  234. imgBlackPenOne.Source = new BitmapImage(new Uri("pack://application:,,,/Images/Toobar27.png"));
  235. btnBlackPenOne.IsEnabled = true;//蓝笔可点击
  236. imgBlackPenTwo.Source = new BitmapImage(new Uri("pack://application:,,,/Images/Toobar28.png"));
  237. btnBlackPenTwo.IsEnabled = true;//红笔可点击
  238. imgReturn.Source = new BitmapImage(new Uri("pack://application:,,,/Images/Toobar30.png"));
  239. btnReturn.IsEnabled = false;//返回主界面不可点击
  240. txbTime.Visibility = Visibility.Visible;//时间显示
  241. try
  242. {
  243. new Thread(new ThreadStart(new Action(() =>
  244. {
  245. APP.FFmpeg.StartRecordingVideo(VideoSavePathName);
  246. }))).Start();
  247. }
  248. catch (Exception ex)
  249. {
  250. System.Windows.MessageBox.Show(ex.Message);
  251. }
  252. }
  253. else
  254. {
  255. TimeOut();
  256. IsSuspend = true;
  257. ImgRecordingScreen.Source = new BitmapImage(new Uri("pack://application:,,,/Images/Toobar26.png"));//大圆圈三角形
  258. ImgEndRecordingScreen.Source = new BitmapImage(new Uri("pack://application:,,,/Images/Toobar15.png"));
  259. BtnStopRecordingScreen.IsEnabled = false; //停止录制按钮不点击
  260. imgBlackPenOne.Source = new BitmapImage(new Uri("pack://application:,,,/Images/31.png"));
  261. btnBlackPenOne.IsEnabled = false;//蓝笔不可点击
  262. imgBlackPenTwo.Source = new BitmapImage(new Uri("pack://application:,,,/Images/31.png"));
  263. btnBlackPenTwo.IsEnabled = false;//红笔不可点击
  264. txbTime.Visibility = Visibility.Hidden;//时间不显示
  265. #region 2秒内不可点击
  266. new Thread(new ThreadStart(new Action(() =>
  267. {
  268. Dispatcher.Invoke(() =>
  269. {
  270. BtnRecordingScreen.IsEnabled = false;
  271. BtnStopRecordingScreen.IsEnabled = false;
  272. });
  273. Thread.Sleep(2000);
  274. Dispatcher.Invoke(() =>
  275. {
  276. ImgEndRecordingScreen.Source = new BitmapImage(new Uri("pack://application:,,,/Images/Toobar14.png"));
  277. BtnRecordingScreen.IsEnabled = true;
  278. BtnStopRecordingScreen.IsEnabled = true;
  279. });
  280. }))).Start();
  281. #endregion
  282. try
  283. {
  284. APP.FFmpeg.SuspendFFmpeg();
  285. }
  286. catch (Exception ex)
  287. {
  288. System.Windows.MessageBox.Show(ex.Message);
  289. }
  290. }
  291. }
  292. /// <summary>
  293. /// 停止录像
  294. /// </summary>
  295. /// <param name="sender"></param>
  296. /// <param name="e"></param>
  297. private void BtnStopRecordingScreen_Click(object sender, RoutedEventArgs e)
  298. {
  299. k_hook.Stop();
  300. IsSuspend = true;
  301. txbTime.Text = "00:00";
  302. txbTime.Visibility = Visibility.Hidden;
  303. End();
  304. if (gridToolbar.Visibility == Visibility.Visible)
  305. {
  306. gridToolbar.Visibility = Visibility.Hidden;
  307. gridColour.Visibility = Visibility.Hidden;
  308. gridThickness.Visibility = Visibility.Hidden;
  309. APP.W_PracticeWindow.Hide();
  310. }
  311. if (APP.W_XHMicroLessonSystemWindow == null)
  312. {
  313. APP.W_XHMicroLessonSystemWindow = new XHMicroLessonSystemWindow();
  314. }
  315. APP.W_XHMicroLessonSystemWindow.Show();
  316. if (!IsFirstRS)
  317. {
  318. try
  319. {
  320. try
  321. {
  322. APP.FFmpeg.StopFFmpeg(VideoSavePathName);
  323. }
  324. catch (Exception ex)
  325. {
  326. LogHelper.WriteErrLog("【停止录屏】(BtnStopRecordingScreen_Click)" + ex.Message, ex);
  327. }
  328. IsFirstRS = true;
  329. //生成缩略图
  330. string ThumbnailPath = FileToolsCommon.GetDirectoryName(VideoSavePathName) + "ThumbnailPath/";
  331. FileToolsCommon.CreateDirectory(ThumbnailPath);
  332. //缩略图存储位置
  333. string ThumbnailPathName = ThumbnailPath + FileToolsCommon.GetIOFileNameNoExtension(VideoSavePathName) + ".JPG";
  334. new Thread(new ThreadStart(new Action(() =>
  335. {
  336. while (!FileToolsCommon.IsExistFile(VideoSavePathName))
  337. {
  338. Thread.Sleep(100);
  339. }
  340. FileToolsCommon.DeleteFile(ThumbnailPathName);
  341. //VideoInfo.VideoSize = FileToolsCommon.GetFileSizeByMB(VideoSavePathName).ToString() + " MB";
  342. VideoInfo.RSTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  343. VideoInfo.VideoPath = VideoSavePathName;
  344. VideoInfo.ThumbnailPath = ThumbnailPathName;
  345. APP.FFmpeg.GenerateThumbnails(VideoSavePathName, ThumbnailPathName);
  346. VideoInfo.FileGuid = Guid.NewGuid().ToString();
  347. VideoInfo.IsUpload = false;
  348. VideoInfo.Uploaded = 0;
  349. VideoInfo.Savefolder = APP.UserInfo.Schoolid + "/resource";
  350. APP.VideoList.Add(VideoInfo);
  351. //保存数据
  352. APP.SaveWkData();
  353. }))).Start();
  354. Click_stopRecordingScreen();
  355. }
  356. catch (Exception ex)
  357. {
  358. LogHelper.WriteErrLog("【停止录屏】(BtnStopRecordingScreen_Click)" + ex.Message, ex);
  359. }
  360. }
  361. Hide();
  362. }
  363. #endregion
  364. #region 画笔相关
  365. /// <summary>
  366. /// 画笔工具栏关闭事件
  367. /// </summary>
  368. /// <param name="sender"></param>
  369. /// <param name="e"></param>
  370. private void BtnToolbarDown_Click(object sender, RoutedEventArgs e)
  371. {
  372. gridToolbar.Visibility = Visibility.Hidden;
  373. gridColour.Visibility = Visibility.Hidden;
  374. gridThickness.Visibility = Visibility.Hidden;
  375. APP.W_PracticeWindow.Hide();
  376. }
  377. /// <summary>
  378. /// 画笔点击事件
  379. /// </summary>
  380. /// <param name="sender"></param>
  381. /// <param name="e"></param>
  382. private void BtnBrush_Click(object sender, RoutedEventArgs e)
  383. {
  384. string time = GetTimeStamp();
  385. string tempPath = AppDomain.CurrentDomain.BaseDirectory + "temp\\";
  386. if (!Directory.Exists(tempPath))
  387. {
  388. Directory.CreateDirectory(tempPath);
  389. }
  390. string imagePath = Path.Combine(tempPath, time + ".jpg");
  391. ImageHelper.GetScreenshot(new System.Drawing.Rectangle(0, 0, 0, 0), imagePath, true, out BitmapImage bitmap);
  392. try
  393. {
  394. if (flg == 11)
  395. {
  396. flg = 1;
  397. APP.W_PracticeWindow.Hide();
  398. }
  399. else if(flg==10)
  400. {
  401. APP.W_PracticeWindow.Blue();
  402. flg = 11;
  403. }
  404. else
  405. {
  406. if (APP.W_PracticeWindow == null)
  407. {
  408. APP.W_PracticeWindow = new PracticeWindow();
  409. //APP.W_PracticeWindow.Topmost = true;
  410. APP.W_PracticeWindow.Width = pwidth;
  411. APP.W_PracticeWindow.Height = pHeight;
  412. APP.W_PracticeWindow.Left = 0;
  413. APP.W_PracticeWindow.Top = 0;
  414. //practiceWin.Owner = this;
  415. }
  416. APP.W_PracticeWindow.Initialize(imagePath);
  417. flg = 11;
  418. APP.W_PracticeWindow.Blue();
  419. APP.W_PracticeWindow.Show();
  420. }
  421. }
  422. catch (Exception ex)
  423. {
  424. LogHelper.WriteErrLog("【批注(PracticeWindow)" + ex.Message, ex);
  425. }
  426. //imgCanvas.Source = new BitmapImage(new Uri(imagePath));
  427. }
  428. /// <summary>
  429. /// 屏幕宽
  430. /// </summary>
  431. internal double pwidth = SystemParameters.PrimaryScreenWidth;
  432. /// <summary>
  433. /// 屏幕高
  434. /// </summary>
  435. internal double pHeight = SystemParameters.PrimaryScreenHeight;
  436. /// <summary>
  437. /// 获取时间戳
  438. /// </summary>
  439. /// <returns></returns>
  440. public string GetTimeStamp()
  441. {
  442. TimeSpan ts = DateTime.Now - new DateTime(1970, 1, 1, 0, 0, 0, 0);
  443. return Convert.ToInt64(ts.TotalMilliseconds).ToString();
  444. }
  445. /// <summary>
  446. /// 画笔粗细事件
  447. /// </summary>
  448. /// <param name="sender"></param>
  449. /// <param name="e"></param>
  450. private void BtnThickness_Click(object sender, RoutedEventArgs e)
  451. {
  452. gridThickness.Visibility = Visibility.Visible;
  453. gridColour.Visibility = Visibility.Collapsed;
  454. }
  455. /// <summary>
  456. /// 画笔颜色事件
  457. /// </summary>
  458. /// <param name="sender"></param>
  459. /// <param name="e"></param>
  460. private void BtnColour_Click(object sender, RoutedEventArgs e)
  461. {
  462. gridColour.Visibility = Visibility.Visible;
  463. gridThickness.Visibility = Visibility.Collapsed;
  464. }
  465. /// <summary>
  466. /// 白色
  467. /// </summary>
  468. /// <param name="sender"></param>
  469. /// <param name="e"></param>
  470. private void BtnWhite_Click(object sender, RoutedEventArgs e)
  471. {
  472. //drawingAttributes.Color = Colors.White;
  473. APP.W_PracticeWindow.White();
  474. gridColour.Visibility = Visibility.Collapsed;
  475. gridThickness.Visibility = Visibility.Collapsed;
  476. }
  477. /// <summary>
  478. /// 红色
  479. /// </summary>
  480. /// <param name="sender"></param>
  481. /// <param name="e"></param>
  482. private void BtnRed_Click(object sender, RoutedEventArgs e)
  483. {
  484. //drawingAttributes.Color = Colors.Red;
  485. APP.W_PracticeWindow.Red();
  486. gridColour.Visibility = Visibility.Collapsed;
  487. gridThickness.Visibility = Visibility.Collapsed;
  488. }
  489. /// <summary>
  490. /// 黄色
  491. /// </summary>
  492. /// <param name="sender"></param>
  493. /// <param name="e"></param>
  494. private void BtnYellow_Click(object sender, RoutedEventArgs e)
  495. {
  496. //drawingAttributes.Color = Colors.Gold;
  497. APP.W_PracticeWindow.Yellow();
  498. gridColour.Visibility = Visibility.Collapsed;
  499. gridThickness.Visibility = Visibility.Collapsed;
  500. }
  501. /// <summary>
  502. /// 青色
  503. /// </summary>
  504. /// <param name="sender"></param>
  505. /// <param name="e"></param>
  506. private void BtnCyanBlue_Click(object sender, RoutedEventArgs e)
  507. {
  508. //drawingAttributes.Color = Colors.LimeGreen;
  509. APP.W_PracticeWindow.CyanBlue();
  510. gridColour.Visibility = Visibility.Collapsed;
  511. gridThickness.Visibility = Visibility.Collapsed;
  512. }
  513. /// <summary>
  514. /// 灰色
  515. /// </summary>
  516. /// <param name="sender"></param>
  517. /// <param name="e"></param>
  518. private void BtnGray_Click(object sender, RoutedEventArgs e)
  519. {
  520. //drawingAttributes.Color = Colors.Gray;
  521. APP.W_PracticeWindow.Gray();
  522. gridColour.Visibility = Visibility.Collapsed;
  523. gridThickness.Visibility = Visibility.Collapsed;
  524. }
  525. /// <summary>
  526. /// 蓝色
  527. /// </summary>
  528. /// <param name="sender"></param>
  529. /// <param name="e"></param>
  530. private void BtnBlue_Click(object sender, RoutedEventArgs e)
  531. {
  532. //drawingAttributes.Color = Colors.DeepSkyBlue;
  533. APP.W_PracticeWindow.Blue();
  534. gridColour.Visibility = Visibility.Collapsed;
  535. gridThickness.Visibility = Visibility.Collapsed;
  536. }
  537. /// <summary>
  538. /// 画笔 细
  539. /// </summary>
  540. /// <param name="sender"></param>
  541. /// <param name="e"></param>
  542. private void BtnFine_Click(object sender, RoutedEventArgs e)
  543. {
  544. APP.W_PracticeWindow.Fine();
  545. gridColour.Visibility = Visibility.Collapsed;
  546. gridThickness.Visibility = Visibility.Collapsed;
  547. }
  548. /// <summary>
  549. /// 画笔 中
  550. /// </summary>
  551. /// <param name="sender"></param>
  552. /// <param name="e"></param>
  553. private void BtnIn_Click(object sender, RoutedEventArgs e)
  554. {
  555. APP.W_PracticeWindow.In();
  556. gridColour.Visibility = Visibility.Collapsed;
  557. gridThickness.Visibility = Visibility.Collapsed;
  558. }
  559. /// <summary>
  560. /// 画笔粗
  561. /// </summary>
  562. /// <param name="sender"></param>
  563. /// <param name="e"></param>
  564. private void BtnCrude_Click(object sender, RoutedEventArgs e)
  565. {
  566. APP.W_PracticeWindow.Crude();
  567. gridColour.Visibility = Visibility.Collapsed;
  568. gridThickness.Visibility = Visibility.Collapsed;
  569. }
  570. /// <summary>
  571. /// 橡皮
  572. /// </summary>
  573. /// <param name="sender"></param>
  574. /// <param name="e"></param>
  575. private void BtnEraser_Click(object sender, RoutedEventArgs e)
  576. {
  577. APP.W_PracticeWindow.Eraser();
  578. }
  579. /// <summary>
  580. /// 🖊
  581. /// </summary>
  582. /// <param name="sender"></param>
  583. /// <param name="e"></param>
  584. private void BtnPen_Click(object sender, RoutedEventArgs e)
  585. {
  586. APP.W_PracticeWindow.Pen();
  587. }
  588. /// <summary>
  589. /// ⚪
  590. /// </summary>
  591. /// <param name="sender"></param>
  592. /// <param name="e"></param>
  593. private void BtnRound_Click(object sender, RoutedEventArgs e)
  594. {
  595. APP.W_PracticeWindow.Round();
  596. }
  597. /// <summary>
  598. /// 矩形
  599. /// </summary>
  600. /// <param name="sender"></param>
  601. /// <param name="e"></param>
  602. private void BtnRectangle_Click(object sender, RoutedEventArgs e)
  603. {
  604. APP.W_PracticeWindow.Rectangle();
  605. }
  606. #endregion
  607. #endregion
  608. /// <summary>
  609. /// 停止录屏
  610. /// </summary>
  611. public delegate void StopRecordingScreen();
  612. /// <summary>
  613. /// 停止录屏
  614. /// </summary>
  615. public event StopRecordingScreen Click_stopRecordingScreen;
  616. /// <summary>
  617. /// 黑笔
  618. /// </summary>
  619. /// <param name="sender"></param>
  620. /// <param name="e"></param>
  621. private void BtnBlackPen_Click(object sender, RoutedEventArgs e)
  622. {
  623. }
  624. /// <summary>
  625. /// 移动工具栏
  626. /// </summary>
  627. /// <param name="sender"></param>
  628. /// <param name="e"></param>
  629. private void Grid_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
  630. {
  631. DragMove();
  632. }
  633. /// <summary>
  634. /// 红笔
  635. /// </summary>
  636. /// <param name="sender"></param>
  637. /// <param name="e"></param>
  638. private void BtnBlackPenTwo_Click(object sender, RoutedEventArgs e)
  639. {
  640. string time = GetTimeStamp();
  641. string tempPath = AppDomain.CurrentDomain.BaseDirectory + "temp\\";
  642. if (!Directory.Exists(tempPath))
  643. {
  644. Directory.CreateDirectory(tempPath);
  645. }
  646. string imagePath = Path.Combine(tempPath, time + ".jpg");
  647. ImageHelper.GetScreenshot(new System.Drawing.Rectangle(0, 0, 0, 0), imagePath, true, out BitmapImage bitmap);
  648. try
  649. {
  650. if (flg == 10)
  651. {
  652. flg = 0;
  653. APP.W_PracticeWindow.Hide();
  654. }
  655. else if(flg==11)
  656. {
  657. flg = 10;
  658. APP.W_PracticeWindow.Red();
  659. }
  660. else
  661. {
  662. if (APP.W_PracticeWindow == null)
  663. {
  664. APP.W_PracticeWindow = new PracticeWindow();
  665. //APP.W_PracticeWindow.Topmost = true;
  666. APP.W_PracticeWindow.Width = pwidth;
  667. APP.W_PracticeWindow.Height = pHeight;
  668. APP.W_PracticeWindow.Left = 0;
  669. APP.W_PracticeWindow.Top = 0;
  670. //practiceWin.Owner = this;
  671. }
  672. APP.W_PracticeWindow.Initialize(imagePath);
  673. flg = 10;
  674. APP.W_PracticeWindow.Red();
  675. APP.W_PracticeWindow.Show();
  676. }
  677. }
  678. catch (Exception ex)
  679. {
  680. LogHelper.WriteErrLog("【批注(PracticeWindow)" + ex.Message, ex);
  681. }
  682. }
  683. /// <summary>
  684. /// 鼠标右键按下事件
  685. /// </summary>
  686. /// <param name="sender"></param>
  687. /// <param name="e"></param>
  688. private void RightButtonDown()
  689. {
  690. if (flg > 9)
  691. {
  692. APP.W_PracticeWindow.Hide();
  693. }
  694. else
  695. {
  696. string time = GetTimeStamp();
  697. string tempPath = AppDomain.CurrentDomain.BaseDirectory + "temp\\";
  698. if (!Directory.Exists(tempPath))
  699. {
  700. Directory.CreateDirectory(tempPath);
  701. }
  702. string imagePath = Path.Combine(tempPath, time + ".jpg");
  703. ImageHelper.GetScreenshot(new System.Drawing.Rectangle(0, 0, 0, 0), imagePath, true, out BitmapImage bitmap);
  704. try
  705. {
  706. if (APP.W_PracticeWindow == null)
  707. {
  708. APP.W_PracticeWindow = new PracticeWindow();
  709. //APP.W_PracticeWindow.Topmost = true;
  710. APP.W_PracticeWindow.Width = pwidth;
  711. APP.W_PracticeWindow.Height = pHeight;
  712. APP.W_PracticeWindow.Left = 0;
  713. APP.W_PracticeWindow.Top = 0;
  714. //practiceWin.Owner = this;
  715. }
  716. APP.W_PracticeWindow.Initialize(imagePath);
  717. if (flg == 0)
  718. {
  719. flg = 10;
  720. APP.W_PracticeWindow.Red();
  721. }
  722. else
  723. {
  724. flg = 11;
  725. APP.W_PracticeWindow.Blue();
  726. }
  727. APP.W_PracticeWindow.Show();
  728. }
  729. catch (Exception ex)
  730. {
  731. LogHelper.WriteErrLog("【批注(PracticeWindow)" + ex.Message, ex);
  732. }
  733. }
  734. }
  735. /// <summary>
  736. /// 返回主界面
  737. /// </summary>
  738. /// <param name="sender"></param>
  739. /// <param name="e"></param>
  740. private void BtnReturn_Click(object sender, RoutedEventArgs e)
  741. {
  742. if (APP.W_XHMicroLessonSystemWindow == null)
  743. {
  744. APP.W_XHMicroLessonSystemWindow = new XHMicroLessonSystemWindow();
  745. }
  746. APP.W_XHMicroLessonSystemWindow.Show();
  747. this.Hide();
  748. }
  749. }
  750. }