using Common.system; using System; using System.Windows; using XHWK.Model; namespace XHWK.WKTool { /// /// 录屏工具栏 /// public partial class ScreenRecordingToolbarWindow : Window { #region 初始变量 /// /// 视频存储路径 /// string RSPath; /// /// 是否正在录制 /// bool IsStartRS = false; /// /// 是否暂停 /// bool IsSuspend = true; /// /// 录屏 /// FFMpeg Ffmpeg = null; #endregion #region 初始化 /// /// 录屏工具栏 /// public ScreenRecordingToolbarWindow() { InitializeComponent(); } /// /// 初始化 /// public void Initialize() { //隐藏画笔工具栏 BtnToolbarDown_Click(null, null); IsStartRS = false; IsSuspend = true; RSPath = null; if (Ffmpeg == null) { Ffmpeg = new FFMpeg(); } } #endregion #region 录制 /// /// 停止录像 /// /// /// private void BtnStopRecordingScreen_Click(object sender, RoutedEventArgs e) { if (APP.W_XHMicroLessonSystemWindow == null) { APP.W_XHMicroLessonSystemWindow = new XHMicroLessonSystemWindow(); } APP.W_XHMicroLessonSystemWindow.Show(); try { Ffmpeg.StopFFmpeg(RSPath); } catch (Exception ex) { MessageBox.Show(ex.Message); } IsStartRS = false; Hide(); } /// /// 开始或暂停录制 /// /// /// private void BtnRecordingScreen_Click(object sender, RoutedEventArgs e) { if (IsSuspend) { if(IsStartRS) { } //timer = new DispatcherTimer(); //timer.Interval = TimeSpan.FromMilliseconds(1000); //timer.Tick += Timer_Tick;//你的事件 //dt = Convert.ToDateTime("2020-01-01 00:00:00"); //FileToolsCommon.DeleteDirectory(RSPath); IsSuspend = false; IsStartRS = true; BtnRecordingScreen.Content = "暂停录制"; try { RSPath = APP.WkSavePath; FileToolsCommon.CreateDirectory(RSPath); RSPath += "." + ((Emum_VideoType)int.Parse(FileToolsCommon.GetConfigValue("VideoType"))).ToString(); Ffmpeg.StartRecordingVideo(RSPath); } catch (Exception ex) { MessageBox.Show(ex.Message); } } else { IsSuspend = true; try { Ffmpeg.SuspendFFmpeg(); Ffmpeg.StopFFmpeg(RSPath); } catch (Exception ex) { MessageBox.Show(ex.Message); } } } #endregion #region 画笔相关 /// /// 画笔工具栏关闭事件 /// /// /// private void BtnToolbarDown_Click(object sender, RoutedEventArgs e) { gridToolbar.Visibility = Visibility.Hidden; gridColour.Visibility = Visibility.Hidden; gridThickness.Visibility = Visibility.Hidden; } /// /// 画笔点击事件 /// /// /// private void BtnBrush_Click(object sender, RoutedEventArgs e) { if (gridToolbar.Visibility == Visibility.Visible) { gridToolbar.Visibility = Visibility.Hidden; } else { gridToolbar.Visibility = Visibility.Visible; } } /// /// 画笔粗细事件 /// /// /// private void BtnThickness_Click(object sender, RoutedEventArgs e) { gridThickness.Visibility = Visibility.Visible; gridColour.Visibility = Visibility.Collapsed; } /// /// 画笔颜色事件 /// /// /// private void BtnColour_Click(object sender, RoutedEventArgs e) { gridColour.Visibility = Visibility.Visible; gridThickness.Visibility = Visibility.Collapsed; } #endregion } }