星火微课系统客户端
Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

ScreenRecordingToolbarWindow.xaml.cs 51KB

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