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

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408
  1. using Common.system;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Drawing;
  5. using System.IO;
  6. using System.Threading;
  7. using System.Windows;
  8. using System.Windows.Forms;
  9. using System.Windows.Ink;
  10. using System.Windows.Media;
  11. using System.Windows.Media.Imaging;
  12. using System.Windows.Threading;
  13. using TStudyDigitalPen.HID;
  14. using XHWK.Model;
  15. namespace XHWK.WKTool
  16. {
  17. /// <summary>
  18. /// 录屏工具栏
  19. /// </summary>
  20. public partial class ScreenRecordingToolbarWindow : Window
  21. {
  22. #region 初始变量
  23. /// <summary>
  24. /// 视频保存名称
  25. /// </summary>
  26. private string VideoSavePathName;
  27. /// <summary>
  28. /// 是否首次录屏
  29. /// </summary>
  30. private bool IsFirstRS = true;
  31. /// <summary>
  32. /// 是否暂停
  33. /// </summary>
  34. private bool IsSuspend = true;
  35. /// <summary>
  36. /// 视频信息
  37. /// </summary>
  38. private Model_Video VideoInfo = null;
  39. //声明一个 DrawingAttributes 类型的变量
  40. private DrawingAttributes drawingAttributes;
  41. private DispatcherTimer t = null;
  42. /// <summary>
  43. /// 计时器状态
  44. /// </summary>
  45. private enum State
  46. {
  47. Start,
  48. Pause,
  49. End
  50. }
  51. /// <summary>
  52. /// 状态
  53. /// </summary>
  54. private State _state = State.End;
  55. private KeyboardHookCommon k_hook;
  56. /// <summary>
  57. /// 🖊状态 0红色 1蓝色 10红色批注内 11蓝色批注内
  58. /// </summary>
  59. public int flg = 0;
  60. private System.Timers.Timer timer = new System.Timers.Timer();
  61. #endregion
  62. #region 初始化
  63. /// <summary>
  64. /// 录屏工具栏
  65. /// </summary>
  66. public ScreenRecordingToolbarWindow()
  67. {
  68. InitializeComponent();
  69. ResizeMode = ResizeMode.NoResize;
  70. }
  71. /// <summary>
  72. /// 初始化
  73. /// </summary>
  74. public void Initialize()
  75. {
  76. gridToobar.Visibility = Visibility.Visible;
  77. if (APP.W_PracticeWindow == null)
  78. {
  79. APP.W_PracticeWindow = new PracticeWindow
  80. {
  81. //APP.W_PracticeWindow.Topmost = true;
  82. Width = pwidth,
  83. Height = pHeight,
  84. Left = 0,
  85. Top = 0
  86. };
  87. //practiceWin.Owner = this;
  88. }
  89. APP.W_PracticeWindow.InitPen();
  90. APP.W_PracticeWindow.InitTQLPPen();
  91. APP.W_PracticeWindow.Show();
  92. new Thread(new ThreadStart(new Action(() =>
  93. {
  94. Thread.Sleep(100);
  95. Dispatcher.Invoke(() =>
  96. {
  97. //Owner = APP.W_PracticeWindow;
  98. Topmost = true;
  99. });
  100. }))).Start();
  101. APP.W_PracticeWindow.Hide();
  102. //timer = new System.Timers.Timer(200);
  103. //timer.Interval = 300;
  104. //timer.Elapsed += new System.Timers.ElapsedEventHandler(TimerDealy);
  105. //timer.Enabled = true; //启动计时器
  106. borOne.Background = new SolidColorBrush(Colors.DodgerBlue);
  107. borTwo.Background = new SolidColorBrush(Colors.DodgerBlue);
  108. flg = 0;
  109. k_hook = new KeyboardHookCommon();
  110. k_hook.KeyDownEvent += K_hook_KeyDownEvent;
  111. //创建 DrawingAttributes 类的一个实例
  112. drawingAttributes = new DrawingAttributes();
  113. //将 InkCanvas 的 DefaultDrawingAttributes 属性的值赋成创建的 DrawingAttributes 类的对象的引用
  114. //InkCanvas 通过 DefaultDrawingAttributes 属性来获取墨迹的各种设置,该属性的类型为 DrawingAttributes 型
  115. blackboard_canvas.DefaultDrawingAttributes = drawingAttributes;
  116. drawingAttributes.FitToCurve = true;
  117. //隐藏画笔工具栏
  118. //BtnToolbarDown_Click(null, null);
  119. gridToolbar.Visibility = Visibility.Hidden;
  120. gridColour.Visibility = Visibility.Hidden;
  121. gridThickness.Visibility = Visibility.Hidden;
  122. ImgRecordingScreen.Source = new BitmapImage(new Uri("pack://application:,,,/Images/Toobar26.png"));//大圆圈三角形
  123. ImgEndRecordingScreen.Source = new BitmapImage(new Uri("pack://application:,,,/Images/Toobar15.png"));
  124. BtnStopRecordingScreen.IsEnabled = false; //停止录制按钮不点击
  125. imgBlackPenOne.Source = new BitmapImage(new Uri("pack://application:,,,/Images/31.png"));
  126. btnBlackPenOne.IsEnabled = false;//蓝笔不可点击
  127. imgBlackPenTwo.Source = new BitmapImage(new Uri("pack://application:,,,/Images/31.png"));
  128. btnBlackPenTwo.IsEnabled = false;//红笔不可点击
  129. //imgReturn.Source = new BitmapImage(new Uri("pack://application:,,,/Images/Toobar29.png"));
  130. //btnReturn.IsEnabled = true;//返回主界面可点击
  131. txbTime.Visibility = Visibility.Hidden;//时间不显示
  132. BtnRecordingScreen.ToolTip = "开始";
  133. if (t == null)
  134. {
  135. t = new DispatcherTimer();
  136. t.Tick += OnTimer;
  137. t.Interval = new TimeSpan(0, 0, 0, 0, 300);
  138. t.IsEnabled = true;
  139. t.Start();
  140. }
  141. t.Interval = new TimeSpan(0, 0, 0, 0, 300);
  142. //Stack();
  143. //ImgRecordingScreen.Source = new BitmapImage(new Uri("pack://application:,,,/Images/Toobar25.png"));
  144. //BtnRecordingScreen_Click(null, null);
  145. }
  146. private void TimerDealy(object o, EventArgs e)
  147. {
  148. Dispatcher.Invoke(() =>
  149. {
  150. if (Left > 1630)
  151. {
  152. return;
  153. }
  154. //获取鼠标在屏幕上的位置
  155. double mouse_x = Form.MousePosition.X; //需要添加引用System.Drawing
  156. double mouse_y = Form.MousePosition.Y;
  157. bool is_in_collasped_range = (mouse_y > Left + Height) || (mouse_x < Left || mouse_x > Left + Width);//缩起的条件
  158. bool is_in_visiable_range = (mouse_y < 1 && mouse_x >= Left && mouse_x <= Left + Width); //展开的条件
  159. if (Left < 1630 && Left >= 0 && is_in_collasped_range)
  160. {
  161. System.Threading.Thread.Sleep(300);
  162. Left += 20 /*-this.ActualWidth - 3*/;
  163. }
  164. else if (Left < 0 && is_in_visiable_range)
  165. {
  166. Left = 1;
  167. }
  168. });
  169. }
  170. private void K_hook_KeyDownEvent(object sender, System.Windows.Forms.KeyEventArgs e)
  171. {
  172. if (e.KeyValue == (int)System.Windows.Forms.Keys.F5 && (int)Control.ModifierKeys == (int)Keys.Control)
  173. {
  174. //开始,暂停
  175. BtnRecordingScreen_Click(null, null);
  176. }
  177. if (e.KeyValue == (int)Keys.S && (int)Control.ModifierKeys == (int)Keys.Control)
  178. {
  179. //结束
  180. BtnStopRecordingScreen_Click(null, null);
  181. }
  182. }
  183. #endregion
  184. #region 事件
  185. /// <summary>
  186. /// 记录上次执行时间
  187. /// </summary>
  188. private DateTime Recorddt = DateTime.Now;
  189. DateTime SRTime = Convert.ToDateTime("2020-01-01 00:00:00");
  190. /// <summary>
  191. /// 时钟回调
  192. /// </summary>
  193. /// <param name="sender"></param>
  194. /// <param name="e"></param>
  195. private void OnTimer(object sender, EventArgs e)
  196. {
  197. switch (_state)
  198. {
  199. case State.Start:
  200. {
  201. DateTime dt = DateTime.Now;
  202. TimeSpan ts = dt.Subtract(Recorddt);//时间差
  203. double tsmi = ts.TotalMilliseconds;
  204. if (tsmi > 500.0)
  205. {
  206. Recorddt = Recorddt.AddMilliseconds(500);
  207. SRTime = SRTime.AddMilliseconds(500);
  208. }
  209. }
  210. break;
  211. case State.Pause:
  212. {
  213. }
  214. break;
  215. case State.End:
  216. {
  217. SRTime = Convert.ToDateTime("2020-01-01 00:00:00");
  218. //_timeSpan = new TimeSpan();
  219. ////_timeSpan = new TimeSpan(0, 23, 12, 45, 54);
  220. }
  221. break;
  222. }
  223. //string time = string.Format("{0:D2}:{1:D2}",/* _timeSpan.Hours,*/ _timeSpan.Minutes, _timeSpan.Seconds);
  224. //char[] times = time.ToCharArray();
  225. if (SRTime.Hour > 0)
  226. {
  227. //Dispatcher.Invoke(() =>
  228. //{
  229. txbTime.Text = SRTime.ToString("HH:mm:ss");
  230. //});
  231. }
  232. else
  233. {
  234. //Dispatcher.Invoke(() =>
  235. //{
  236. txbTime.Text = SRTime.ToString("mm:ss");
  237. //});
  238. }
  239. }
  240. /// <summary>
  241. /// 开始
  242. /// </summary>
  243. /// <param name="sender"></param>
  244. /// <param name="e"></param>
  245. private void Stack()
  246. {
  247. Recorddt = DateTime.Now;
  248. _state = State.Start;
  249. }
  250. /// <summary>
  251. /// 暂停
  252. /// </summary>
  253. private void TimeOut()
  254. {
  255. _state = State.Pause;
  256. }
  257. /// <summary>
  258. /// 结束
  259. /// </summary>
  260. /// <param name="sender"></param>
  261. /// <param name="e"></param>
  262. private void End()
  263. {
  264. _state = State.End;
  265. }
  266. #region 录屏
  267. /// <summary>
  268. /// 设置录屏文件地址
  269. /// </summary>
  270. private void SetUpVideoPathName()
  271. {
  272. //FileToolsCommon.DeleteDirectory(APP.WKData.WkPath + "temp/");
  273. FileToolsCommon.CreateDirectory(APP.WKData.WkPath);
  274. FileToolsCommon.DeleteDirectory(APP.WKData.WkPath + "temprs/");
  275. VideoSavePathName = APP.WKData.WkPath + APP.WKData.WkName + "_录屏." + ((Enum_VideoType)int.Parse(FileToolsCommon.GetConfigValue("VideoType"))).ToString();
  276. int num = 1;
  277. while (FileToolsCommon.IsExistFile(VideoSavePathName))
  278. {
  279. VideoSavePathName = APP.WKData.WkPath + APP.WKData.WkName + "_录屏_" + num + "." + ((Enum_VideoType)int.Parse(FileToolsCommon.GetConfigValue("VideoType"))).ToString();
  280. num++;
  281. }
  282. }
  283. /// <summary>
  284. /// 是否已经按下按钮
  285. /// </summary>
  286. private bool IsPressButton = false;
  287. /// <summary>
  288. /// 开始或暂停录制
  289. /// </summary>
  290. /// <param name="sender"></param>
  291. /// <param name="e"></param>
  292. private void BtnRecordingScreen_Click(object sender, RoutedEventArgs e)
  293. {
  294. #region 防止连击
  295. if (IsPressButton)
  296. {
  297. return;
  298. }
  299. else
  300. {
  301. IsPressButton = true;
  302. new Thread(new ThreadStart(new Action(() =>
  303. {
  304. Thread.Sleep(500);
  305. IsPressButton = false;
  306. }))).Start();
  307. }
  308. #endregion
  309. if (IsSuspend)
  310. {
  311. if (IsFirstRS)
  312. {
  313. #region 检测麦克风扬声器是否可用
  314. string AudioPath = FileToolsCommon.GetFileAbsolutePath("/temp/audio/");
  315. FileToolsCommon.CreateDirectory(AudioPath);
  316. string audioSpeakerPath = AudioPath + "adoS" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".m";
  317. string audioMicrophonePath = AudioPath + "adoM" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".m";
  318. try
  319. {
  320. FileToolsCommon.DeleteFile(audioSpeakerPath);
  321. FileToolsCommon.DeleteFile(audioMicrophonePath);
  322. }
  323. catch (Exception)
  324. {
  325. }
  326. //扬声器
  327. if (APP.FFmpeg.StartRecordSpeakerAudio(audioSpeakerPath))
  328. {
  329. APP.FFmpeg.StopRecordAudio(2);
  330. //Thread.Sleep(500);
  331. //麦克风
  332. if (APP.FFmpeg.StartRecordAudio(audioMicrophonePath))
  333. {
  334. }
  335. else
  336. {
  337. //无法录制麦克风
  338. MessageBoxResult Res = MessageWindow.Show("当前电脑无法录制麦克风,是否继续?", "消息提示", MessageBoxButton.OKCancel);
  339. if (Res == MessageBoxResult.Cancel)
  340. {
  341. return;
  342. }
  343. }
  344. APP.FFmpeg.StopRecordAudio(1);
  345. }
  346. else
  347. {
  348. //无法录制扬声器音频
  349. MessageBoxResult Res = MessageWindow.Show("当前电脑无法录制音频,是否继续?", "消息提示", MessageBoxButton.OKCancel);
  350. if (Res == MessageBoxResult.Cancel)
  351. {
  352. return;
  353. }
  354. }
  355. #endregion
  356. VideoInfo = new Model_Video
  357. {
  358. VideoType = (Enum_VideoType)int.Parse(FileToolsCommon.GetConfigValue("VideoType")),
  359. WkType = Enum_WKVidetype.RecordingScreen
  360. };
  361. SetUpVideoPathName();
  362. k_hook.Start();//安装键盘钩子
  363. if (APP.W_CountdownWindow == null)
  364. {
  365. APP.W_CountdownWindow = new CountdownWindow();
  366. APP.W_CountdownWindow.Initialize(true, 1800);
  367. //APP.W_CountdownWindow.Topmost = true;
  368. }
  369. else
  370. {
  371. APP.W_CountdownWindow.Initialize(true, 1800);
  372. //APP.W_CountdownWindow.Topmost = true;
  373. }
  374. APP.W_CountdownWindow.Show();
  375. }
  376. IsSuspend = false;
  377. //#region 录像倒计时
  378. //if (APP.W_CountdownWindow == null)
  379. //{
  380. // APP.W_CountdownWindow = new CountdownWindow();
  381. // //APP.W_CountdownWindow.Topmost = true;
  382. //}
  383. //else
  384. //{
  385. // APP.W_CountdownWindow.Initialize();
  386. // //APP.W_CountdownWindow.Topmost = true;
  387. //}
  388. //APP.W_CountdownWindow.Show();
  389. //#endregion
  390. ImgRecordingScreen.Source = new BitmapImage(new Uri("pack://application:,,,/Images/Toobar25.png"));//播放状态
  391. ImgEndRecordingScreen.Source = new BitmapImage(new Uri("pack://application:,,,/Images/Toobar14.png"));
  392. BtnStopRecordingScreen.IsEnabled = true; //停止录制按钮可点击
  393. imgBlackPenOne.Source = new BitmapImage(new Uri("pack://application:,,,/Images/Toobar27.png"));
  394. btnBlackPenOne.IsEnabled = true;//蓝笔可点击
  395. imgBlackPenTwo.Source = new BitmapImage(new Uri("pack://application:,,,/Images/Toobar28.png"));
  396. btnBlackPenTwo.IsEnabled = true;//红笔可点击
  397. txbTime.Visibility = Visibility.Visible;//时间显示
  398. //imgReturn.Source = new BitmapImage(new Uri("pack://application:,,,/Images/Toobar30.png"));
  399. //borOne.Background = new SolidColorBrush(Colors.LightBlue);
  400. BtnRecordingScreen.ToolTip = "暂停";
  401. #region 隐藏工具栏
  402. if (APP.IsHideSRTool)
  403. {
  404. if (APP.W_MinToolbar == null)
  405. {
  406. APP.W_MinToolbar = new MinToolbar();
  407. }
  408. APP.W_MinToolbar.Topmost = true;
  409. APP.W_MinToolbar.Initialize(this.Top);
  410. gridToobar.Visibility = Visibility.Hidden;
  411. APP.W_MinToolbar.Show();
  412. }
  413. #endregion
  414. try
  415. {
  416. #region 4秒内不可点击
  417. new Thread(new ThreadStart(new Action(() =>
  418. {
  419. //Dispatcher.Invoke(() =>
  420. //{
  421. // ImgEndRecordingScreen.Source = new BitmapImage(new Uri("pack://application:,,,/Images/Toobar15.png"));
  422. // BtnRecordingScreen.IsEnabled = false;
  423. // BtnStopRecordingScreen.IsEnabled = false;
  424. //});
  425. //Thread.Sleep(4000);
  426. Dispatcher.Invoke(() =>
  427. {
  428. ImgEndRecordingScreen.Source = new BitmapImage(new Uri("pack://application:,,,/Images/Toobar14.png"));
  429. BtnRecordingScreen.IsEnabled = true;
  430. BtnStopRecordingScreen.IsEnabled = true;
  431. });
  432. }))).Start();
  433. #endregion
  434. new Thread(new ThreadStart(new Action(() =>
  435. {
  436. if (IsFirstRS)
  437. {
  438. Thread.Sleep(800);
  439. }
  440. if (APP.FFmpeg.myProcess != null)
  441. {
  442. Thread.Sleep(100);
  443. }
  444. System.Drawing.Size DesktopSize = PrimaryScreen.DESKTOP;
  445. bool SynRes = APP.FFmpeg.StartRecordingVideo(VideoSavePathName, DesktopSize, out string ErrMessage);
  446. Thread.Sleep(1300);
  447. Dispatcher.Invoke(() =>
  448. {
  449. if (!SynRes)
  450. {
  451. MessageWindow.Show(ErrMessage);
  452. //隐藏画笔工具栏
  453. //BtnToolbarDown_Click(null, null);
  454. gridToolbar.Visibility = Visibility.Hidden;
  455. gridColour.Visibility = Visibility.Hidden;
  456. gridThickness.Visibility = Visibility.Hidden;
  457. ImgRecordingScreen.Source = new BitmapImage(new Uri("pack://application:,,,/Images/Toobar26.png"));//大圆圈三角形
  458. ImgEndRecordingScreen.Source = new BitmapImage(new Uri("pack://application:,,,/Images/Toobar15.png"));
  459. BtnStopRecordingScreen.IsEnabled = false; //停止录制按钮不点击
  460. imgBlackPenOne.Source = new BitmapImage(new Uri("pack://application:,,,/Images/31.png"));
  461. btnBlackPenOne.IsEnabled = false;//蓝笔不可点击
  462. imgBlackPenTwo.Source = new BitmapImage(new Uri("pack://application:,,,/Images/31.png"));
  463. btnBlackPenTwo.IsEnabled = false;//红笔不可点击
  464. txbTime.Visibility = Visibility.Hidden;//时间不显示
  465. BtnRecordingScreen.ToolTip = "开始";
  466. IsSuspend = true;
  467. IsFirstRS = true;
  468. return;
  469. }
  470. Stack();
  471. });
  472. }))).Start();
  473. }
  474. catch (Exception ex)
  475. {
  476. MessageWindow.Show(ex.Message);
  477. }
  478. IsFirstRS = false;
  479. }
  480. else
  481. {
  482. TimeOut();
  483. IsSuspend = true;
  484. ImgRecordingScreen.Source = new BitmapImage(new Uri("pack://application:,,,/Images/Toobar26.png"));//大圆圈三角形
  485. BtnStopRecordingScreen.IsEnabled = false; //停止录制按钮不点击
  486. BtnRecordingScreen.ToolTip = "开始";
  487. //imgBlackPenOne.Source = new BitmapImage(new Uri("pack://application:,,,/Images/31.png"));
  488. //btnBlackPenOne.IsEnabled = false;//蓝笔不可点击
  489. //imgBlackPenTwo.Source = new BitmapImage(new Uri("pack://application:,,,/Images/31.png"));
  490. //btnBlackPenTwo.IsEnabled = false;//红笔不可点击
  491. txbTime.Visibility = Visibility.Hidden;//时间不显示
  492. //imgReturn.Source = new BitmapImage(new Uri("pack://application:,,,/Images/Toobar29.png"));
  493. //btnReturn.IsEnabled = true;//返回主界面可点击
  494. #region 2秒内不可点击
  495. new Thread(new ThreadStart(new Action(() =>
  496. {
  497. //Dispatcher.Invoke(() =>
  498. //{
  499. // ImgEndRecordingScreen.Source = new BitmapImage(new Uri("pack://application:,,,/Images/Toobar15.png"));
  500. // BtnRecordingScreen.IsEnabled = false;
  501. // BtnStopRecordingScreen.IsEnabled = false;
  502. //});
  503. //Thread.Sleep(2000);
  504. Dispatcher.Invoke(() =>
  505. {
  506. ImgEndRecordingScreen.Source = new BitmapImage(new Uri("pack://application:,,,/Images/Toobar14.png"));
  507. BtnRecordingScreen.IsEnabled = true;
  508. BtnStopRecordingScreen.IsEnabled = true;
  509. });
  510. }))).Start();
  511. #endregion
  512. try
  513. {
  514. APP.FFmpeg.SuspendFFmpeg();
  515. }
  516. catch (Exception ex)
  517. {
  518. MessageWindow.Show(ex.Message);
  519. }
  520. }
  521. }
  522. /// <summary>
  523. /// 停止录像
  524. /// </summary>
  525. /// <param name="sender"></param>
  526. /// <param name="e"></param>
  527. private void BtnStopRecordingScreen_Click(object sender, RoutedEventArgs e)
  528. {
  529. #region 防止连击
  530. if (IsPressButton)
  531. {
  532. return;
  533. }
  534. else
  535. {
  536. IsPressButton = true;
  537. new Thread(new ThreadStart(new Action(() =>
  538. {
  539. Thread.Sleep(500);
  540. IsPressButton = false;
  541. }))).Start();
  542. }
  543. #endregion
  544. if (APP.W_MinToolbar != null)
  545. {
  546. APP.W_MinToolbar.Hide();
  547. }
  548. BtnRecordingScreen.ToolTip = "开始";
  549. k_hook.Stop();
  550. IsSuspend = true;
  551. txbTime.Text = "00:00";
  552. txbTime.Visibility = Visibility.Hidden;
  553. End();
  554. if (APP.W_PracticeWindow != null)
  555. {
  556. if (APP.W_PracticeWindow.Visibility == Visibility.Visible)
  557. {
  558. Owner = null;
  559. APP.W_PracticeWindow.ReturnPractice();
  560. }
  561. }
  562. if (gridToolbar.Visibility == Visibility.Visible)
  563. {
  564. gridToolbar.Visibility = Visibility.Hidden;
  565. gridColour.Visibility = Visibility.Hidden;
  566. gridThickness.Visibility = Visibility.Hidden;
  567. }
  568. if (APP.W_XHMicroLessonSystemWindow == null)
  569. {
  570. APP.W_XHMicroLessonSystemWindow = new XHMicroLessonSystemWindow();
  571. }
  572. APP.W_XHMicroLessonSystemWindow.InitializeKeyDownEvent();
  573. APP.W_XHMicroLessonSystemWindow.InitPen();
  574. APP.W_XHMicroLessonSystemWindow.InitTQLPPen();
  575. APP.W_XHMicroLessonSystemWindow.Show();
  576. if (!IsFirstRS)
  577. {
  578. try
  579. {
  580. if (SRTime.Hour > 0 || SRTime.Minute > 0 || SRTime.Second > 3)
  581. {
  582. try
  583. {
  584. APP.FFmpeg.StopFFmpeg(VideoSavePathName);
  585. }
  586. catch (Exception ex)
  587. {
  588. LogHelper.WriteErrLog("【停止录屏】(BtnStopRecordingScreen_Click)" + ex.Message, ex);
  589. }
  590. IsFirstRS = true;
  591. //生成缩略图
  592. string ThumbnailPath = FileToolsCommon.GetDirectoryName(VideoSavePathName) + "ThumbnailPath/";
  593. FileToolsCommon.CreateDirectory(ThumbnailPath);
  594. //缩略图存储位置
  595. string ThumbnailPathName = ThumbnailPath + FileToolsCommon.GetIOFileName(VideoSavePathName).Replace(".", "") + ".JPG";
  596. new Thread(new ThreadStart(new Action(() =>
  597. {
  598. while (!FileToolsCommon.IsExistFile(VideoSavePathName))
  599. {
  600. Thread.Sleep(100);
  601. }
  602. FileToolsCommon.DeleteFile(ThumbnailPathName);
  603. //VideoInfo.VideoSize = FileToolsCommon.GetFileSizeByMB(VideoSavePathName).ToString() + " MB";
  604. VideoInfo.RSTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  605. VideoInfo.VideoPath = VideoSavePathName;
  606. VideoInfo.ThumbnailPath = ThumbnailPathName;
  607. APP.FFmpeg.GenerateThumbnails(VideoSavePathName, ThumbnailPathName, 200, 130);
  608. VideoInfo.FileGuid = Guid.NewGuid().ToString();
  609. VideoInfo.IsUpload = false;
  610. VideoInfo.Uploaded = 0;
  611. //VideoInfo.Savefolder = APP.UserInfo.Schoolid + "/resource";
  612. APP.VideoList.Add(VideoInfo);
  613. //保存数据
  614. APP.SaveWkData();
  615. }))).Start();
  616. Click_stopRecordingScreen();
  617. }
  618. else
  619. {
  620. //视频过短
  621. APP.FFmpeg.SuspendFFmpeg();
  622. IsFirstRS = true;
  623. MessageWindow.Show("录屏时间过短,请重新录制!");
  624. }
  625. }
  626. catch (Exception ex)
  627. {
  628. LogHelper.WriteErrLog("【停止录屏】(BtnStopRecordingScreen_Click)" + ex.Message, ex);
  629. }
  630. }
  631. Hide();
  632. }
  633. public void MaxToobar()
  634. {
  635. Graphics graphics = Graphics.FromHwnd(IntPtr.Zero);
  636. float DIP = graphics.DpiX;
  637. float DIPY = graphics.DpiY;
  638. APP.W_ScreenRecordingToolbarWindow.Left = PrimaryScreen.WorkingArea.Width / (DIP / 96) - APP.W_ScreenRecordingToolbarWindow.Width + 10;
  639. gridToobar.Visibility = Visibility.Visible;
  640. APP.W_ScreenRecordingToolbarWindow.Topmost = true;
  641. }
  642. #endregion
  643. #region 画笔相关
  644. /// <summary>
  645. /// 画笔工具栏关闭事件
  646. /// </summary>
  647. /// <param name="sender"></param>
  648. /// <param name="e"></param>
  649. private void BtnToolbarDown_Click(object sender, RoutedEventArgs e)
  650. {
  651. gridToolbar.Visibility = Visibility.Hidden;
  652. gridColour.Visibility = Visibility.Hidden;
  653. gridThickness.Visibility = Visibility.Hidden;
  654. APP.W_PracticeWindow.Hide();
  655. }
  656. /// <summary>
  657. /// 笔调用批注
  658. /// </summary>
  659. public void PenPractice()
  660. {
  661. if (!IsFirstRS)
  662. {
  663. if (flg != 11 && flg != 10)
  664. {
  665. #region 防止连击
  666. if (IsPressButton)
  667. {
  668. return;
  669. }
  670. else
  671. {
  672. IsPressButton = true;
  673. new Thread(new ThreadStart(new Action(() =>
  674. {
  675. Thread.Sleep(500);
  676. IsPressButton = false;
  677. }))).Start();
  678. }
  679. #endregion
  680. string time = GetTimeStamp();
  681. string tempPath = AppDomain.CurrentDomain.BaseDirectory + "temp\\";
  682. if (!Directory.Exists(tempPath))
  683. {
  684. Directory.CreateDirectory(tempPath);
  685. }
  686. try
  687. {
  688. Dispatcher.Invoke(() =>
  689. {
  690. borOne.Background = new SolidColorBrush(Colors.LightSkyBlue);
  691. borTwo.Background = new SolidColorBrush(Colors.DodgerBlue);
  692. if (APP.W_PracticeWindow == null)
  693. {
  694. APP.W_PracticeWindow = new PracticeWindow
  695. {
  696. Width = pwidth,
  697. Height = pHeight,
  698. Left = 0,
  699. Top = 0
  700. };
  701. //practiceWin.Owner = this;
  702. }
  703. //APP.W_PracticeWindow.InitPen();
  704. //APP.W_PracticeWindow.InitTQLPPen();
  705. APP.W_PracticeWindow.Initialize();// imagePath);
  706. flg = 11;
  707. APP.W_PracticeWindow.Blue();
  708. APP.W_PracticeWindow.Show();
  709. APP.W_PracticeWindow.Topmost = true;
  710. APP.W_PracticeWindow.Focus();
  711. });
  712. new Thread(new ThreadStart(new Action(() =>
  713. {
  714. Dispatcher.Invoke(() =>
  715. {
  716. APP.W_PracticeWindow.Topmost = false;
  717. });
  718. Thread.Sleep(500);
  719. Dispatcher.Invoke(() =>
  720. {
  721. //Owner = APP.W_PracticeWindow;
  722. Topmost = true;
  723. });
  724. }))).Start();
  725. }
  726. catch (Exception ex)
  727. {
  728. LogHelper.WriteErrLog("【批注(PracticeWindow)" + ex.Message, ex);
  729. }
  730. }
  731. }
  732. }
  733. /// <summary>
  734. /// 画笔点击事件
  735. /// </summary>
  736. /// <param name="sender"></param>
  737. /// <param name="e"></param>
  738. private void BtnBrush_Click(object sender, RoutedEventArgs e)
  739. {
  740. #region 防止连击
  741. if (IsPressButton)
  742. {
  743. return;
  744. }
  745. else
  746. {
  747. IsPressButton = true;
  748. new Thread(new ThreadStart(new Action(() =>
  749. {
  750. Thread.Sleep(500);
  751. IsPressButton = false;
  752. }))).Start();
  753. }
  754. #endregion
  755. string time = GetTimeStamp();
  756. string tempPath = AppDomain.CurrentDomain.BaseDirectory + "temp\\";
  757. if (!Directory.Exists(tempPath))
  758. {
  759. Directory.CreateDirectory(tempPath);
  760. }
  761. #region 录屏批注取消画笔
  762. //string imagePath = Path.Combine(tempPath, time + ".jpg");
  763. //ImageHelper.GetScreenshot(new System.Drawing.Rectangle(0, 0, 0, 0), imagePath, true, out BitmapImage bitmap);
  764. #endregion
  765. try
  766. {
  767. if (flg == 11)
  768. {
  769. Dispatcher.Invoke(() =>
  770. {
  771. borOne.Background = new SolidColorBrush(Colors.DodgerBlue);
  772. borTwo.Background = new SolidColorBrush(Colors.DodgerBlue);
  773. });
  774. flg = 1;
  775. //this.Owner = null;
  776. APP.W_PracticeWindow.ReturnPractice();
  777. }
  778. else if (flg == 10)
  779. {
  780. Dispatcher.Invoke(() =>
  781. {
  782. borOne.Background = new SolidColorBrush(Colors.LightSkyBlue);
  783. borTwo.Background = new SolidColorBrush(Colors.DodgerBlue);
  784. });
  785. APP.W_PracticeWindow.Blue();
  786. flg = 11;
  787. }
  788. else
  789. {
  790. //new Thread(new ThreadStart(new Action(() =>
  791. //{
  792. Dispatcher.Invoke(() =>
  793. {
  794. borOne.Background = new SolidColorBrush(Colors.LightSkyBlue);
  795. borTwo.Background = new SolidColorBrush(Colors.DodgerBlue);
  796. });
  797. //}))).Start();
  798. if (APP.W_PracticeWindow == null)
  799. {
  800. APP.W_PracticeWindow = new PracticeWindow
  801. {
  802. //APP.W_PracticeWindow.Topmost = true;
  803. Width = pwidth,
  804. Height = pHeight,
  805. Left = 0,
  806. Top = 0
  807. };
  808. //practiceWin.Owner = this;
  809. }
  810. APP.W_PracticeWindow.InitPen();
  811. APP.W_PracticeWindow.InitTQLPPen();
  812. APP.W_PracticeWindow.Initialize();// imagePath);
  813. flg = 11;
  814. APP.W_PracticeWindow.Blue();
  815. APP.W_PracticeWindow.Show();
  816. new Thread(new ThreadStart(new Action(() =>
  817. {
  818. Thread.Sleep(100);
  819. Dispatcher.Invoke(() =>
  820. {
  821. //Owner = APP.W_PracticeWindow;
  822. Topmost = true;
  823. });
  824. }))).Start();
  825. }
  826. }
  827. catch (Exception ex)
  828. {
  829. LogHelper.WriteErrLog("【批注(PracticeWindow)" + ex.Message, ex);
  830. }
  831. //imgCanvas.Source = new BitmapImage(new Uri(imagePath));
  832. }
  833. /// <summary>
  834. /// 屏幕宽
  835. /// </summary>
  836. internal double pwidth = SystemParameters.PrimaryScreenWidth;
  837. /// <summary>
  838. /// 屏幕高
  839. /// </summary>
  840. internal double pHeight = SystemParameters.PrimaryScreenHeight;
  841. /// <summary>
  842. /// 获取时间戳
  843. /// </summary>
  844. /// <returns></returns>
  845. public string GetTimeStamp()
  846. {
  847. TimeSpan ts = DateTime.Now - new DateTime(1970, 1, 1, 0, 0, 0, 0);
  848. return Convert.ToInt64(ts.TotalMilliseconds).ToString();
  849. }
  850. /// <summary>
  851. /// 画笔粗细事件
  852. /// </summary>
  853. /// <param name="sender"></param>
  854. /// <param name="e"></param>
  855. private void BtnThickness_Click(object sender, RoutedEventArgs e)
  856. {
  857. gridThickness.Visibility = Visibility.Visible;
  858. gridColour.Visibility = Visibility.Collapsed;
  859. }
  860. /// <summary>
  861. /// 画笔颜色事件
  862. /// </summary>
  863. /// <param name="sender"></param>
  864. /// <param name="e"></param>
  865. private void BtnColour_Click(object sender, RoutedEventArgs e)
  866. {
  867. gridColour.Visibility = Visibility.Visible;
  868. gridThickness.Visibility = Visibility.Collapsed;
  869. }
  870. /// <summary>
  871. /// 白色
  872. /// </summary>
  873. /// <param name="sender"></param>
  874. /// <param name="e"></param>
  875. private void BtnWhite_Click(object sender, RoutedEventArgs e)
  876. {
  877. //drawingAttributes.Color = Colors.White;
  878. APP.W_PracticeWindow.White();
  879. gridColour.Visibility = Visibility.Collapsed;
  880. gridThickness.Visibility = Visibility.Collapsed;
  881. }
  882. /// <summary>
  883. /// 红色
  884. /// </summary>
  885. /// <param name="sender"></param>
  886. /// <param name="e"></param>
  887. private void BtnRed_Click(object sender, RoutedEventArgs e)
  888. {
  889. //drawingAttributes.Color = Colors.Red;
  890. APP.W_PracticeWindow.Red();
  891. gridColour.Visibility = Visibility.Collapsed;
  892. gridThickness.Visibility = Visibility.Collapsed;
  893. }
  894. /// <summary>
  895. /// 黄色
  896. /// </summary>
  897. /// <param name="sender"></param>
  898. /// <param name="e"></param>
  899. private void BtnYellow_Click(object sender, RoutedEventArgs e)
  900. {
  901. //drawingAttributes.Color = Colors.Gold;
  902. APP.W_PracticeWindow.Yellow();
  903. gridColour.Visibility = Visibility.Collapsed;
  904. gridThickness.Visibility = Visibility.Collapsed;
  905. }
  906. /// <summary>
  907. /// 青色
  908. /// </summary>
  909. /// <param name="sender"></param>
  910. /// <param name="e"></param>
  911. private void BtnCyanBlue_Click(object sender, RoutedEventArgs e)
  912. {
  913. //drawingAttributes.Color = Colors.LimeGreen;
  914. APP.W_PracticeWindow.CyanBlue();
  915. gridColour.Visibility = Visibility.Collapsed;
  916. gridThickness.Visibility = Visibility.Collapsed;
  917. }
  918. /// <summary>
  919. /// 灰色
  920. /// </summary>
  921. /// <param name="sender"></param>
  922. /// <param name="e"></param>
  923. private void BtnGray_Click(object sender, RoutedEventArgs e)
  924. {
  925. //drawingAttributes.Color = Colors.Gray;
  926. APP.W_PracticeWindow.Gray();
  927. gridColour.Visibility = Visibility.Collapsed;
  928. gridThickness.Visibility = Visibility.Collapsed;
  929. }
  930. /// <summary>
  931. /// 蓝色
  932. /// </summary>
  933. /// <param name="sender"></param>
  934. /// <param name="e"></param>
  935. private void BtnBlue_Click(object sender, RoutedEventArgs e)
  936. {
  937. //drawingAttributes.Color = Colors.DeepSkyBlue;
  938. APP.W_PracticeWindow.Blue();
  939. gridColour.Visibility = Visibility.Collapsed;
  940. gridThickness.Visibility = Visibility.Collapsed;
  941. }
  942. /// <summary>
  943. /// 画笔 细
  944. /// </summary>
  945. /// <param name="sender"></param>
  946. /// <param name="e"></param>
  947. private void BtnFine_Click(object sender, RoutedEventArgs e)
  948. {
  949. APP.W_PracticeWindow.Fine();
  950. gridColour.Visibility = Visibility.Collapsed;
  951. gridThickness.Visibility = Visibility.Collapsed;
  952. }
  953. /// <summary>
  954. /// 画笔 中
  955. /// </summary>
  956. /// <param name="sender"></param>
  957. /// <param name="e"></param>
  958. private void BtnIn_Click(object sender, RoutedEventArgs e)
  959. {
  960. APP.W_PracticeWindow.In();
  961. gridColour.Visibility = Visibility.Collapsed;
  962. gridThickness.Visibility = Visibility.Collapsed;
  963. }
  964. /// <summary>
  965. /// 画笔粗
  966. /// </summary>
  967. /// <param name="sender"></param>
  968. /// <param name="e"></param>
  969. private void BtnCrude_Click(object sender, RoutedEventArgs e)
  970. {
  971. APP.W_PracticeWindow.Crude();
  972. gridColour.Visibility = Visibility.Collapsed;
  973. gridThickness.Visibility = Visibility.Collapsed;
  974. }
  975. /// <summary>
  976. /// 橡皮
  977. /// </summary>
  978. /// <param name="sender"></param>
  979. /// <param name="e"></param>
  980. private void BtnEraser_Click(object sender, RoutedEventArgs e)
  981. {
  982. APP.W_PracticeWindow.Eraser();
  983. }
  984. /// <summary>
  985. /// 🖊
  986. /// </summary>
  987. /// <param name="sender"></param>
  988. /// <param name="e"></param>
  989. private void BtnPen_Click(object sender, RoutedEventArgs e)
  990. {
  991. APP.W_PracticeWindow.Pen();
  992. }
  993. /// <summary>
  994. /// ⚪
  995. /// </summary>
  996. /// <param name="sender"></param>
  997. /// <param name="e"></param>
  998. private void BtnRound_Click(object sender, RoutedEventArgs e)
  999. {
  1000. APP.W_PracticeWindow.Round();
  1001. }
  1002. /// <summary>
  1003. /// 矩形
  1004. /// </summary>
  1005. /// <param name="sender"></param>
  1006. /// <param name="e"></param>
  1007. private void BtnRectangle_Click(object sender, RoutedEventArgs e)
  1008. {
  1009. APP.W_PracticeWindow.Rectangle();
  1010. }
  1011. #endregion
  1012. #endregion
  1013. /// <summary>
  1014. /// 停止录屏
  1015. /// </summary>
  1016. public delegate void StopRecordingScreen();
  1017. /// <summary>
  1018. /// 停止录屏
  1019. /// </summary>
  1020. public event StopRecordingScreen Click_stopRecordingScreen;
  1021. /// <summary>
  1022. /// 黑笔
  1023. /// </summary>
  1024. /// <param name="sender"></param>
  1025. /// <param name="e"></param>
  1026. private void BtnBlackPen_Click(object sender, RoutedEventArgs e)
  1027. {
  1028. }
  1029. /// <summary>
  1030. /// 移动工具栏
  1031. /// </summary>
  1032. /// <param name="sender"></param>
  1033. /// <param name="e"></param>
  1034. private void Grid_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
  1035. {
  1036. DragMove();
  1037. }
  1038. /// <summary>
  1039. /// 红笔
  1040. /// </summary>
  1041. /// <param name="sender"></param>
  1042. /// <param name="e"></param>
  1043. private void BtnBlackPenTwo_Click(object sender, RoutedEventArgs e)
  1044. {
  1045. #region 防止连击
  1046. if (IsPressButton)
  1047. {
  1048. return;
  1049. }
  1050. else
  1051. {
  1052. IsPressButton = true;
  1053. new Thread(new ThreadStart(new Action(() =>
  1054. {
  1055. Thread.Sleep(500);
  1056. IsPressButton = false;
  1057. }))).Start();
  1058. }
  1059. #endregion
  1060. string time = GetTimeStamp();
  1061. string tempPath = AppDomain.CurrentDomain.BaseDirectory + "temp\\";
  1062. if (!Directory.Exists(tempPath))
  1063. {
  1064. Directory.CreateDirectory(tempPath);
  1065. }
  1066. #region 录屏批注取消画笔
  1067. string imagePath = Path.Combine(tempPath, time + ".jpg");
  1068. ImageHelper.GetScreenshot(new System.Drawing.Rectangle(0, 0, 0, 0), imagePath, true, out BitmapImage bitmap);
  1069. #endregion
  1070. try
  1071. {
  1072. if (flg == 10)
  1073. {
  1074. Dispatcher.Invoke(() =>
  1075. {
  1076. borOne.Background = new SolidColorBrush(Colors.DodgerBlue);
  1077. borTwo.Background = new SolidColorBrush(Colors.DodgerBlue);
  1078. });
  1079. flg = 0;
  1080. //this.Owner = null;
  1081. APP.W_PracticeWindow.ReturnPractice();
  1082. }
  1083. else if (flg == 11)
  1084. {
  1085. Dispatcher.Invoke(() =>
  1086. {
  1087. borTwo.Background = new SolidColorBrush(Colors.LightSkyBlue);
  1088. borOne.Background = new SolidColorBrush(Colors.DodgerBlue);
  1089. });
  1090. flg = 10;
  1091. APP.W_PracticeWindow.Red();
  1092. }
  1093. else
  1094. {
  1095. Dispatcher.Invoke(() =>
  1096. {
  1097. borTwo.Background = new SolidColorBrush(Colors.LightSkyBlue);
  1098. borOne.Background = new SolidColorBrush(Colors.DodgerBlue);
  1099. });
  1100. if (APP.W_PracticeWindow == null)
  1101. {
  1102. APP.W_PracticeWindow = new PracticeWindow
  1103. {
  1104. //APP.W_PracticeWindow.Topmost = true;
  1105. Width = pwidth,
  1106. Height = pHeight,
  1107. Left = 0,
  1108. Top = 0
  1109. };
  1110. //practiceWin.Owner = this;
  1111. }
  1112. APP.W_PracticeWindow.InitPen();
  1113. APP.W_PracticeWindow.InitTQLPPen();
  1114. APP.W_PracticeWindow.Initialize();//imagePath);
  1115. flg = 10;
  1116. APP.W_PracticeWindow.Red();
  1117. APP.W_PracticeWindow.Show();
  1118. new Thread(new ThreadStart(new Action(() =>
  1119. {
  1120. Thread.Sleep(100);
  1121. Dispatcher.Invoke(() =>
  1122. {
  1123. //Owner = APP.W_PracticeWindow;
  1124. Topmost = true;
  1125. });
  1126. }))).Start();
  1127. }
  1128. }
  1129. catch (Exception ex)
  1130. {
  1131. LogHelper.WriteErrLog("【批注(PracticeWindow)" + ex.Message, ex);
  1132. }
  1133. }
  1134. /// <summary>
  1135. /// 鼠标右键按下事件 废弃
  1136. /// </summary>
  1137. /// <param name="sender"></param>
  1138. /// <param name="e"></param>
  1139. private void RightButtonDown()
  1140. {
  1141. if (flg > 9)
  1142. {
  1143. Owner = null;
  1144. APP.W_PracticeWindow.Hide();
  1145. }
  1146. else
  1147. {
  1148. //string time = GetTimeStamp();
  1149. string tempPath = AppDomain.CurrentDomain.BaseDirectory + "temp\\";
  1150. if (!Directory.Exists(tempPath))
  1151. {
  1152. Directory.CreateDirectory(tempPath);
  1153. }
  1154. #region 录屏批注取消画笔
  1155. //string imagePath = Path.Combine(tempPath, time + ".jpg");
  1156. //ImageHelper.GetScreenshot(new System.Drawing.Rectangle(0, 0, 0, 0), imagePath, true, out BitmapImage bitmap);
  1157. #endregion
  1158. try
  1159. {
  1160. if (APP.W_PracticeWindow == null)
  1161. {
  1162. APP.W_PracticeWindow = new PracticeWindow
  1163. {
  1164. //APP.W_PracticeWindow.Topmost = true;
  1165. Width = pwidth,
  1166. Height = pHeight,
  1167. Left = 0,
  1168. Top = 0
  1169. };
  1170. //practiceWin.Owner = this;
  1171. }
  1172. APP.W_PracticeWindow.InitPen();
  1173. APP.W_PracticeWindow.InitTQLPPen();
  1174. APP.W_PracticeWindow.Initialize();//imagePath);
  1175. if (flg == 0)
  1176. {
  1177. flg = 10;
  1178. APP.W_PracticeWindow.Red();
  1179. }
  1180. else
  1181. {
  1182. flg = 11;
  1183. APP.W_PracticeWindow.Blue();
  1184. }
  1185. APP.W_PracticeWindow.Show();
  1186. }
  1187. catch (Exception ex)
  1188. {
  1189. LogHelper.WriteErrLog("【批注(PracticeWindow)" + ex.Message, ex);
  1190. }
  1191. }
  1192. }
  1193. /// <summary>
  1194. /// 返回主界面
  1195. /// </summary>
  1196. /// <param name="sender"></param>
  1197. /// <param name="e"></param>
  1198. private void BtnReturn_Click(object sender, RoutedEventArgs e)
  1199. {
  1200. if (!IsFirstRS)
  1201. {
  1202. MessageBoxResult br = MessageWindow.Show("退出将取消保存当前录屏,是否继续?", "提示", MessageBoxButton.OKCancel);
  1203. if (br == MessageBoxResult.Cancel)
  1204. {
  1205. return;
  1206. }
  1207. k_hook.Stop();
  1208. BtnRecordingScreen.ToolTip = "开始";
  1209. if (APP.W_MinToolbar != null)
  1210. {
  1211. APP.W_MinToolbar.Hide();
  1212. }
  1213. IsSuspend = true;
  1214. txbTime.Text = "00:00";
  1215. txbTime.Visibility = Visibility.Hidden;
  1216. End();
  1217. APP.W_PracticeWindow.ReturnPractice();
  1218. if (APP.W_PracticeWindow != null)
  1219. {
  1220. if (APP.W_PracticeWindow.Visibility == Visibility.Visible)
  1221. {
  1222. APP.W_PracticeWindow.Hide();
  1223. }
  1224. }
  1225. if (gridToolbar.Visibility == Visibility.Visible)
  1226. {
  1227. gridToolbar.Visibility = Visibility.Hidden;
  1228. gridColour.Visibility = Visibility.Hidden;
  1229. gridThickness.Visibility = Visibility.Hidden;
  1230. }
  1231. if (APP.W_XHMicroLessonSystemWindow == null)
  1232. {
  1233. APP.W_XHMicroLessonSystemWindow = new XHMicroLessonSystemWindow();
  1234. }
  1235. try
  1236. {
  1237. try
  1238. {
  1239. APP.FFmpeg.SuspendFFmpeg();
  1240. }
  1241. catch (Exception ex)
  1242. {
  1243. LogHelper.WriteErrLog("【录屏返回】(BtnStopRecordingScreen_Click)" + ex.Message, ex);
  1244. }
  1245. IsFirstRS = true;
  1246. new Thread(new ThreadStart(new Action(() =>
  1247. {
  1248. VideoInfo = null;
  1249. FileToolsCommon.DeleteDirectory(APP.WKData.WkPath + "temprs/");
  1250. }))).Start();
  1251. }
  1252. catch (Exception ex)
  1253. {
  1254. LogHelper.WriteErrLog("【录屏返回】(BtnStopRecordingScreen_Click)" + ex.Message, ex);
  1255. }
  1256. }
  1257. APP.W_XHMicroLessonSystemWindow.InitializeKeyDownEvent();
  1258. APP.W_XHMicroLessonSystemWindow.InitPen();
  1259. APP.W_XHMicroLessonSystemWindow.InitTQLPPen();
  1260. APP.W_XHMicroLessonSystemWindow.Show();
  1261. Hide();
  1262. }
  1263. /// <summary>
  1264. /// 批注退出 废弃
  1265. /// </summary>
  1266. public void ReturnPractice()
  1267. {
  1268. new Thread(new ThreadStart(new Action(() =>
  1269. {
  1270. Dispatcher.Invoke(() =>
  1271. {
  1272. borOne.Background = new SolidColorBrush(Colors.DodgerBlue);
  1273. borTwo.Background = new SolidColorBrush(Colors.DodgerBlue);
  1274. });
  1275. flg = 0;
  1276. Thread.Sleep(500);
  1277. Dispatcher.Invoke(() =>
  1278. {
  1279. Owner = null;
  1280. APP.W_PracticeWindow.Hide();
  1281. });
  1282. }))).Start();
  1283. //Dispatcher.Invoke(() =>
  1284. //{
  1285. // borOne.Background = new SolidColorBrush(Colors.DodgerBlue);
  1286. // borTwo.Background = new SolidColorBrush(Colors.DodgerBlue);
  1287. //});
  1288. //flg = 0;
  1289. //Thread.Sleep(300);
  1290. //APP.W_PracticeWindow.Hide();
  1291. }
  1292. /// <summary>
  1293. /// 修改笔状态
  1294. /// </summary>
  1295. public void ModifyState()
  1296. {
  1297. borOne.Background = new SolidColorBrush(Colors.DodgerBlue);
  1298. borTwo.Background = new SolidColorBrush(Colors.DodgerBlue);
  1299. }
  1300. /// <summary>
  1301. /// 切换页面
  1302. /// </summary>
  1303. void SwitchPages()
  1304. {
  1305. //SendKeys.SendWait("%{TAB}");
  1306. MouseEventCommon.MouseMiddleClickEvent(0);
  1307. }
  1308. bool isToobar = false;
  1309. /// <summary>
  1310. /// 在工具条区域内
  1311. /// </summary>
  1312. /// <param name="sender"></param>
  1313. /// <param name="e"></param>
  1314. private void gridToobarTwo_MouseEnter(object sender, System.Windows.Input.MouseEventArgs e)
  1315. {
  1316. isToobar = true;
  1317. }
  1318. private void gridToobarTwo_MouseLeave(object sender, System.Windows.Input.MouseEventArgs e)
  1319. {
  1320. if (BtnRecordingScreen.ToolTip.ToString().Equals("暂停") && gridToobar.Visibility == Visibility.Visible)
  1321. {
  1322. if (APP.IsHideSRTool)
  1323. {
  1324. if (APP.W_MinToolbar == null)
  1325. {
  1326. APP.W_MinToolbar = new MinToolbar();
  1327. }
  1328. APP.W_MinToolbar.Topmost = true;
  1329. APP.W_MinToolbar.Initialize(this.Top);
  1330. //else
  1331. //{
  1332. // APP.W_CountdownWindow.Initialize(true, 1800);
  1333. //}
  1334. new Thread(new ThreadStart(new Action(() =>
  1335. {
  1336. Thread.Sleep(500);
  1337. Dispatcher.Invoke(() =>
  1338. {
  1339. gridToobar.Visibility = Visibility.Hidden;
  1340. APP.W_MinToolbar.Show();
  1341. });
  1342. }))).Start();
  1343. //Console.WriteLine(this.Top+"max");
  1344. }
  1345. }
  1346. }
  1347. }
  1348. }