123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182 |
- using Common.system;
-
- using System;
- using System.Windows;
- using System.Windows.Media.Imaging;
- using XHWK.Model;
-
- namespace XHWK.WKTool
- {
- /// <summary>
- /// 录屏工具栏
- /// </summary>
- public partial class ScreenRecordingToolbarWindow : Window
- {
- #region 初始变量
- /// <summary>
- /// 视频存储路径
- /// </summary>
- string RecordingPath;
- /// <summary>
- /// 视频保存名称
- /// </summary>
- string VideoSavePathName;
- /// <summary>
- /// 是否首次录屏
- /// </summary>
- bool IsFirstRS = true;
- /// <summary>
- /// 是否暂停
- /// </summary>
- bool IsSuspend = true;
- #endregion
-
- #region 初始化
- /// <summary>
- /// 录屏工具栏
- /// </summary>
- public ScreenRecordingToolbarWindow()
- {
- InitializeComponent();
- }
- /// <summary>
- /// 初始化
- /// </summary>
- public void Initialize()
- {
- //隐藏画笔工具栏
- BtnToolbarDown_Click(null, null);
- }
- #endregion
-
- #region 录制
- /// <summary>
- /// 开始或暂停录制
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void BtnRecordingScreen_Click(object sender, RoutedEventArgs e)
- {
- if (IsSuspend)
- {
- if(IsFirstRS)
- {
- RecordingPath = APP.WKData.WkPath;
- //FileToolsCommon.DeleteDirectory(APP.WKData.WkPath + "temp/");
- FileToolsCommon.CreateDirectory(RecordingPath);
- VideoSavePathName = RecordingPath + APP.WKData.WkName + "_录屏." + ((Enum_VideoType)int.Parse(FileToolsCommon.GetConfigValue("VideoType"))).ToString();
- if (FileToolsCommon.IsExistFile(VideoSavePathName))
- {
- MessageBoxResult dr = System.Windows.MessageBox.Show("已存在录屏是否覆盖?", "提示", MessageBoxButton.OKCancel);
- if (dr == MessageBoxResult.OK)
- {
- FileToolsCommon.DeleteFile(VideoSavePathName);
- }
- else
- {
- return;
- }
- }
- IsFirstRS = false;
- }
- IsSuspend = false;
- ImgRecordingScreen.Source = new BitmapImage(new Uri("pack://application:,,,/Images/Toobar25.png"));
- try
- {
- APP.FFmpeg.StartRecordingVideo(VideoSavePathName);
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.Message);
- }
- }
- else
- {
- IsSuspend = true;
- ImgRecordingScreen.Source = new BitmapImage(new Uri("pack://application:,,,/Images/Toobar25.png"));
- try
- {
- APP.FFmpeg.SuspendFFmpeg();
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.Message);
- }
- }
- }
- /// <summary>
- /// 停止录像
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void BtnStopRecordingScreen_Click(object sender, RoutedEventArgs e)
- {
- if (APP.W_XHMicroLessonSystemWindow == null)
- {
- APP.W_XHMicroLessonSystemWindow = new XHMicroLessonSystemWindow();
- }
- APP.W_XHMicroLessonSystemWindow.Show();
- try
- {
- APP.FFmpeg.StopFFmpeg(VideoSavePathName);
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.Message);
- }
- IsFirstRS = true;
- Hide();
- }
- #endregion
-
- #region 画笔相关
- /// <summary>
- /// 画笔工具栏关闭事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void BtnToolbarDown_Click(object sender, RoutedEventArgs e)
- {
- gridToolbar.Visibility = Visibility.Hidden;
- gridColour.Visibility = Visibility.Hidden;
- gridThickness.Visibility = Visibility.Hidden;
- }
- /// <summary>
- /// 画笔点击事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void BtnBrush_Click(object sender, RoutedEventArgs e)
- {
- if (gridToolbar.Visibility == Visibility.Visible)
- {
- gridToolbar.Visibility = Visibility.Hidden;
- }
- else
- {
- gridToolbar.Visibility = Visibility.Visible;
- }
- }
- /// <summary>
- /// 画笔粗细事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void BtnThickness_Click(object sender, RoutedEventArgs e)
- {
- gridThickness.Visibility = Visibility.Visible;
- gridColour.Visibility = Visibility.Collapsed;
- }
- /// <summary>
- /// 画笔颜色事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void BtnColour_Click(object sender, RoutedEventArgs e)
- {
- gridColour.Visibility = Visibility.Visible;
- gridThickness.Visibility = Visibility.Collapsed;
- }
- #endregion
- }
- }
|