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

ScreenRecordingToolbarWindow.xaml.cs 29KB

4 年之前
4 年之前
4 年之前
4 年之前
4 年之前
4 年之前
4 年之前
4 年之前
4 年之前
4 年之前
4 年之前
4 年之前
4 年之前
4 年之前
4 年之前
4 年之前
4 年之前
4 年之前
4 年之前
4 年之前
4 年之前
4 年之前
4 年之前
4 年之前
4 年之前
4 年之前
4 年之前
4 年之前
4 年之前
4 年之前
4 年之前
4 年之前
4 年之前
4 年之前
4 年之前
4 年之前
4 年之前
4 年之前
4 年之前
4 年之前
4 年之前
4 年之前
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791
  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. if (IsFirstRS)
  208. {
  209. VideoInfo = new Model_Video();
  210. VideoInfo.VideoType = (Enum_VideoType)int.Parse(FileToolsCommon.GetConfigValue("VideoType"));
  211. VideoInfo.WkType = Enum_WKVidetype.RecordingScreen;
  212. SetUpVideoPathName();
  213. IsFirstRS = false;
  214. k_hook.Start();//安装键盘钩子
  215. }
  216. IsSuspend = false;
  217. //#region 录像倒计时
  218. //if (APP.W_CountdownWindow == null)
  219. //{
  220. // APP.W_CountdownWindow = new CountdownWindow();
  221. // //APP.W_CountdownWindow.Topmost = true;
  222. //}
  223. //else
  224. //{
  225. // APP.W_CountdownWindow.Initialize();
  226. // //APP.W_CountdownWindow.Topmost = true;
  227. //}
  228. //APP.W_CountdownWindow.Show();
  229. //#endregion
  230. ImgRecordingScreen.Source = new BitmapImage(new Uri("pack://application:,,,/Images/Toobar25.png"));//播放状态
  231. ImgEndRecordingScreen.Source = new BitmapImage(new Uri("pack://application:,,,/Images/Toobar14.png"));
  232. BtnStopRecordingScreen.IsEnabled = true; //停止录制按钮可点击
  233. imgBlackPenOne.Source = new BitmapImage(new Uri("pack://application:,,,/Images/Toobar27.png"));
  234. btnBlackPenOne.IsEnabled = true;//蓝笔可点击
  235. imgBlackPenTwo.Source = new BitmapImage(new Uri("pack://application:,,,/Images/Toobar28.png"));
  236. btnBlackPenTwo.IsEnabled = true;//红笔可点击
  237. imgReturn.Source = new BitmapImage(new Uri("pack://application:,,,/Images/Toobar30.png"));
  238. btnReturn.IsEnabled = false;//返回主界面不可点击
  239. txbTime.Visibility = Visibility.Visible;//时间显示
  240. try
  241. {
  242. if (APP.W_CountdownWindow == null)
  243. {
  244. APP.W_CountdownWindow = new CountdownWindow();
  245. APP.W_CountdownWindow.Initialize(true, 1800);
  246. //APP.W_CountdownWindow.Topmost = true;
  247. }
  248. else
  249. {
  250. APP.W_CountdownWindow.Initialize(true, 1800);
  251. //APP.W_CountdownWindow.Topmost = true;
  252. }
  253. APP.W_CountdownWindow.Show();
  254. new Thread(new ThreadStart(new Action(() =>
  255. {
  256. Thread.Sleep(1000);
  257. APP.FFmpeg.StartRecordingVideo(VideoSavePathName);
  258. Thread.Sleep(1800);
  259. Dispatcher.Invoke(() =>
  260. {
  261. Stack();
  262. });
  263. }))).Start();
  264. }
  265. catch (Exception ex)
  266. {
  267. MessageWindow.Show(ex.Message);
  268. }
  269. }
  270. else
  271. {
  272. TimeOut();
  273. IsSuspend = true;
  274. ImgRecordingScreen.Source = new BitmapImage(new Uri("pack://application:,,,/Images/Toobar26.png"));//大圆圈三角形
  275. ImgEndRecordingScreen.Source = new BitmapImage(new Uri("pack://application:,,,/Images/Toobar15.png"));
  276. BtnStopRecordingScreen.IsEnabled = false; //停止录制按钮不点击
  277. imgBlackPenOne.Source = new BitmapImage(new Uri("pack://application:,,,/Images/31.png"));
  278. btnBlackPenOne.IsEnabled = false;//蓝笔不可点击
  279. imgBlackPenTwo.Source = new BitmapImage(new Uri("pack://application:,,,/Images/31.png"));
  280. btnBlackPenTwo.IsEnabled = false;//红笔不可点击
  281. txbTime.Visibility = Visibility.Hidden;//时间不显示
  282. #region 2秒内不可点击
  283. new Thread(new ThreadStart(new Action(() =>
  284. {
  285. Dispatcher.Invoke(() =>
  286. {
  287. BtnRecordingScreen.IsEnabled = false;
  288. BtnStopRecordingScreen.IsEnabled = false;
  289. });
  290. Thread.Sleep(2000);
  291. Dispatcher.Invoke(() =>
  292. {
  293. ImgEndRecordingScreen.Source = new BitmapImage(new Uri("pack://application:,,,/Images/Toobar14.png"));
  294. BtnRecordingScreen.IsEnabled = true;
  295. BtnStopRecordingScreen.IsEnabled = true;
  296. });
  297. }))).Start();
  298. #endregion
  299. try
  300. {
  301. APP.FFmpeg.SuspendFFmpeg();
  302. }
  303. catch (Exception ex)
  304. {
  305. MessageWindow.Show(ex.Message);
  306. }
  307. }
  308. }
  309. /// <summary>
  310. /// 停止录像
  311. /// </summary>
  312. /// <param name="sender"></param>
  313. /// <param name="e"></param>
  314. private void BtnStopRecordingScreen_Click(object sender, RoutedEventArgs e)
  315. {
  316. k_hook.Stop();
  317. IsSuspend = true;
  318. txbTime.Text = "00:00";
  319. txbTime.Visibility = Visibility.Hidden;
  320. End();
  321. if (gridToolbar.Visibility == Visibility.Visible)
  322. {
  323. gridToolbar.Visibility = Visibility.Hidden;
  324. gridColour.Visibility = Visibility.Hidden;
  325. gridThickness.Visibility = Visibility.Hidden;
  326. APP.W_PracticeWindow.Hide();
  327. }
  328. if (APP.W_XHMicroLessonSystemWindow == null)
  329. {
  330. APP.W_XHMicroLessonSystemWindow = new XHMicroLessonSystemWindow();
  331. }
  332. APP.W_XHMicroLessonSystemWindow.Show();
  333. if (!IsFirstRS)
  334. {
  335. try
  336. {
  337. try
  338. {
  339. APP.FFmpeg.StopFFmpeg(VideoSavePathName);
  340. }
  341. catch (Exception ex)
  342. {
  343. LogHelper.WriteErrLog("【停止录屏】(BtnStopRecordingScreen_Click)" + ex.Message, ex);
  344. }
  345. IsFirstRS = true;
  346. //生成缩略图
  347. string ThumbnailPath = FileToolsCommon.GetDirectoryName(VideoSavePathName) + "ThumbnailPath/";
  348. FileToolsCommon.CreateDirectory(ThumbnailPath);
  349. //缩略图存储位置
  350. string ThumbnailPathName = ThumbnailPath + FileToolsCommon.GetIOFileNameNoExtension(VideoSavePathName) + ".JPG";
  351. new Thread(new ThreadStart(new Action(() =>
  352. {
  353. while (!FileToolsCommon.IsExistFile(VideoSavePathName))
  354. {
  355. Thread.Sleep(100);
  356. }
  357. FileToolsCommon.DeleteFile(ThumbnailPathName);
  358. //VideoInfo.VideoSize = FileToolsCommon.GetFileSizeByMB(VideoSavePathName).ToString() + " MB";
  359. VideoInfo.RSTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  360. VideoInfo.VideoPath = VideoSavePathName;
  361. VideoInfo.ThumbnailPath = ThumbnailPathName;
  362. APP.FFmpeg.GenerateThumbnails(VideoSavePathName, ThumbnailPathName);
  363. VideoInfo.FileGuid = Guid.NewGuid().ToString();
  364. VideoInfo.IsUpload = false;
  365. VideoInfo.Uploaded = 0;
  366. VideoInfo.Savefolder = APP.UserInfo.Schoolid + "/resource";
  367. APP.VideoList.Add(VideoInfo);
  368. //保存数据
  369. APP.SaveWkData();
  370. }))).Start();
  371. Click_stopRecordingScreen();
  372. }
  373. catch (Exception ex)
  374. {
  375. LogHelper.WriteErrLog("【停止录屏】(BtnStopRecordingScreen_Click)" + ex.Message, ex);
  376. }
  377. }
  378. Hide();
  379. }
  380. #endregion
  381. #region 画笔相关
  382. /// <summary>
  383. /// 画笔工具栏关闭事件
  384. /// </summary>
  385. /// <param name="sender"></param>
  386. /// <param name="e"></param>
  387. private void BtnToolbarDown_Click(object sender, RoutedEventArgs e)
  388. {
  389. gridToolbar.Visibility = Visibility.Hidden;
  390. gridColour.Visibility = Visibility.Hidden;
  391. gridThickness.Visibility = Visibility.Hidden;
  392. APP.W_PracticeWindow.Hide();
  393. }
  394. /// <summary>
  395. /// 画笔点击事件
  396. /// </summary>
  397. /// <param name="sender"></param>
  398. /// <param name="e"></param>
  399. private void BtnBrush_Click(object sender, RoutedEventArgs e)
  400. {
  401. string time = GetTimeStamp();
  402. string tempPath = AppDomain.CurrentDomain.BaseDirectory + "temp\\";
  403. if (!Directory.Exists(tempPath))
  404. {
  405. Directory.CreateDirectory(tempPath);
  406. }
  407. string imagePath = Path.Combine(tempPath, time + ".jpg");
  408. ImageHelper.GetScreenshot(new System.Drawing.Rectangle(0, 0, 0, 0), imagePath, true, out BitmapImage bitmap);
  409. try
  410. {
  411. if (flg == 11)
  412. {
  413. flg = 1;
  414. APP.W_PracticeWindow.Hide();
  415. }
  416. else if(flg==10)
  417. {
  418. APP.W_PracticeWindow.Blue();
  419. flg = 11;
  420. }
  421. else
  422. {
  423. if (APP.W_PracticeWindow == null)
  424. {
  425. APP.W_PracticeWindow = new PracticeWindow();
  426. //APP.W_PracticeWindow.Topmost = true;
  427. APP.W_PracticeWindow.Width = pwidth;
  428. APP.W_PracticeWindow.Height = pHeight;
  429. APP.W_PracticeWindow.Left = 0;
  430. APP.W_PracticeWindow.Top = 0;
  431. //practiceWin.Owner = this;
  432. }
  433. APP.W_PracticeWindow.Initialize(imagePath);
  434. flg = 11;
  435. APP.W_PracticeWindow.Blue();
  436. APP.W_PracticeWindow.Show();
  437. }
  438. }
  439. catch (Exception ex)
  440. {
  441. LogHelper.WriteErrLog("【批注(PracticeWindow)" + ex.Message, ex);
  442. }
  443. //imgCanvas.Source = new BitmapImage(new Uri(imagePath));
  444. }
  445. /// <summary>
  446. /// 屏幕宽
  447. /// </summary>
  448. internal double pwidth = SystemParameters.PrimaryScreenWidth;
  449. /// <summary>
  450. /// 屏幕高
  451. /// </summary>
  452. internal double pHeight = SystemParameters.PrimaryScreenHeight;
  453. /// <summary>
  454. /// 获取时间戳
  455. /// </summary>
  456. /// <returns></returns>
  457. public string GetTimeStamp()
  458. {
  459. TimeSpan ts = DateTime.Now - new DateTime(1970, 1, 1, 0, 0, 0, 0);
  460. return Convert.ToInt64(ts.TotalMilliseconds).ToString();
  461. }
  462. /// <summary>
  463. /// 画笔粗细事件
  464. /// </summary>
  465. /// <param name="sender"></param>
  466. /// <param name="e"></param>
  467. private void BtnThickness_Click(object sender, RoutedEventArgs e)
  468. {
  469. gridThickness.Visibility = Visibility.Visible;
  470. gridColour.Visibility = Visibility.Collapsed;
  471. }
  472. /// <summary>
  473. /// 画笔颜色事件
  474. /// </summary>
  475. /// <param name="sender"></param>
  476. /// <param name="e"></param>
  477. private void BtnColour_Click(object sender, RoutedEventArgs e)
  478. {
  479. gridColour.Visibility = Visibility.Visible;
  480. gridThickness.Visibility = Visibility.Collapsed;
  481. }
  482. /// <summary>
  483. /// 白色
  484. /// </summary>
  485. /// <param name="sender"></param>
  486. /// <param name="e"></param>
  487. private void BtnWhite_Click(object sender, RoutedEventArgs e)
  488. {
  489. //drawingAttributes.Color = Colors.White;
  490. APP.W_PracticeWindow.White();
  491. gridColour.Visibility = Visibility.Collapsed;
  492. gridThickness.Visibility = Visibility.Collapsed;
  493. }
  494. /// <summary>
  495. /// 红色
  496. /// </summary>
  497. /// <param name="sender"></param>
  498. /// <param name="e"></param>
  499. private void BtnRed_Click(object sender, RoutedEventArgs e)
  500. {
  501. //drawingAttributes.Color = Colors.Red;
  502. APP.W_PracticeWindow.Red();
  503. gridColour.Visibility = Visibility.Collapsed;
  504. gridThickness.Visibility = Visibility.Collapsed;
  505. }
  506. /// <summary>
  507. /// 黄色
  508. /// </summary>
  509. /// <param name="sender"></param>
  510. /// <param name="e"></param>
  511. private void BtnYellow_Click(object sender, RoutedEventArgs e)
  512. {
  513. //drawingAttributes.Color = Colors.Gold;
  514. APP.W_PracticeWindow.Yellow();
  515. gridColour.Visibility = Visibility.Collapsed;
  516. gridThickness.Visibility = Visibility.Collapsed;
  517. }
  518. /// <summary>
  519. /// 青色
  520. /// </summary>
  521. /// <param name="sender"></param>
  522. /// <param name="e"></param>
  523. private void BtnCyanBlue_Click(object sender, RoutedEventArgs e)
  524. {
  525. //drawingAttributes.Color = Colors.LimeGreen;
  526. APP.W_PracticeWindow.CyanBlue();
  527. gridColour.Visibility = Visibility.Collapsed;
  528. gridThickness.Visibility = Visibility.Collapsed;
  529. }
  530. /// <summary>
  531. /// 灰色
  532. /// </summary>
  533. /// <param name="sender"></param>
  534. /// <param name="e"></param>
  535. private void BtnGray_Click(object sender, RoutedEventArgs e)
  536. {
  537. //drawingAttributes.Color = Colors.Gray;
  538. APP.W_PracticeWindow.Gray();
  539. gridColour.Visibility = Visibility.Collapsed;
  540. gridThickness.Visibility = Visibility.Collapsed;
  541. }
  542. /// <summary>
  543. /// 蓝色
  544. /// </summary>
  545. /// <param name="sender"></param>
  546. /// <param name="e"></param>
  547. private void BtnBlue_Click(object sender, RoutedEventArgs e)
  548. {
  549. //drawingAttributes.Color = Colors.DeepSkyBlue;
  550. APP.W_PracticeWindow.Blue();
  551. gridColour.Visibility = Visibility.Collapsed;
  552. gridThickness.Visibility = Visibility.Collapsed;
  553. }
  554. /// <summary>
  555. /// 画笔 细
  556. /// </summary>
  557. /// <param name="sender"></param>
  558. /// <param name="e"></param>
  559. private void BtnFine_Click(object sender, RoutedEventArgs e)
  560. {
  561. APP.W_PracticeWindow.Fine();
  562. gridColour.Visibility = Visibility.Collapsed;
  563. gridThickness.Visibility = Visibility.Collapsed;
  564. }
  565. /// <summary>
  566. /// 画笔 中
  567. /// </summary>
  568. /// <param name="sender"></param>
  569. /// <param name="e"></param>
  570. private void BtnIn_Click(object sender, RoutedEventArgs e)
  571. {
  572. APP.W_PracticeWindow.In();
  573. gridColour.Visibility = Visibility.Collapsed;
  574. gridThickness.Visibility = Visibility.Collapsed;
  575. }
  576. /// <summary>
  577. /// 画笔粗
  578. /// </summary>
  579. /// <param name="sender"></param>
  580. /// <param name="e"></param>
  581. private void BtnCrude_Click(object sender, RoutedEventArgs e)
  582. {
  583. APP.W_PracticeWindow.Crude();
  584. gridColour.Visibility = Visibility.Collapsed;
  585. gridThickness.Visibility = Visibility.Collapsed;
  586. }
  587. /// <summary>
  588. /// 橡皮
  589. /// </summary>
  590. /// <param name="sender"></param>
  591. /// <param name="e"></param>
  592. private void BtnEraser_Click(object sender, RoutedEventArgs e)
  593. {
  594. APP.W_PracticeWindow.Eraser();
  595. }
  596. /// <summary>
  597. /// 🖊
  598. /// </summary>
  599. /// <param name="sender"></param>
  600. /// <param name="e"></param>
  601. private void BtnPen_Click(object sender, RoutedEventArgs e)
  602. {
  603. APP.W_PracticeWindow.Pen();
  604. }
  605. /// <summary>
  606. /// ⚪
  607. /// </summary>
  608. /// <param name="sender"></param>
  609. /// <param name="e"></param>
  610. private void BtnRound_Click(object sender, RoutedEventArgs e)
  611. {
  612. APP.W_PracticeWindow.Round();
  613. }
  614. /// <summary>
  615. /// 矩形
  616. /// </summary>
  617. /// <param name="sender"></param>
  618. /// <param name="e"></param>
  619. private void BtnRectangle_Click(object sender, RoutedEventArgs e)
  620. {
  621. APP.W_PracticeWindow.Rectangle();
  622. }
  623. #endregion
  624. #endregion
  625. /// <summary>
  626. /// 停止录屏
  627. /// </summary>
  628. public delegate void StopRecordingScreen();
  629. /// <summary>
  630. /// 停止录屏
  631. /// </summary>
  632. public event StopRecordingScreen Click_stopRecordingScreen;
  633. /// <summary>
  634. /// 黑笔
  635. /// </summary>
  636. /// <param name="sender"></param>
  637. /// <param name="e"></param>
  638. private void BtnBlackPen_Click(object sender, RoutedEventArgs e)
  639. {
  640. }
  641. /// <summary>
  642. /// 移动工具栏
  643. /// </summary>
  644. /// <param name="sender"></param>
  645. /// <param name="e"></param>
  646. private void Grid_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
  647. {
  648. DragMove();
  649. }
  650. /// <summary>
  651. /// 红笔
  652. /// </summary>
  653. /// <param name="sender"></param>
  654. /// <param name="e"></param>
  655. private void BtnBlackPenTwo_Click(object sender, RoutedEventArgs e)
  656. {
  657. string time = GetTimeStamp();
  658. string tempPath = AppDomain.CurrentDomain.BaseDirectory + "temp\\";
  659. if (!Directory.Exists(tempPath))
  660. {
  661. Directory.CreateDirectory(tempPath);
  662. }
  663. string imagePath = Path.Combine(tempPath, time + ".jpg");
  664. ImageHelper.GetScreenshot(new System.Drawing.Rectangle(0, 0, 0, 0), imagePath, true, out BitmapImage bitmap);
  665. try
  666. {
  667. if (flg == 10)
  668. {
  669. flg = 0;
  670. APP.W_PracticeWindow.Hide();
  671. }
  672. else if(flg==11)
  673. {
  674. flg = 10;
  675. APP.W_PracticeWindow.Red();
  676. }
  677. else
  678. {
  679. if (APP.W_PracticeWindow == null)
  680. {
  681. APP.W_PracticeWindow = new PracticeWindow();
  682. //APP.W_PracticeWindow.Topmost = true;
  683. APP.W_PracticeWindow.Width = pwidth;
  684. APP.W_PracticeWindow.Height = pHeight;
  685. APP.W_PracticeWindow.Left = 0;
  686. APP.W_PracticeWindow.Top = 0;
  687. //practiceWin.Owner = this;
  688. }
  689. APP.W_PracticeWindow.Initialize(imagePath);
  690. flg = 10;
  691. APP.W_PracticeWindow.Red();
  692. APP.W_PracticeWindow.Show();
  693. }
  694. }
  695. catch (Exception ex)
  696. {
  697. LogHelper.WriteErrLog("【批注(PracticeWindow)" + ex.Message, ex);
  698. }
  699. }
  700. /// <summary>
  701. /// 鼠标右键按下事件
  702. /// </summary>
  703. /// <param name="sender"></param>
  704. /// <param name="e"></param>
  705. private void RightButtonDown()
  706. {
  707. if (flg > 9)
  708. {
  709. APP.W_PracticeWindow.Hide();
  710. }
  711. else
  712. {
  713. string time = GetTimeStamp();
  714. string tempPath = AppDomain.CurrentDomain.BaseDirectory + "temp\\";
  715. if (!Directory.Exists(tempPath))
  716. {
  717. Directory.CreateDirectory(tempPath);
  718. }
  719. string imagePath = Path.Combine(tempPath, time + ".jpg");
  720. ImageHelper.GetScreenshot(new System.Drawing.Rectangle(0, 0, 0, 0), imagePath, true, out BitmapImage bitmap);
  721. try
  722. {
  723. if (APP.W_PracticeWindow == null)
  724. {
  725. APP.W_PracticeWindow = new PracticeWindow();
  726. //APP.W_PracticeWindow.Topmost = true;
  727. APP.W_PracticeWindow.Width = pwidth;
  728. APP.W_PracticeWindow.Height = pHeight;
  729. APP.W_PracticeWindow.Left = 0;
  730. APP.W_PracticeWindow.Top = 0;
  731. //practiceWin.Owner = this;
  732. }
  733. APP.W_PracticeWindow.Initialize(imagePath);
  734. if (flg == 0)
  735. {
  736. flg = 10;
  737. APP.W_PracticeWindow.Red();
  738. }
  739. else
  740. {
  741. flg = 11;
  742. APP.W_PracticeWindow.Blue();
  743. }
  744. APP.W_PracticeWindow.Show();
  745. }
  746. catch (Exception ex)
  747. {
  748. LogHelper.WriteErrLog("【批注(PracticeWindow)" + ex.Message, ex);
  749. }
  750. }
  751. }
  752. /// <summary>
  753. /// 返回主界面
  754. /// </summary>
  755. /// <param name="sender"></param>
  756. /// <param name="e"></param>
  757. private void BtnReturn_Click(object sender, RoutedEventArgs e)
  758. {
  759. if (APP.W_XHMicroLessonSystemWindow == null)
  760. {
  761. APP.W_XHMicroLessonSystemWindow = new XHMicroLessonSystemWindow();
  762. }
  763. APP.W_XHMicroLessonSystemWindow.Show();
  764. this.Hide();
  765. }
  766. }
  767. }