星火微课系统客户端
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

ScreenRecordingToolbarWindow.xaml.cs 50KB

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