星火微课系统客户端
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

ScreenRecordingToolbarWindow.xaml.cs 55KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431
  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. 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. //if (APP.SkinStyle == "1")
  388. //{
  389. // ColorType = 0;
  390. // MinToolTop = this.Top + ((this.ActualHeight - btnReturn.ActualHeight) / 2);//(VbxBlue.ActualHeight -)
  391. //}
  392. //else if (APP.SkinStyle == "2")
  393. //{
  394. //MinToolTop = this.Top + ((this.ActualHeight - VbxBlack.ActualHeight) / 2);
  395. //}
  396. APP.W_MinToolbar.Initialize(MinToolTop,ActualHeight);
  397. APP.W_MinToolbar.Show();
  398. }
  399. #endregion
  400. try
  401. {
  402. #region 4秒内不可点击
  403. new Thread(new ThreadStart(new Action(() =>
  404. {
  405. //Dispatcher.Invoke(() =>
  406. //{
  407. // ImgEndRecordingScreen.Source = new BitmapImage(new Uri("pack://application:,,,/Images/Toobar15.png"));
  408. // BtnRecordingScreen.IsEnabled = false;
  409. // BtnStopRecordingScreen.IsEnabled = false;
  410. //});
  411. //Thread.Sleep(4000);
  412. Dispatcher.Invoke(() =>
  413. {
  414. BtnRecordingScreen.IsEnabled = true;
  415. BtnStopRecordingScreen.IsEnabled = true;
  416. BtnRecordingScreenPause.IsEnabled = true;
  417. });
  418. }))).Start();
  419. #endregion
  420. new Thread(new ThreadStart(new Action(() =>
  421. {
  422. if (IsFirstRS)
  423. {
  424. Thread.Sleep(800);
  425. }
  426. if (APP.FFmpeg.myProcess != null)
  427. {
  428. Thread.Sleep(100);
  429. }
  430. System.Drawing.Size DesktopSize = PrimaryScreen.DESKTOP;
  431. bool IsRecordingSound = FileToolsCommon.GetConfigValue("IsRecordingSound") == "1";
  432. bool IsRecordingMicrophone = FileToolsCommon.GetConfigValue("IsRecordingMicrophone") == "1";
  433. bool SynRes = APP.FFmpeg.StartRecordingVideo(VideoSavePathName, DesktopSize, IsRecordingSound, IsRecordingMicrophone, out string ErrMessage, APP.MicrophoneName);
  434. Thread.Sleep(1300);
  435. Dispatcher.Invoke(() =>
  436. {
  437. if (!SynRes)
  438. {
  439. MessageWindow.Show(ErrMessage);
  440. //隐藏画笔工具栏
  441. //BtnToolbarDown_Click(null, null);
  442. //gridToolbar.Visibility = Visibility.Hidden;
  443. //gridColour.Visibility = Visibility.Hidden;
  444. //gridThickness.Visibility = Visibility.Hidden;
  445. BtnRecordingScreen.Visibility = Visibility.Visible;
  446. BtnRecordingScreenPause.Visibility = Visibility.Collapsed;
  447. BtnStopRecordingScreen.IsEnabled = false; //停止录制按钮不点击
  448. BtnPenBlue.IsEnabled = false;//蓝笔不可点击
  449. BtnPenRed.IsEnabled = false;//红笔不可点击
  450. BtnPenBlue.Visibility = Visibility.Visible;
  451. BtnPenRed.Visibility = Visibility.Visible;
  452. BtnPenBlue_CL.Visibility = Visibility.Collapsed;
  453. BtnPenRed_CL.Visibility = Visibility.Collapsed;
  454. IsSuspend = true;
  455. IsFirstRS = true;
  456. return;
  457. }
  458. Stack();
  459. });
  460. }))).Start();
  461. }
  462. catch (Exception ex)
  463. {
  464. MessageWindow.Show(ex.Message);
  465. }
  466. IsFirstRS = false;
  467. }
  468. else
  469. {
  470. TimeOut();
  471. IsSuspend = true;
  472. BtnRecordingScreen.Visibility = Visibility.Visible;
  473. BtnRecordingScreenPause.Visibility = Visibility.Collapsed;
  474. BtnStopRecordingScreen.IsEnabled = false; //停止录制按钮不点击
  475. //imgBlackPenOne.Source = new BitmapImage(new Uri("pack://application:,,,/Images/31.png"));
  476. //btnBlackPenOne.IsEnabled = false;//蓝笔不可点击
  477. //imgBlackPenTwo.Source = new BitmapImage(new Uri("pack://application:,,,/Images/31.png"));
  478. //btnBlackPenTwo.IsEnabled = false;//红笔不可点击
  479. #region 2秒内不可点击
  480. new Thread(new ThreadStart(new Action(() =>
  481. {
  482. //Dispatcher.Invoke(() =>
  483. //{
  484. // ImgEndRecordingScreen.Source = new BitmapImage(new Uri("pack://application:,,,/Images/Toobar15.png"));
  485. // BtnRecordingScreen.IsEnabled = false;
  486. // BtnStopRecordingScreen.IsEnabled = false;
  487. //});
  488. //Thread.Sleep(2000);
  489. Dispatcher.Invoke(() =>
  490. {
  491. BtnRecordingScreen.IsEnabled = true;
  492. BtnStopRecordingScreen.IsEnabled = true;
  493. });
  494. }))).Start();
  495. #endregion
  496. try
  497. {
  498. APP.FFmpeg.SuspendFFmpeg();
  499. }
  500. catch (Exception ex)
  501. {
  502. MessageWindow.Show(ex.Message);
  503. }
  504. }
  505. }
  506. /// <summary>
  507. /// 停止录像
  508. /// </summary>
  509. /// <param name="sender"></param>
  510. /// <param name="e"></param>
  511. private void BtnStopRecordingScreen_Click(object sender, RoutedEventArgs e)
  512. {
  513. #region 防止连击
  514. if (IsPressButton)
  515. {
  516. return;
  517. }
  518. else
  519. {
  520. IsPressButton = true;
  521. new Thread(new ThreadStart(new Action(() =>
  522. {
  523. Thread.Sleep(500);
  524. IsPressButton = false;
  525. }))).Start();
  526. }
  527. #endregion
  528. BtnRecordingScreen.ToolTip = "开始";
  529. k_hook.Stop();
  530. IsSuspend = true;
  531. TxbTime.Content = "00:00";
  532. End();
  533. if (APP.W_PracticeWindow != null)
  534. {
  535. if (APP.W_PracticeWindow.Visibility == Visibility.Visible)
  536. {
  537. Owner = null;
  538. APP.W_PracticeWindow.ReturnPractice();
  539. }
  540. }
  541. //if (gridToolbar.Visibility == Visibility.Visible)
  542. //{
  543. // GridSrToobar.Visibility = Visibility.Visible;
  544. // gridToolbar.Visibility = Visibility.Hidden;
  545. // gridColour.Visibility = Visibility.Hidden;
  546. // gridThickness.Visibility = Visibility.Hidden;
  547. //}
  548. if (APP.W_XHMicroLessonSystemWindow == null)
  549. {
  550. APP.W_XHMicroLessonSystemWindow = new XHMicroLessonSystemWindow();
  551. }
  552. APP.W_XHMicroLessonSystemWindow.InitializeKeyDownEvent();
  553. APP.W_XHMicroLessonSystemWindow.InitPen();
  554. APP.W_XHMicroLessonSystemWindow.InitTQLPPen();
  555. APP.W_XHMicroLessonSystemWindow.Show();
  556. if (!IsFirstRS)
  557. {
  558. try
  559. {
  560. if (SRTime.Hour > 0 || SRTime.Minute > 0 || SRTime.Second > 3)
  561. {
  562. try
  563. {
  564. APP.FFmpeg.StopFFmpeg(VideoSavePathName);
  565. }
  566. catch (Exception ex)
  567. {
  568. LogHelper.WriteErrLog("【停止录屏】(BtnStopRecordingScreen_Click)" + ex.Message, ex);
  569. }
  570. IsFirstRS = true;
  571. //生成缩略图
  572. string ThumbnailPath = FileToolsCommon.GetDirectoryName(VideoSavePathName) + "ThumbnailPath/";
  573. FileToolsCommon.CreateDirectory(ThumbnailPath);
  574. //缩略图存储位置
  575. string ThumbnailPathName = ThumbnailPath + FileToolsCommon.GetIOFileName(VideoSavePathName).Replace(".", "") + ".JPG";
  576. new Thread(new ThreadStart(new Action(() =>
  577. {
  578. while (!FileToolsCommon.IsExistFile(VideoSavePathName))
  579. {
  580. Thread.Sleep(100);
  581. }
  582. FileToolsCommon.DeleteFile(ThumbnailPathName);
  583. //VideoInfo.VideoSize = FileToolsCommon.GetFileSizeByMB(VideoSavePathName).ToString() + " MB";
  584. VideoInfo.RSTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  585. VideoInfo.VideoPath = VideoSavePathName;
  586. VideoInfo.ThumbnailPath = ThumbnailPathName;
  587. APP.FFmpeg.GenerateThumbnails(VideoSavePathName, ThumbnailPathName, 200, 130);
  588. VideoInfo.FileGuid = Guid.NewGuid().ToString();
  589. VideoInfo.IsUpload = false;
  590. VideoInfo.Uploaded = 0;
  591. //VideoInfo.Savefolder = APP.UserInfo.Schoolid + "/resource";
  592. if (!APP.VideoList.Exists(x => x.FileGuid == VideoInfo.FileGuid) || !APP.VideoList.Exists(x => x.VideoPath == VideoInfo.VideoPath))
  593. {
  594. APP.VideoList.Add(VideoInfo);
  595. //保存数据
  596. APP.SaveWkData();
  597. }
  598. }))).Start();
  599. Click_stopRecordingScreen();
  600. }
  601. else
  602. {
  603. //视频过短
  604. APP.FFmpeg.SuspendFFmpeg();
  605. IsFirstRS = true;
  606. MessageWindow.Show("录屏时间过短,请重新录制!");
  607. }
  608. new Thread(new ThreadStart(new Action(() =>
  609. {
  610. Thread.Sleep(700);
  611. Dispatcher.Invoke(() =>
  612. {
  613. if (APP.W_MinToolbar != null)
  614. {
  615. APP.W_MinToolbar.Hide();
  616. }
  617. });
  618. }))).Start();
  619. }
  620. catch (Exception ex)
  621. {
  622. LogHelper.WriteErrLog("【停止录屏】(BtnStopRecordingScreen_Click)" + ex.Message, ex);
  623. }
  624. }
  625. Hide();
  626. }
  627. public void MaxToobar()
  628. {
  629. Graphics graphics = Graphics.FromHwnd(IntPtr.Zero);
  630. float DIP = graphics.DpiX;
  631. //float DIPY = graphics.DpiY;
  632. APP.W_ScreenRecordingToolbarWindow.Left = PrimaryScreen.WorkingArea.Width / (DIP / 96) - APP.W_ScreenRecordingToolbarWindow.Width;
  633. GridSrToobar.Visibility = Visibility.Visible;
  634. APP.W_ScreenRecordingToolbarWindow.Topmost = true;
  635. }
  636. #endregion
  637. #region 画笔相关
  638. /// <summary>
  639. /// 画笔工具栏关闭事件
  640. /// </summary>
  641. /// <param name="sender"></param>
  642. /// <param name="e"></param>
  643. private void BtnToolbarDown_Click(object sender, RoutedEventArgs e)
  644. {
  645. gridToolbar.Visibility = Visibility.Hidden;
  646. gridColour.Visibility = Visibility.Hidden;
  647. gridThickness.Visibility = Visibility.Hidden;
  648. APP.W_PracticeWindow.Hide();
  649. }
  650. /// <summary>
  651. /// 笔调用批注
  652. /// </summary>
  653. public void PenPractice()
  654. {
  655. if (!IsFirstRS)
  656. {
  657. if (flg != 11 && flg != 10)
  658. {
  659. #region 防止连击
  660. if (IsPressButton)
  661. {
  662. return;
  663. }
  664. else
  665. {
  666. IsPressButton = true;
  667. new Thread(new ThreadStart(new Action(() =>
  668. {
  669. Thread.Sleep(500);
  670. IsPressButton = false;
  671. }))).Start();
  672. }
  673. #endregion
  674. string time = GetTimeStamp();
  675. string tempPath = AppDomain.CurrentDomain.BaseDirectory + "temp\\";
  676. if (!Directory.Exists(tempPath))
  677. {
  678. Directory.CreateDirectory(tempPath);
  679. }
  680. try
  681. {
  682. Dispatcher.Invoke(() =>
  683. {
  684. //borOne.Background = new SolidColorBrush(Colors.LightSkyBlue);
  685. //borTwo.Background = new SolidColorBrush(Colors.DodgerBlue);
  686. if (APP.W_PracticeWindow == null)
  687. {
  688. APP.W_PracticeWindow = new PracticeWindow
  689. {
  690. Width = pwidth,
  691. Height = pHeight,
  692. Left = 0,
  693. Top = 0
  694. };
  695. //practiceWin.Owner = this;
  696. }
  697. //APP.W_PracticeWindow.InitPen();
  698. //APP.W_PracticeWindow.InitTQLPPen();
  699. APP.W_PracticeWindow.Initialize();// imagePath);
  700. flg = 11;
  701. APP.W_PracticeWindow.Blue();
  702. APP.W_PracticeWindow.Show();
  703. APP.W_PracticeWindow.Topmost = true;
  704. APP.W_PracticeWindow.Focus();
  705. });
  706. new Thread(new ThreadStart(new Action(() =>
  707. {
  708. Dispatcher.Invoke(() =>
  709. {
  710. APP.W_PracticeWindow.Topmost = false;
  711. });
  712. Thread.Sleep(500);
  713. Dispatcher.Invoke(() =>
  714. {
  715. //Owner = APP.W_PracticeWindow;
  716. Topmost = true;
  717. });
  718. }))).Start();
  719. }
  720. catch (Exception ex)
  721. {
  722. LogHelper.WriteErrLog("【批注(PracticeWindow)" + ex.Message, ex);
  723. }
  724. }
  725. }
  726. }
  727. /// <summary>
  728. /// 画笔点击事件
  729. /// </summary>
  730. /// <param name="sender"></param>
  731. /// <param name="e"></param>
  732. private void BtnBrush_Click(object sender, RoutedEventArgs e)
  733. {
  734. if(BtnPenBlue.Visibility!= Visibility.Visible)
  735. {
  736. return;
  737. }
  738. #region 防止连击
  739. if (IsPressButton)
  740. {
  741. return;
  742. }
  743. else
  744. {
  745. IsPressButton = true;
  746. new Thread(new ThreadStart(new Action(() =>
  747. {
  748. Thread.Sleep(500);
  749. IsPressButton = false;
  750. }))).Start();
  751. }
  752. #endregion
  753. BtnPenBlue.Visibility = Visibility.Collapsed;
  754. BtnPenRed.Visibility = Visibility.Visible;
  755. BtnPenBlue_CL.Visibility = Visibility.Visible;
  756. BtnPenRed_CL.Visibility = Visibility.Collapsed;
  757. string time = GetTimeStamp();
  758. string tempPath = AppDomain.CurrentDomain.BaseDirectory + "temp\\";
  759. if (!Directory.Exists(tempPath))
  760. {
  761. Directory.CreateDirectory(tempPath);
  762. }
  763. #region 录屏批注取消画笔
  764. //string imagePath = Path.Combine(tempPath, time + ".jpg");
  765. //ImageHelper.GetScreenshot(new System.Drawing.Rectangle(0, 0, 0, 0), imagePath, true, out BitmapImage bitmap);
  766. #endregion
  767. try
  768. {
  769. if (flg == 11)
  770. {
  771. //Dispatcher.Invoke(() =>
  772. //{
  773. // borOne.Background = new SolidColorBrush(Colors.DodgerBlue);
  774. // borTwo.Background = new SolidColorBrush(Colors.DodgerBlue);
  775. //});
  776. flg = 1;
  777. //this.Owner = null;
  778. APP.W_PracticeWindow.ReturnPractice();
  779. }
  780. else if (flg == 10)
  781. {
  782. //Dispatcher.Invoke(() =>
  783. //{
  784. // borOne.Background = new SolidColorBrush(Colors.LightSkyBlue);
  785. // borTwo.Background = new SolidColorBrush(Colors.DodgerBlue);
  786. //});
  787. APP.W_PracticeWindow.Blue();
  788. flg = 11;
  789. }
  790. else
  791. {
  792. //new Thread(new ThreadStart(new Action(() =>
  793. //{
  794. //Dispatcher.Invoke(() =>
  795. //{
  796. // borOne.Background = new SolidColorBrush(Colors.LightSkyBlue);
  797. // borTwo.Background = new SolidColorBrush(Colors.DodgerBlue);
  798. //});
  799. //}))).Start();
  800. if (APP.W_PracticeWindow == null)
  801. {
  802. APP.W_PracticeWindow = new PracticeWindow
  803. {
  804. //APP.W_PracticeWindow.Topmost = true;
  805. Width = pwidth,
  806. Height = pHeight,
  807. Left = 0,
  808. Top = 0
  809. };
  810. //practiceWin.Owner = this;
  811. }
  812. APP.W_PracticeWindow.InitPen();
  813. APP.W_PracticeWindow.InitTQLPPen();
  814. APP.W_PracticeWindow.Initialize();// imagePath);
  815. flg = 11;
  816. APP.W_PracticeWindow.Blue();
  817. APP.W_PracticeWindow.Show();
  818. new Thread(new ThreadStart(new Action(() =>
  819. {
  820. Thread.Sleep(100);
  821. Dispatcher.Invoke(() =>
  822. {
  823. //Owner = APP.W_PracticeWindow;
  824. Topmost = true;
  825. });
  826. }))).Start();
  827. }
  828. }
  829. catch (Exception ex)
  830. {
  831. LogHelper.WriteErrLog("【批注(PracticeWindow)" + ex.Message, ex);
  832. }
  833. //imgCanvas.Source = new BitmapImage(new Uri(imagePath));
  834. }
  835. /// <summary>
  836. /// 屏幕宽
  837. /// </summary>
  838. internal double pwidth = SystemParameters.PrimaryScreenWidth;
  839. /// <summary>
  840. /// 屏幕高
  841. /// </summary>
  842. internal double pHeight = SystemParameters.PrimaryScreenHeight;
  843. /// <summary>
  844. /// 获取时间戳
  845. /// </summary>
  846. /// <returns></returns>
  847. public string GetTimeStamp()
  848. {
  849. TimeSpan ts = DateTime.Now - new DateTime(1970, 1, 1, 0, 0, 0, 0);
  850. return Convert.ToInt64(ts.TotalMilliseconds).ToString();
  851. }
  852. /// <summary>
  853. /// 画笔粗细事件
  854. /// </summary>
  855. /// <param name="sender"></param>
  856. /// <param name="e"></param>
  857. private void BtnThickness_Click(object sender, RoutedEventArgs e)
  858. {
  859. gridThickness.Visibility = Visibility.Visible;
  860. gridColour.Visibility = Visibility.Collapsed;
  861. }
  862. /// <summary>
  863. /// 画笔颜色事件
  864. /// </summary>
  865. /// <param name="sender"></param>
  866. /// <param name="e"></param>
  867. private void BtnColour_Click(object sender, RoutedEventArgs e)
  868. {
  869. gridColour.Visibility = Visibility.Visible;
  870. gridThickness.Visibility = Visibility.Collapsed;
  871. }
  872. /// <summary>
  873. /// 白色
  874. /// </summary>
  875. /// <param name="sender"></param>
  876. /// <param name="e"></param>
  877. private void BtnWhite_Click(object sender, RoutedEventArgs e)
  878. {
  879. //drawingAttributes.Color = Colors.White;
  880. APP.W_PracticeWindow.White();
  881. gridColour.Visibility = Visibility.Collapsed;
  882. gridThickness.Visibility = Visibility.Collapsed;
  883. }
  884. /// <summary>
  885. /// 红色
  886. /// </summary>
  887. /// <param name="sender"></param>
  888. /// <param name="e"></param>
  889. private void BtnRed_Click(object sender, RoutedEventArgs e)
  890. {
  891. //drawingAttributes.Color = Colors.Red;
  892. APP.W_PracticeWindow.Red();
  893. gridColour.Visibility = Visibility.Collapsed;
  894. gridThickness.Visibility = Visibility.Collapsed;
  895. }
  896. /// <summary>
  897. /// 黄色
  898. /// </summary>
  899. /// <param name="sender"></param>
  900. /// <param name="e"></param>
  901. private void BtnYellow_Click(object sender, RoutedEventArgs e)
  902. {
  903. //drawingAttributes.Color = Colors.Gold;
  904. APP.W_PracticeWindow.Yellow();
  905. gridColour.Visibility = Visibility.Collapsed;
  906. gridThickness.Visibility = Visibility.Collapsed;
  907. }
  908. /// <summary>
  909. /// 青色
  910. /// </summary>
  911. /// <param name="sender"></param>
  912. /// <param name="e"></param>
  913. private void BtnCyanBlue_Click(object sender, RoutedEventArgs e)
  914. {
  915. //drawingAttributes.Color = Colors.LimeGreen;
  916. APP.W_PracticeWindow.CyanBlue();
  917. gridColour.Visibility = Visibility.Collapsed;
  918. gridThickness.Visibility = Visibility.Collapsed;
  919. }
  920. /// <summary>
  921. /// 灰色
  922. /// </summary>
  923. /// <param name="sender"></param>
  924. /// <param name="e"></param>
  925. private void BtnGray_Click(object sender, RoutedEventArgs e)
  926. {
  927. //drawingAttributes.Color = Colors.Gray;
  928. APP.W_PracticeWindow.Gray();
  929. gridColour.Visibility = Visibility.Collapsed;
  930. gridThickness.Visibility = Visibility.Collapsed;
  931. }
  932. /// <summary>
  933. /// 蓝色
  934. /// </summary>
  935. /// <param name="sender"></param>
  936. /// <param name="e"></param>
  937. private void BtnBlue_Click(object sender, RoutedEventArgs e)
  938. {
  939. //drawingAttributes.Color = Colors.DeepSkyBlue;
  940. APP.W_PracticeWindow.Blue();
  941. gridColour.Visibility = Visibility.Collapsed;
  942. gridThickness.Visibility = Visibility.Collapsed;
  943. }
  944. /// <summary>
  945. /// 画笔 细
  946. /// </summary>
  947. /// <param name="sender"></param>
  948. /// <param name="e"></param>
  949. private void BtnFine_Click(object sender, RoutedEventArgs e)
  950. {
  951. APP.W_PracticeWindow.Fine();
  952. gridColour.Visibility = Visibility.Collapsed;
  953. gridThickness.Visibility = Visibility.Collapsed;
  954. }
  955. /// <summary>
  956. /// 画笔 中
  957. /// </summary>
  958. /// <param name="sender"></param>
  959. /// <param name="e"></param>
  960. private void BtnIn_Click(object sender, RoutedEventArgs e)
  961. {
  962. APP.W_PracticeWindow.In();
  963. gridColour.Visibility = Visibility.Collapsed;
  964. gridThickness.Visibility = Visibility.Collapsed;
  965. }
  966. /// <summary>
  967. /// 画笔粗
  968. /// </summary>
  969. /// <param name="sender"></param>
  970. /// <param name="e"></param>
  971. private void BtnCrude_Click(object sender, RoutedEventArgs e)
  972. {
  973. APP.W_PracticeWindow.Crude();
  974. gridColour.Visibility = Visibility.Collapsed;
  975. gridThickness.Visibility = Visibility.Collapsed;
  976. }
  977. /// <summary>
  978. /// 橡皮
  979. /// </summary>
  980. /// <param name="sender"></param>
  981. /// <param name="e"></param>
  982. private void BtnEraser_Click(object sender, RoutedEventArgs e)
  983. {
  984. APP.W_PracticeWindow.Eraser();
  985. }
  986. /// <summary>
  987. /// 🖊
  988. /// </summary>
  989. /// <param name="sender"></param>
  990. /// <param name="e"></param>
  991. private void BtnPen_Click(object sender, RoutedEventArgs e)
  992. {
  993. APP.W_PracticeWindow.Pen();
  994. }
  995. /// <summary>
  996. /// ⚪
  997. /// </summary>
  998. /// <param name="sender"></param>
  999. /// <param name="e"></param>
  1000. private void BtnRound_Click(object sender, RoutedEventArgs e)
  1001. {
  1002. APP.W_PracticeWindow.Round();
  1003. }
  1004. /// <summary>
  1005. /// 矩形
  1006. /// </summary>
  1007. /// <param name="sender"></param>
  1008. /// <param name="e"></param>
  1009. private void BtnRectangle_Click(object sender, RoutedEventArgs e)
  1010. {
  1011. APP.W_PracticeWindow.Rectangle();
  1012. }
  1013. #endregion
  1014. #endregion
  1015. /// <summary>
  1016. /// 停止录屏
  1017. /// </summary>
  1018. public delegate void StopRecordingScreen();
  1019. /// <summary>
  1020. /// 停止录屏
  1021. /// </summary>
  1022. public event StopRecordingScreen Click_stopRecordingScreen;
  1023. /// <summary>
  1024. /// 黑笔
  1025. /// </summary>
  1026. /// <param name="sender"></param>
  1027. /// <param name="e"></param>
  1028. private void BtnBlackPen_Click(object sender, RoutedEventArgs e)
  1029. {
  1030. }
  1031. /// <summary>
  1032. /// 移动工具栏
  1033. /// </summary>
  1034. /// <param name="sender"></param>
  1035. /// <param name="e"></param>
  1036. private void Grid_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
  1037. {
  1038. DragMove();
  1039. }
  1040. /// <summary>
  1041. /// 红笔
  1042. /// </summary>
  1043. /// <param name="sender"></param>
  1044. /// <param name="e"></param>
  1045. private void BtnBlackPenTwo_Click(object sender, RoutedEventArgs e)
  1046. {
  1047. if (BtnPenRed.Visibility != Visibility.Visible)
  1048. {
  1049. return;
  1050. }
  1051. #region 防止连击
  1052. if (IsPressButton)
  1053. {
  1054. return;
  1055. }
  1056. else
  1057. {
  1058. IsPressButton = true;
  1059. new Thread(new ThreadStart(new Action(() =>
  1060. {
  1061. Thread.Sleep(500);
  1062. IsPressButton = false;
  1063. }))).Start();
  1064. }
  1065. #endregion
  1066. BtnPenBlue.Visibility = Visibility.Visible;
  1067. BtnPenRed.Visibility = Visibility.Collapsed;
  1068. BtnPenBlue_CL.Visibility = Visibility.Collapsed;
  1069. BtnPenRed_CL.Visibility = Visibility.Visible;
  1070. string time = GetTimeStamp();
  1071. string tempPath = AppDomain.CurrentDomain.BaseDirectory + "temp\\";
  1072. if (!Directory.Exists(tempPath))
  1073. {
  1074. Directory.CreateDirectory(tempPath);
  1075. }
  1076. #region 录屏批注取消画笔
  1077. string imagePath = Path.Combine(tempPath, time + ".jpg");
  1078. ImageHelper.GetScreenshot(new System.Drawing.Rectangle(0, 0, 0, 0), imagePath, true, out BitmapImage bitmap);
  1079. #endregion
  1080. try
  1081. {
  1082. if (flg == 10)
  1083. {
  1084. //Dispatcher.Invoke(() =>
  1085. //{
  1086. // borOne.Background = new SolidColorBrush(Colors.DodgerBlue);
  1087. // borTwo.Background = new SolidColorBrush(Colors.DodgerBlue);
  1088. //});
  1089. flg = 0;
  1090. //this.Owner = null;
  1091. APP.W_PracticeWindow.ReturnPractice();
  1092. }
  1093. else if (flg == 11)
  1094. {
  1095. //Dispatcher.Invoke(() =>
  1096. //{
  1097. // borTwo.Background = new SolidColorBrush(Colors.LightSkyBlue);
  1098. // borOne.Background = new SolidColorBrush(Colors.DodgerBlue);
  1099. //});
  1100. flg = 10;
  1101. APP.W_PracticeWindow.Red();
  1102. }
  1103. else
  1104. {
  1105. //Dispatcher.Invoke(() =>
  1106. //{
  1107. // borTwo.Background = new SolidColorBrush(Colors.LightSkyBlue);
  1108. // borOne.Background = new SolidColorBrush(Colors.DodgerBlue);
  1109. //});
  1110. if (APP.W_PracticeWindow == null)
  1111. {
  1112. APP.W_PracticeWindow = new PracticeWindow
  1113. {
  1114. //APP.W_PracticeWindow.Topmost = true;
  1115. Width = pwidth,
  1116. Height = pHeight,
  1117. Left = 0,
  1118. Top = 0
  1119. };
  1120. //practiceWin.Owner = this;
  1121. }
  1122. APP.W_PracticeWindow.InitPen();
  1123. APP.W_PracticeWindow.InitTQLPPen();
  1124. APP.W_PracticeWindow.Initialize();//imagePath);
  1125. flg = 10;
  1126. APP.W_PracticeWindow.Red();
  1127. APP.W_PracticeWindow.Show();
  1128. new Thread(new ThreadStart(new Action(() =>
  1129. {
  1130. Thread.Sleep(100);
  1131. Dispatcher.Invoke(() =>
  1132. {
  1133. //Owner = APP.W_PracticeWindow;
  1134. Topmost = true;
  1135. });
  1136. }))).Start();
  1137. }
  1138. }
  1139. catch (Exception ex)
  1140. {
  1141. LogHelper.WriteErrLog("【批注(PracticeWindow)" + ex.Message, ex);
  1142. }
  1143. }
  1144. /// <summary>
  1145. /// 鼠标右键按下事件 废弃
  1146. /// </summary>
  1147. /// <param name="sender"></param>
  1148. /// <param name="e"></param>
  1149. private void RightButtonDown()
  1150. {
  1151. if (flg > 9)
  1152. {
  1153. Owner = null;
  1154. APP.W_PracticeWindow.Hide();
  1155. }
  1156. else
  1157. {
  1158. //string time = GetTimeStamp();
  1159. string tempPath = AppDomain.CurrentDomain.BaseDirectory + "temp\\";
  1160. if (!Directory.Exists(tempPath))
  1161. {
  1162. Directory.CreateDirectory(tempPath);
  1163. }
  1164. #region 录屏批注取消画笔
  1165. //string imagePath = Path.Combine(tempPath, time + ".jpg");
  1166. //ImageHelper.GetScreenshot(new System.Drawing.Rectangle(0, 0, 0, 0), imagePath, true, out BitmapImage bitmap);
  1167. #endregion
  1168. try
  1169. {
  1170. if (APP.W_PracticeWindow == null)
  1171. {
  1172. APP.W_PracticeWindow = new PracticeWindow
  1173. {
  1174. //APP.W_PracticeWindow.Topmost = true;
  1175. Width = pwidth,
  1176. Height = pHeight,
  1177. Left = 0,
  1178. Top = 0
  1179. };
  1180. //practiceWin.Owner = this;
  1181. }
  1182. APP.W_PracticeWindow.InitPen();
  1183. APP.W_PracticeWindow.InitTQLPPen();
  1184. APP.W_PracticeWindow.Initialize();//imagePath);
  1185. if (flg == 0)
  1186. {
  1187. flg = 10;
  1188. APP.W_PracticeWindow.Red();
  1189. }
  1190. else
  1191. {
  1192. flg = 11;
  1193. APP.W_PracticeWindow.Blue();
  1194. }
  1195. APP.W_PracticeWindow.Show();
  1196. }
  1197. catch (Exception ex)
  1198. {
  1199. LogHelper.WriteErrLog("【批注(PracticeWindow)" + ex.Message, ex);
  1200. }
  1201. }
  1202. }
  1203. /// <summary>
  1204. /// 返回主界面
  1205. /// </summary>
  1206. /// <param name="sender"></param>
  1207. /// <param name="e"></param>
  1208. private void BtnReturn_Click(object sender, RoutedEventArgs e)
  1209. {
  1210. if (!IsFirstRS)
  1211. {
  1212. MessageBoxResult br = MessageWindow.Show("退出将取消保存当前录屏,是否继续?", "提示", MessageBoxButton.OKCancel);
  1213. if (br == MessageBoxResult.Cancel)
  1214. {
  1215. return;
  1216. }
  1217. k_hook.Stop();
  1218. BtnRecordingScreen.ToolTip = "开始";
  1219. IsSuspend = true;
  1220. TxbTime.Content = "00:00";
  1221. End();
  1222. APP.W_PracticeWindow.ReturnPractice();
  1223. if (APP.W_PracticeWindow != null)
  1224. {
  1225. if (APP.W_PracticeWindow.Visibility == Visibility.Visible)
  1226. {
  1227. APP.W_PracticeWindow.Hide();
  1228. }
  1229. }
  1230. if (gridToolbar.Visibility == Visibility.Visible)
  1231. {
  1232. gridToolbar.Visibility = Visibility.Hidden;
  1233. gridColour.Visibility = Visibility.Hidden;
  1234. gridThickness.Visibility = Visibility.Hidden;
  1235. }
  1236. if (APP.W_XHMicroLessonSystemWindow == null)
  1237. {
  1238. APP.W_XHMicroLessonSystemWindow = new XHMicroLessonSystemWindow();
  1239. }
  1240. try
  1241. {
  1242. try
  1243. {
  1244. APP.FFmpeg.SuspendFFmpeg();
  1245. }
  1246. catch (Exception ex)
  1247. {
  1248. LogHelper.WriteErrLog("【录屏返回】(BtnStopRecordingScreen_Click)" + ex.Message, ex);
  1249. }
  1250. IsFirstRS = true;
  1251. new Thread(new ThreadStart(new Action(() =>
  1252. {
  1253. VideoInfo = null;
  1254. FileToolsCommon.DeleteDirectory(APP.WKData.WkPath + "temprs/");
  1255. }))).Start();
  1256. }
  1257. catch (Exception ex)
  1258. {
  1259. LogHelper.WriteErrLog("【录屏返回】(BtnStopRecordingScreen_Click)" + ex.Message, ex);
  1260. }
  1261. }
  1262. APP.W_XHMicroLessonSystemWindow.InitializeKeyDownEvent();
  1263. APP.W_XHMicroLessonSystemWindow.InitPen();
  1264. APP.W_XHMicroLessonSystemWindow.InitTQLPPen();
  1265. APP.W_XHMicroLessonSystemWindow.Show();
  1266. new Thread(new ThreadStart(new Action(() =>
  1267. {
  1268. Thread.Sleep(700);
  1269. Dispatcher.Invoke(() =>
  1270. {
  1271. if (APP.W_MinToolbar != null)
  1272. {
  1273. APP.W_MinToolbar.Hide();
  1274. }
  1275. });
  1276. }))).Start();
  1277. Hide();
  1278. }
  1279. /// <summary>
  1280. /// 批注退出 废弃
  1281. /// </summary>
  1282. public void ReturnPractice()
  1283. {
  1284. new Thread(new ThreadStart(new Action(() =>
  1285. {
  1286. //Dispatcher.Invoke(() =>
  1287. //{
  1288. // borOne.Background = new SolidColorBrush(Colors.DodgerBlue);
  1289. // borTwo.Background = new SolidColorBrush(Colors.DodgerBlue);
  1290. //});
  1291. flg = 0;
  1292. Thread.Sleep(500);
  1293. Dispatcher.Invoke(() =>
  1294. {
  1295. Owner = null;
  1296. APP.W_PracticeWindow.Hide();
  1297. });
  1298. }))).Start();
  1299. }
  1300. /// <summary>
  1301. /// 修改笔状态
  1302. /// </summary>
  1303. public void ModifyState()
  1304. {
  1305. BtnPenBlue.Visibility = Visibility.Visible;
  1306. BtnPenRed.Visibility = Visibility.Visible;
  1307. BtnPenBlue_CL.Visibility = Visibility.Collapsed;
  1308. BtnPenRed_CL.Visibility = Visibility.Collapsed;
  1309. //borOne.Background = new SolidColorBrush(Colors.DodgerBlue);
  1310. //borTwo.Background = new SolidColorBrush(Colors.DodgerBlue);
  1311. }
  1312. /// <summary>
  1313. /// 切换页面
  1314. /// </summary>
  1315. void SwitchPages()
  1316. {
  1317. //SendKeys.SendWait("%{TAB}");
  1318. MouseEventCommon.MouseMiddleClickEvent(0);
  1319. }
  1320. //bool isToobar = false;
  1321. /// <summary>
  1322. /// 在工具条区域内
  1323. /// </summary>
  1324. /// <param name="sender"></param>
  1325. /// <param name="e"></param>
  1326. private void gridToobarTwo_MouseEnter(object sender, System.Windows.Input.MouseEventArgs e)
  1327. {
  1328. //isToobar = true;
  1329. }
  1330. private void gridToobarTwo_MouseLeave(object sender, System.Windows.Input.MouseEventArgs e)
  1331. {
  1332. //if (BtnRecordingScreen.ToolTip.ToString().Equals("暂停") && (gridToobar.Visibility == Visibility.Visible || BorderBlack.Visibility == Visibility.Visible))
  1333. if(BtnRecordingScreenPause.Visibility == Visibility.Visible)
  1334. {
  1335. if (APP.IsHideSRTool)
  1336. {
  1337. if (APP.W_MinToolbar == null)
  1338. {
  1339. APP.W_MinToolbar = new MinToolbar();
  1340. }
  1341. APP.W_MinToolbar.Topmost = true;
  1342. double MinToolTop = Top;
  1343. //int ColorType = 0;
  1344. //if (APP.SkinStyle == "1")
  1345. //{
  1346. // ColorType = 0;
  1347. // MinToolTop = this.Top + ((this.ActualHeight - btnReturn.ActualHeight) / 2);
  1348. //}
  1349. //else if (APP.SkinStyle == "2")
  1350. //{
  1351. // ColorType = 1;
  1352. // MinToolTop = this.Top + ((this.ActualHeight - VbxBlack.ActualHeight) / 2);
  1353. //}
  1354. new Thread(new ThreadStart(new Action(() =>
  1355. {
  1356. Thread.Sleep(500);
  1357. Dispatcher.Invoke(() =>
  1358. {
  1359. MouseEventCommon.GetCursorPos(out MouseEventCommon.POINT pointRecord);
  1360. if (pointRecord.X >= this.Left && pointRecord.X < this.Left + this.ActualWidth && pointRecord.Y >= this.Top && pointRecord.Y < this.Top + this.ActualHeight)
  1361. {
  1362. //LblMessage.Content = "在区域内:("+ pointRecord.X+","+pointRecord.Y+") ("+ Left + ","+Top+")";
  1363. }
  1364. else
  1365. {
  1366. //LblMessage.Content = "不在区域内:(" + pointRecord.X + "," + pointRecord.Y + ") (" + Left + "," + Top + ")";
  1367. APP.W_MinToolbar.Initialize(MinToolTop, ActualHeight);
  1368. GridSrToobar.Visibility = Visibility.Hidden;
  1369. APP.W_MinToolbar.Show();
  1370. }
  1371. });
  1372. }))).Start();
  1373. }
  1374. }
  1375. }
  1376. }
  1377. }