using Common.system; using System; using System.IO; using System.Threading; using System.Windows; using System.Windows.Forms; using System.Windows.Ink; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Threading; using XHWK.Model; namespace XHWK.WKTool { /// /// 录屏工具栏 /// public partial class ScreenRecordingToolbarWindow : Window { #region 初始变量 /// /// 视频保存名称 /// private string VideoSavePathName; /// /// 是否首次录屏 /// private bool IsFirstRS = true; /// /// 是否暂停 /// private bool IsSuspend = true; /// /// 视频信息 /// private Model_Video VideoInfo = null; //声明一个 DrawingAttributes 类型的变量 private DrawingAttributes drawingAttributes; private DispatcherTimer t = null; /// /// 计时器状态 /// private enum State { Start, Pause, End } /// /// 状态 /// private State _state = State.End; /// /// 计时用 /// private TimeSpan _timeSpan = new TimeSpan(0, 0, 0, 0, 0); private KeyboardHookCommon k_hook; /// /// 🖊状态 0红色 1蓝色 10红色批注内 11蓝色批注内 /// public int flg = 0; private System.Timers.Timer timer = new System.Timers.Timer(); #endregion #region 初始化 /// /// 录屏工具栏 /// public ScreenRecordingToolbarWindow() { InitializeComponent(); } /// /// 初始化 /// public void Initialize() { //timer = new System.Timers.Timer(200); //timer.Interval = 300; //timer.Elapsed += new System.Timers.ElapsedEventHandler(TimerDealy); //timer.Enabled = true; //启动计时器 borOne.Background = new SolidColorBrush(Colors.DodgerBlue); borTwo.Background = new SolidColorBrush(Colors.DodgerBlue); k_hook = new KeyboardHookCommon(); k_hook.KeyDownEvent += K_hook_KeyDownEvent; //创建 DrawingAttributes 类的一个实例 drawingAttributes = new DrawingAttributes(); //将 InkCanvas 的 DefaultDrawingAttributes 属性的值赋成创建的 DrawingAttributes 类的对象的引用 //InkCanvas 通过 DefaultDrawingAttributes 属性来获取墨迹的各种设置,该属性的类型为 DrawingAttributes 型 blackboard_canvas.DefaultDrawingAttributes = drawingAttributes; drawingAttributes.FitToCurve = true; //隐藏画笔工具栏 //BtnToolbarDown_Click(null, null); gridToolbar.Visibility = Visibility.Hidden; gridColour.Visibility = Visibility.Hidden; gridThickness.Visibility = Visibility.Hidden; imgReturn.Source = new BitmapImage(new Uri("pack://application:,,,/Images/Toobar29.png")); btnReturn.IsEnabled = true;//返回主界面可点击 ImgRecordingScreen.Source = new BitmapImage(new Uri("pack://application:,,,/Images/Toobar26.png"));//大圆圈三角形 ImgEndRecordingScreen.Source = new BitmapImage(new Uri("pack://application:,,,/Images/Toobar15.png")); BtnStopRecordingScreen.IsEnabled = false; //停止录制按钮不点击 imgBlackPenOne.Source = new BitmapImage(new Uri("pack://application:,,,/Images/31.png")); btnBlackPenOne.IsEnabled = false;//蓝笔不可点击 imgBlackPenTwo.Source = new BitmapImage(new Uri("pack://application:,,,/Images/31.png")); btnBlackPenTwo.IsEnabled = false;//红笔不可点击 //imgReturn.Source = new BitmapImage(new Uri("pack://application:,,,/Images/Toobar29.png")); //btnReturn.IsEnabled = true;//返回主界面可点击 txbTime.Visibility = Visibility.Hidden;//时间不显示 if (t == null) { t = new DispatcherTimer(); t.Tick += OnTimer; t.Interval = new TimeSpan(0, 0, 0, 1); t.IsEnabled = true; t.Start(); } t.Interval = new TimeSpan(0, 0, 0, 1); //Stack(); //ImgRecordingScreen.Source = new BitmapImage(new Uri("pack://application:,,,/Images/Toobar25.png")); //BtnRecordingScreen_Click(null, null); } private void TimerDealy(object o, EventArgs e) { Dispatcher.Invoke(() => { if (Left > 1630) { return; } //获取鼠标在屏幕上的位置 double mouse_x = Form.MousePosition.X; //需要添加引用System.Drawing double mouse_y = Form.MousePosition.Y; bool is_in_collasped_range = (mouse_y > Left + Height) || (mouse_x < Left || mouse_x > Left + Width);//缩起的条件 bool is_in_visiable_range = (mouse_y < 1 && mouse_x >= Left && mouse_x <= Left + Width); //展开的条件 if (Left < 1630 && Left >= 0 && is_in_collasped_range) { System.Threading.Thread.Sleep(300); Left += 20 /*-this.ActualWidth - 3*/; } else if (Left < 0 && is_in_visiable_range) { Left = 1; } }); } private void K_hook_KeyDownEvent(object sender, System.Windows.Forms.KeyEventArgs e) { if (e.KeyValue == (int)System.Windows.Forms.Keys.F5 && (int)Control.ModifierKeys == (int)Keys.Control) { //开始,暂停 BtnRecordingScreen_Click(null, null); } if (e.KeyValue == (int)Keys.S && (int)Control.ModifierKeys == (int)Keys.Control) { //结束 BtnStopRecordingScreen_Click(null, null); } } #endregion #region 事件 /// /// 时钟回调 /// /// /// private void OnTimer(object sender, EventArgs e) { switch (_state) { case State.Start: { _timeSpan += new TimeSpan(0, 0, 0, 1); } break; case State.Pause: { } break; case State.End: { _timeSpan = new TimeSpan(); //_timeSpan = new TimeSpan(0, 23, 12, 45, 54); } break; } string time = string.Format("{0:D2}:{1:D2}",/* _timeSpan.Hours,*/ _timeSpan.Minutes, _timeSpan.Seconds); //char[] times = time.ToCharArray(); txbTime.Text = time; } /// /// 开始 /// /// /// private void Stack() { _state = State.Start; } /// /// 暂停 /// private void TimeOut() { _state = State.Pause; } /// /// 结束 /// /// /// private void End() { _state = State.End; } #region 录屏 /// /// 设置录屏文件地址 /// private void SetUpVideoPathName() { //FileToolsCommon.DeleteDirectory(APP.WKData.WkPath + "temp/"); FileToolsCommon.CreateDirectory(APP.WKData.WkPath); FileToolsCommon.DeleteDirectory(APP.WKData.WkPath + "temprs/"); VideoSavePathName = APP.WKData.WkPath + APP.WKData.WkName + "_录屏." + ((Enum_VideoType)int.Parse(FileToolsCommon.GetConfigValue("VideoType"))).ToString(); int num = 1; while (FileToolsCommon.IsExistFile(VideoSavePathName)) { VideoSavePathName = APP.WKData.WkPath + APP.WKData.WkName + "_录屏_" + num + "." + ((Enum_VideoType)int.Parse(FileToolsCommon.GetConfigValue("VideoType"))).ToString(); num++; } } /// /// 开始或暂停录制 /// /// /// private void BtnRecordingScreen_Click(object sender, RoutedEventArgs e) { if (IsSuspend) { if (IsFirstRS) { #region 检测麦克风扬声器是否可用 string audioSpeakerPath = FileToolsCommon.GetFileAbsolutePath("adoS.m"); string audioMicrophonePath = FileToolsCommon.GetFileAbsolutePath("adoM.m"); try { FileToolsCommon.DeleteFile(audioSpeakerPath); FileToolsCommon.DeleteFile(audioMicrophonePath); } catch (Exception) { } //扬声器 if (APP.FFmpeg.StartRecordSpeakerAudio(audioSpeakerPath)) { APP.FFmpeg.StopRecordAudio(2); //Thread.Sleep(500); //麦克风 if (APP.FFmpeg.StartRecordAudio(audioMicrophonePath)) { } else { //无法录制麦克风 MessageBoxResult Res = MessageWindow.Show("当前电脑无法录制麦克风,是否继续?", "消息提示", MessageBoxButton.OKCancel); if (Res == MessageBoxResult.Cancel) { return; } } APP.FFmpeg.StopRecordAudio(1); } else { //无法录制扬声器音频 MessageBoxResult Res = MessageWindow.Show("当前电脑无法录制音频,是否继续?", "消息提示", MessageBoxButton.OKCancel); if (Res == MessageBoxResult.Cancel) { return; } } #endregion VideoInfo = new Model_Video { VideoType = (Enum_VideoType)int.Parse(FileToolsCommon.GetConfigValue("VideoType")), WkType = Enum_WKVidetype.RecordingScreen }; SetUpVideoPathName(); IsFirstRS = false; k_hook.Start();//安装键盘钩子 if (APP.W_CountdownWindow == null) { APP.W_CountdownWindow = new CountdownWindow(); APP.W_CountdownWindow.Initialize(true, 1800); //APP.W_CountdownWindow.Topmost = true; } else { APP.W_CountdownWindow.Initialize(true, 1800); //APP.W_CountdownWindow.Topmost = true; } APP.W_CountdownWindow.Show(); } IsSuspend = false; //#region 录像倒计时 //if (APP.W_CountdownWindow == null) //{ // APP.W_CountdownWindow = new CountdownWindow(); // //APP.W_CountdownWindow.Topmost = true; //} //else //{ // APP.W_CountdownWindow.Initialize(); // //APP.W_CountdownWindow.Topmost = true; //} //APP.W_CountdownWindow.Show(); //#endregion ImgRecordingScreen.Source = new BitmapImage(new Uri("pack://application:,,,/Images/Toobar25.png"));//播放状态 ImgEndRecordingScreen.Source = new BitmapImage(new Uri("pack://application:,,,/Images/Toobar14.png")); BtnStopRecordingScreen.IsEnabled = true; //停止录制按钮可点击 imgBlackPenOne.Source = new BitmapImage(new Uri("pack://application:,,,/Images/Toobar27.png")); btnBlackPenOne.IsEnabled = true;//蓝笔可点击 imgBlackPenTwo.Source = new BitmapImage(new Uri("pack://application:,,,/Images/Toobar28.png")); btnBlackPenTwo.IsEnabled = true;//红笔可点击 txbTime.Visibility = Visibility.Visible;//时间显示 imgReturn.Source = new BitmapImage(new Uri("pack://application:,,,/Images/Toobar30.png")); btnReturn.IsEnabled = false;//返回主界面可点击 //borOne.Background = new SolidColorBrush(Colors.LightBlue); try { new Thread(new ThreadStart(new Action(() => { if (IsFirstRS) { Thread.Sleep(1500); } if(APP.FFmpeg.myProcess!=null) { Thread.Sleep(100); } APP.FFmpeg.StartRecordingVideo(VideoSavePathName); Thread.Sleep(1000); Dispatcher.Invoke(() => { Stack(); }); }))).Start(); } catch (Exception ex) { MessageWindow.Show(ex.Message); } } else { TimeOut(); IsSuspend = true; ImgRecordingScreen.Source = new BitmapImage(new Uri("pack://application:,,,/Images/Toobar26.png"));//大圆圈三角形 ImgEndRecordingScreen.Source = new BitmapImage(new Uri("pack://application:,,,/Images/Toobar15.png")); BtnStopRecordingScreen.IsEnabled = false; //停止录制按钮不点击 imgBlackPenOne.Source = new BitmapImage(new Uri("pack://application:,,,/Images/31.png")); btnBlackPenOne.IsEnabled = false;//蓝笔不可点击 imgBlackPenTwo.Source = new BitmapImage(new Uri("pack://application:,,,/Images/31.png")); btnBlackPenTwo.IsEnabled = false;//红笔不可点击 txbTime.Visibility = Visibility.Hidden;//时间不显示 imgReturn.Source = new BitmapImage(new Uri("pack://application:,,,/Images/Toobar29.png")); btnReturn.IsEnabled = true;//返回主界面可点击 #region 2秒内不可点击 new Thread(new ThreadStart(new Action(() => { Dispatcher.Invoke(() => { BtnRecordingScreen.IsEnabled = false; BtnStopRecordingScreen.IsEnabled = false; }); Thread.Sleep(2000); Dispatcher.Invoke(() => { ImgEndRecordingScreen.Source = new BitmapImage(new Uri("pack://application:,,,/Images/Toobar14.png")); BtnRecordingScreen.IsEnabled = true; BtnStopRecordingScreen.IsEnabled = true; }); }))).Start(); #endregion try { APP.FFmpeg.SuspendFFmpeg(); } catch (Exception ex) { MessageWindow.Show(ex.Message); } } } /// /// 停止录像 /// /// /// private void BtnStopRecordingScreen_Click(object sender, RoutedEventArgs e) { k_hook.Stop(); IsSuspend = true; txbTime.Text = "00:00"; txbTime.Visibility = Visibility.Hidden; End(); if (APP.W_PracticeWindow != null) { if (APP.W_PracticeWindow.Visibility == Visibility.Visible) { APP.W_PracticeWindow.Hide(); } } if (gridToolbar.Visibility == Visibility.Visible) { gridToolbar.Visibility = Visibility.Hidden; gridColour.Visibility = Visibility.Hidden; gridThickness.Visibility = Visibility.Hidden; } if (APP.W_XHMicroLessonSystemWindow == null) { APP.W_XHMicroLessonSystemWindow = new XHMicroLessonSystemWindow(); } APP.W_XHMicroLessonSystemWindow.Show(); if (!IsFirstRS) { try { try { APP.FFmpeg.StopFFmpeg(VideoSavePathName); } catch (Exception ex) { LogHelper.WriteErrLog("【停止录屏】(BtnStopRecordingScreen_Click)" + ex.Message, ex); } IsFirstRS = true; //生成缩略图 string ThumbnailPath = FileToolsCommon.GetDirectoryName(VideoSavePathName) + "ThumbnailPath/"; FileToolsCommon.CreateDirectory(ThumbnailPath); //缩略图存储位置 string ThumbnailPathName = ThumbnailPath + FileToolsCommon.GetIOFileName(VideoSavePathName).Replace(".", "") + ".JPG"; new Thread(new ThreadStart(new Action(() => { while (!FileToolsCommon.IsExistFile(VideoSavePathName)) { Thread.Sleep(100); } FileToolsCommon.DeleteFile(ThumbnailPathName); //VideoInfo.VideoSize = FileToolsCommon.GetFileSizeByMB(VideoSavePathName).ToString() + " MB"; VideoInfo.RSTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); VideoInfo.VideoPath = VideoSavePathName; VideoInfo.ThumbnailPath = ThumbnailPathName; APP.FFmpeg.GenerateThumbnails(VideoSavePathName, ThumbnailPathName); VideoInfo.FileGuid = Guid.NewGuid().ToString(); VideoInfo.IsUpload = false; VideoInfo.Uploaded = 0; VideoInfo.Savefolder = APP.UserInfo.Schoolid + "/resource"; APP.VideoList.Add(VideoInfo); //保存数据 APP.SaveWkData(); }))).Start(); Click_stopRecordingScreen(); } catch (Exception ex) { LogHelper.WriteErrLog("【停止录屏】(BtnStopRecordingScreen_Click)" + ex.Message, ex); } } Hide(); } #endregion #region 画笔相关 /// /// 画笔工具栏关闭事件 /// /// /// private void BtnToolbarDown_Click(object sender, RoutedEventArgs e) { gridToolbar.Visibility = Visibility.Hidden; gridColour.Visibility = Visibility.Hidden; gridThickness.Visibility = Visibility.Hidden; APP.W_PracticeWindow.Hide(); } /// /// 画笔点击事件 /// /// /// private void BtnBrush_Click(object sender, RoutedEventArgs e) { string time = GetTimeStamp(); string tempPath = AppDomain.CurrentDomain.BaseDirectory + "temp\\"; if (!Directory.Exists(tempPath)) { Directory.CreateDirectory(tempPath); } string imagePath = Path.Combine(tempPath, time + ".jpg"); ImageHelper.GetScreenshot(new System.Drawing.Rectangle(0, 0, 0, 0), imagePath, true, out BitmapImage bitmap); try { if (flg == 11) { Dispatcher.Invoke(() => { borOne.Background = new SolidColorBrush(Colors.DodgerBlue); borTwo.Background = new SolidColorBrush(Colors.DodgerBlue); }); flg = 1; APP.W_PracticeWindow.Hide(); } else if (flg == 10) { Dispatcher.Invoke(() => { borOne.Background = new SolidColorBrush(Colors.LightSkyBlue); borTwo.Background = new SolidColorBrush(Colors.DodgerBlue); }); APP.W_PracticeWindow.Blue(); flg = 11; } else { //new Thread(new ThreadStart(new Action(() => //{ Dispatcher.Invoke(() => { borOne.Background = new SolidColorBrush(Colors.LightSkyBlue); borTwo.Background = new SolidColorBrush(Colors.DodgerBlue); }); //}))).Start(); if (APP.W_PracticeWindow == null) { APP.W_PracticeWindow = new PracticeWindow { //APP.W_PracticeWindow.Topmost = true; Width = pwidth, Height = pHeight, Left = 0, Top = 0 }; //practiceWin.Owner = this; } APP.W_PracticeWindow.Initialize(imagePath); flg = 11; APP.W_PracticeWindow.Blue(); APP.W_PracticeWindow.Show(); } } catch (Exception ex) { LogHelper.WriteErrLog("【批注(PracticeWindow)" + ex.Message, ex); } //imgCanvas.Source = new BitmapImage(new Uri(imagePath)); } /// /// 屏幕宽 /// internal double pwidth = SystemParameters.PrimaryScreenWidth; /// /// 屏幕高 /// internal double pHeight = SystemParameters.PrimaryScreenHeight; /// /// 获取时间戳 /// /// public string GetTimeStamp() { TimeSpan ts = DateTime.Now - new DateTime(1970, 1, 1, 0, 0, 0, 0); return Convert.ToInt64(ts.TotalMilliseconds).ToString(); } /// /// 画笔粗细事件 /// /// /// 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; } /// /// 白色 /// /// /// private void BtnWhite_Click(object sender, RoutedEventArgs e) { //drawingAttributes.Color = Colors.White; APP.W_PracticeWindow.White(); gridColour.Visibility = Visibility.Collapsed; gridThickness.Visibility = Visibility.Collapsed; } /// /// 红色 /// /// /// private void BtnRed_Click(object sender, RoutedEventArgs e) { //drawingAttributes.Color = Colors.Red; APP.W_PracticeWindow.Red(); gridColour.Visibility = Visibility.Collapsed; gridThickness.Visibility = Visibility.Collapsed; } /// /// 黄色 /// /// /// private void BtnYellow_Click(object sender, RoutedEventArgs e) { //drawingAttributes.Color = Colors.Gold; APP.W_PracticeWindow.Yellow(); gridColour.Visibility = Visibility.Collapsed; gridThickness.Visibility = Visibility.Collapsed; } /// /// 青色 /// /// /// private void BtnCyanBlue_Click(object sender, RoutedEventArgs e) { //drawingAttributes.Color = Colors.LimeGreen; APP.W_PracticeWindow.CyanBlue(); gridColour.Visibility = Visibility.Collapsed; gridThickness.Visibility = Visibility.Collapsed; } /// /// 灰色 /// /// /// private void BtnGray_Click(object sender, RoutedEventArgs e) { //drawingAttributes.Color = Colors.Gray; APP.W_PracticeWindow.Gray(); gridColour.Visibility = Visibility.Collapsed; gridThickness.Visibility = Visibility.Collapsed; } /// /// 蓝色 /// /// /// private void BtnBlue_Click(object sender, RoutedEventArgs e) { //drawingAttributes.Color = Colors.DeepSkyBlue; APP.W_PracticeWindow.Blue(); gridColour.Visibility = Visibility.Collapsed; gridThickness.Visibility = Visibility.Collapsed; } /// /// 画笔 细 /// /// /// private void BtnFine_Click(object sender, RoutedEventArgs e) { APP.W_PracticeWindow.Fine(); gridColour.Visibility = Visibility.Collapsed; gridThickness.Visibility = Visibility.Collapsed; } /// /// 画笔 中 /// /// /// private void BtnIn_Click(object sender, RoutedEventArgs e) { APP.W_PracticeWindow.In(); gridColour.Visibility = Visibility.Collapsed; gridThickness.Visibility = Visibility.Collapsed; } /// /// 画笔粗 /// /// /// private void BtnCrude_Click(object sender, RoutedEventArgs e) { APP.W_PracticeWindow.Crude(); gridColour.Visibility = Visibility.Collapsed; gridThickness.Visibility = Visibility.Collapsed; } /// /// 橡皮 /// /// /// private void BtnEraser_Click(object sender, RoutedEventArgs e) { APP.W_PracticeWindow.Eraser(); } /// /// 🖊 /// /// /// private void BtnPen_Click(object sender, RoutedEventArgs e) { APP.W_PracticeWindow.Pen(); } /// /// ⚪ /// /// /// private void BtnRound_Click(object sender, RoutedEventArgs e) { APP.W_PracticeWindow.Round(); } /// /// 矩形 /// /// /// private void BtnRectangle_Click(object sender, RoutedEventArgs e) { APP.W_PracticeWindow.Rectangle(); } #endregion #endregion /// /// 停止录屏 /// public delegate void StopRecordingScreen(); /// /// 停止录屏 /// public event StopRecordingScreen Click_stopRecordingScreen; /// /// 黑笔 /// /// /// private void BtnBlackPen_Click(object sender, RoutedEventArgs e) { } /// /// 移动工具栏 /// /// /// private void Grid_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e) { DragMove(); } /// /// 红笔 /// /// /// private void BtnBlackPenTwo_Click(object sender, RoutedEventArgs e) { string time = GetTimeStamp(); string tempPath = AppDomain.CurrentDomain.BaseDirectory + "temp\\"; if (!Directory.Exists(tempPath)) { Directory.CreateDirectory(tempPath); } string imagePath = Path.Combine(tempPath, time + ".jpg"); ImageHelper.GetScreenshot(new System.Drawing.Rectangle(0, 0, 0, 0), imagePath, true, out BitmapImage bitmap); try { if (flg == 10) { Dispatcher.Invoke(() => { borOne.Background = new SolidColorBrush(Colors.DodgerBlue); borTwo.Background = new SolidColorBrush(Colors.DodgerBlue); }); flg = 0; APP.W_PracticeWindow.Hide(); } else if (flg == 11) { Dispatcher.Invoke(() => { borTwo.Background = new SolidColorBrush(Colors.LightSkyBlue); borOne.Background = new SolidColorBrush(Colors.DodgerBlue); }); flg = 10; APP.W_PracticeWindow.Red(); } else { Dispatcher.Invoke(() => { borTwo.Background = new SolidColorBrush(Colors.LightSkyBlue); borOne.Background = new SolidColorBrush(Colors.DodgerBlue); }); if (APP.W_PracticeWindow == null) { APP.W_PracticeWindow = new PracticeWindow { //APP.W_PracticeWindow.Topmost = true; Width = pwidth, Height = pHeight, Left = 0, Top = 0 }; //practiceWin.Owner = this; } APP.W_PracticeWindow.Initialize(imagePath); flg = 10; APP.W_PracticeWindow.Red(); APP.W_PracticeWindow.Show(); } } catch (Exception ex) { LogHelper.WriteErrLog("【批注(PracticeWindow)" + ex.Message, ex); } } /// /// 鼠标右键按下事件 /// /// /// private void RightButtonDown() { if (flg > 9) { APP.W_PracticeWindow.Hide(); } else { string time = GetTimeStamp(); string tempPath = AppDomain.CurrentDomain.BaseDirectory + "temp\\"; if (!Directory.Exists(tempPath)) { Directory.CreateDirectory(tempPath); } string imagePath = Path.Combine(tempPath, time + ".jpg"); ImageHelper.GetScreenshot(new System.Drawing.Rectangle(0, 0, 0, 0), imagePath, true, out BitmapImage bitmap); try { if (APP.W_PracticeWindow == null) { APP.W_PracticeWindow = new PracticeWindow { //APP.W_PracticeWindow.Topmost = true; Width = pwidth, Height = pHeight, Left = 0, Top = 0 }; //practiceWin.Owner = this; } APP.W_PracticeWindow.Initialize(imagePath); if (flg == 0) { flg = 10; APP.W_PracticeWindow.Red(); } else { flg = 11; APP.W_PracticeWindow.Blue(); } APP.W_PracticeWindow.Show(); } catch (Exception ex) { LogHelper.WriteErrLog("【批注(PracticeWindow)" + ex.Message, ex); } } } /// /// 返回主界面 /// /// /// private void BtnReturn_Click(object sender, RoutedEventArgs e) { MessageBoxResult br=MessageWindow.Show("退出将不保存当前录屏!", "提示", MessageBoxButton.OKCancel); if(br==MessageBoxResult.Cancel) { return; } k_hook.Stop(); IsSuspend = true; txbTime.Text = "00:00"; txbTime.Visibility = Visibility.Hidden; End(); if (APP.W_PracticeWindow != null) { if (APP.W_PracticeWindow.Visibility == Visibility.Visible) { APP.W_PracticeWindow.Hide(); } } if (gridToolbar.Visibility == Visibility.Visible) { gridToolbar.Visibility = Visibility.Hidden; gridColour.Visibility = Visibility.Hidden; gridThickness.Visibility = Visibility.Hidden; } if (APP.W_XHMicroLessonSystemWindow == null) { MessageBoxResult dr = MessageWindow.Show("返回主界面视频不保存,是否返回?", "提示", MessageBoxButton.OKCancel); if (dr == MessageBoxResult.OK) { IsSuspend = true; txbTime.Text = "00:00"; txbTime.Visibility = Visibility.Hidden; End(); if (APP.W_XHMicroLessonSystemWindow == null) { APP.W_XHMicroLessonSystemWindow = new XHMicroLessonSystemWindow(); } APP.W_XHMicroLessonSystemWindow.Show(); Hide(); } } else { if (APP.W_XHMicroLessonSystemWindow == null) { APP.W_XHMicroLessonSystemWindow = new XHMicroLessonSystemWindow(); } APP.W_XHMicroLessonSystemWindow.Show(); Hide(); } APP.W_XHMicroLessonSystemWindow.Show(); if (!IsFirstRS) { try { try { APP.FFmpeg.SuspendFFmpeg(); } catch (Exception ex) { LogHelper.WriteErrLog("【录屏返回】(BtnStopRecordingScreen_Click)" + ex.Message, ex); } IsFirstRS = true; new Thread(new ThreadStart(new Action(() => { VideoInfo = null; FileToolsCommon.DeleteDirectory(APP.WKData.WkPath + "temprs/"); }))).Start(); } catch (Exception ex) { LogHelper.WriteErrLog("【录屏返回】(BtnStopRecordingScreen_Click)" + ex.Message, ex); } } Hide(); } } }