星火微课系统客户端
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

ScreenRecordingToolbarWindow.xaml.cs 5.3KB

4 år sedan
4 år sedan
4 år sedan
4 år sedan
4 år sedan
4 år sedan
4 år sedan
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. using Common.system;
  2. using System;
  3. using System.Windows;
  4. using XHWK.Model;
  5. namespace XHWK.WKTool
  6. {
  7. /// <summary>
  8. /// 录屏工具栏
  9. /// </summary>
  10. public partial class ScreenRecordingToolbarWindow : Window
  11. {
  12. #region 初始变量
  13. /// <summary>
  14. /// 视频存储路径
  15. /// </summary>
  16. string RSPath;
  17. /// <summary>
  18. /// 是否正在录制
  19. /// </summary>
  20. bool IsStartRS = false;
  21. /// <summary>
  22. /// 是否暂停
  23. /// </summary>
  24. bool IsSuspend = true;
  25. /// <summary>
  26. /// 录屏
  27. /// </summary>
  28. FFMpeg Ffmpeg = null;
  29. #endregion
  30. #region 初始化
  31. /// <summary>
  32. /// 录屏工具栏
  33. /// </summary>
  34. public ScreenRecordingToolbarWindow()
  35. {
  36. InitializeComponent();
  37. }
  38. /// <summary>
  39. /// 初始化
  40. /// </summary>
  41. public void Initialize()
  42. {
  43. //隐藏画笔工具栏
  44. BtnToolbarDown_Click(null, null);
  45. IsStartRS = false;
  46. IsSuspend = true;
  47. RSPath = null;
  48. if (Ffmpeg == null)
  49. {
  50. Ffmpeg = new FFMpeg();
  51. }
  52. }
  53. #endregion
  54. #region 录制
  55. /// <summary>
  56. /// 停止录像
  57. /// </summary>
  58. /// <param name="sender"></param>
  59. /// <param name="e"></param>
  60. private void BtnStopRecordingScreen_Click(object sender, RoutedEventArgs e)
  61. {
  62. if (APP.W_XHMicroLessonSystemWindow == null)
  63. {
  64. APP.W_XHMicroLessonSystemWindow = new XHMicroLessonSystemWindow();
  65. }
  66. APP.W_XHMicroLessonSystemWindow.Show();
  67. try
  68. {
  69. Ffmpeg.StopFFmpeg(RSPath);
  70. }
  71. catch (Exception ex)
  72. {
  73. MessageBox.Show(ex.Message);
  74. }
  75. IsStartRS = false;
  76. Hide();
  77. }
  78. /// <summary>
  79. /// 开始或暂停录制
  80. /// </summary>
  81. /// <param name="sender"></param>
  82. /// <param name="e"></param>
  83. private void BtnRecordingScreen_Click(object sender, RoutedEventArgs e)
  84. {
  85. if (IsSuspend)
  86. {
  87. if(IsStartRS)
  88. {
  89. }
  90. //timer = new DispatcherTimer();
  91. //timer.Interval = TimeSpan.FromMilliseconds(1000);
  92. //timer.Tick += Timer_Tick;//你的事件
  93. //dt = Convert.ToDateTime("2020-01-01 00:00:00");
  94. //FileToolsCommon.DeleteDirectory(RSPath);
  95. IsSuspend = false;
  96. IsStartRS = true;
  97. BtnRecordingScreen.Content = "暂停录制";
  98. try
  99. {
  100. RSPath = APP.WkSavePath;
  101. FileToolsCommon.CreateDirectory(RSPath);
  102. RSPath += "." + ((Emum_VideoType)int.Parse(FileToolsCommon.GetConfigValue("VideoType"))).ToString();
  103. Ffmpeg.StartRecordingVideo(RSPath);
  104. }
  105. catch (Exception ex)
  106. {
  107. MessageBox.Show(ex.Message);
  108. }
  109. }
  110. else
  111. {
  112. IsSuspend = true;
  113. try
  114. {
  115. Ffmpeg.SuspendFFmpeg();
  116. Ffmpeg.StopFFmpeg(RSPath);
  117. }
  118. catch (Exception ex)
  119. {
  120. MessageBox.Show(ex.Message);
  121. }
  122. }
  123. }
  124. #endregion
  125. #region 画笔相关
  126. /// <summary>
  127. /// 画笔工具栏关闭事件
  128. /// </summary>
  129. /// <param name="sender"></param>
  130. /// <param name="e"></param>
  131. private void BtnToolbarDown_Click(object sender, RoutedEventArgs e)
  132. {
  133. gridToolbar.Visibility = Visibility.Hidden;
  134. gridColour.Visibility = Visibility.Hidden;
  135. gridThickness.Visibility = Visibility.Hidden;
  136. }
  137. /// <summary>
  138. /// 画笔点击事件
  139. /// </summary>
  140. /// <param name="sender"></param>
  141. /// <param name="e"></param>
  142. private void BtnBrush_Click(object sender, RoutedEventArgs e)
  143. {
  144. if (gridToolbar.Visibility == Visibility.Visible)
  145. {
  146. gridToolbar.Visibility = Visibility.Hidden;
  147. }
  148. else
  149. {
  150. gridToolbar.Visibility = Visibility.Visible;
  151. }
  152. }
  153. /// <summary>
  154. /// 画笔粗细事件
  155. /// </summary>
  156. /// <param name="sender"></param>
  157. /// <param name="e"></param>
  158. private void BtnThickness_Click(object sender, RoutedEventArgs e)
  159. {
  160. gridThickness.Visibility = Visibility.Visible;
  161. gridColour.Visibility = Visibility.Collapsed;
  162. }
  163. /// <summary>
  164. /// 画笔颜色事件
  165. /// </summary>
  166. /// <param name="sender"></param>
  167. /// <param name="e"></param>
  168. private void BtnColour_Click(object sender, RoutedEventArgs e)
  169. {
  170. gridColour.Visibility = Visibility.Visible;
  171. gridThickness.Visibility = Visibility.Collapsed;
  172. }
  173. #endregion
  174. }
  175. }