星火微课系统客户端
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

ScreenRecordingToolbarWindow.xaml.cs 53KB

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