123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181 |
- using Common.system;
-
- using System;
- using System.Windows;
-
- using XHWK.Model;
-
- namespace XHWK.WKTool
- {
- /// <summary>
- /// 录屏工具栏
- /// </summary>
- public partial class ScreenRecordingToolbarWindow : Window
- {
- #region 初始变量
- /// <summary>
- /// 视频存储路径
- /// </summary>
- string RSPath;
- /// <summary>
- /// 是否正在录制
- /// </summary>
- bool IsStartRS = false;
- /// <summary>
- /// 是否暂停
- /// </summary>
- bool IsSuspend = true;
- /// <summary>
- /// 录屏
- /// </summary>
- FFMpeg Ffmpeg = null;
- #endregion
-
- #region 初始化
- /// <summary>
- /// 录屏工具栏
- /// </summary>
- public ScreenRecordingToolbarWindow()
- {
- InitializeComponent();
- }
- /// <summary>
- /// 初始化
- /// </summary>
- public void Initialize()
- {
- //隐藏画笔工具栏
- BtnToolbarDown_Click(null, null);
- IsStartRS = false;
- IsSuspend = true;
- RSPath = null;
- if (Ffmpeg == null)
- {
- Ffmpeg = new FFMpeg();
- }
- }
- #endregion
-
- #region 录制
- /// <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
- {
- Ffmpeg.StopFFmpeg(RSPath);
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.Message);
- }
- IsStartRS = false;
- Hide();
- }
- /// <summary>
- /// 开始或暂停录制
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- 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 画笔相关
- /// <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
- }
- }
|