星火微课系统客户端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ScreenRecordingToolbarWindow.xaml.cs 49KB

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