星火微课系统客户端
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

ScreenRecordingToolbarWindow.xaml.cs 49KB

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