星火微课系统客户端
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

ScreenRecordingToolbarWindow.xaml.cs 5.7KB

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