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

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